Home > Software engineering >  Put a move in the VB picturebox function figure will flash
Put a move in the VB picturebox function figure will flash

Time:10-01



Is a move of the CAM is done in the process of rotation will flash
This is I set of program
Private Sub Timer1_Timer ()
Timer1. Interval=Val (Text2. Text) 'set the animation speed
Picture1. Cls
Picture1. DrawWidth=1 'set line thicknesses
Picture1. Circle (0, 0), 5
Picture1. Circle (350, 0), apart from the 5 '2 basis points
Dim L1! , Xc! Yc! , a! , b! , theta! The beta! Alpha! , f! , Xn! , Yn! , g! , Xs! Ys! , Xt! , Yt! , k! , p! , Xe! , Ye! , Rb! , Rr! , l! , f0! , Xc1! , Yc1! , Xn1! , Yn1!
L1=350
L=Text1. Text
Rr=Text3. Text
K=180 - Text4. The value of the Text 'alpha + beta
P=Text5. Text
C=c - 1
If c & lt;=0 Then
C=c + 360
End the If
'a=(L1 ^ 2 + m ^ 2 - Rb ^ 2)/(2 * L1 * l)
'b=Atn (- a/Sqr (- a * a + 1)) + 2 * Atn (1), b=bits 0
Picture1. ForeColor=vbBlack
Picture1. Scale (500, 500) - (500, 500)
Picture1. Line (500, 0) - (500, 0)
Picture1. Line (0-500) - (0, 500) 'establishing coordinate system
Picture1. CurrentX=- 80: Picture1. CurrentY=- 50: Picture1. Print "(0, 0)", "
Picture1. CurrentX=- 85: Picture1. CurrentY=- 480: Picture1. Print "Y"
Picture1. CurrentX=440: Picture1. CurrentY=40: Picture1. Print "X"
If c & gt; 0 And c & lt; Then=90
Beta - c=k/3
ElseIf c & gt; 90 And c & lt; Then=180
Beta=k - 30
ElseIf c & gt; 180 And c & lt; Then=270
Beta=k - 90 - c/3)
ElseIf c & gt; 270 And c & lt; Then=360
Beta=k
End the If

Xs=350 + l * Cos (beta/180 * PI)
Ys=l * Sin (beta/180 * PI) '(350, 0) to the roller center of linear equation
Xt - 350-100=* Sin (PI/2 + (beta k)/180 * PI)
Yt=100 * Cos (PI/2 + (beta k)/180 * PI) '(350, 0) to the sealed deck of linear equation
Xe=350 + l * Cos (+ p (beta)/180 * PI) * Cos (p/180 * PI)
Ye Sin=l * (+ p (beta)/180 * PI) * Cos (p/180 * PI) 'roller roller center inclined to linear equations
Picture1. ForeColor=vbBlue
Picture1. DrawWidth=1.5
Picture1. Line (Xe, Ye) - (- 350, 0)
Picture1. Line (Xe - Ye) - (- 350, 0)
Picture1. Line (Xe, Ye) - (Xs and Ys)
Picture1. Line (Xe - Ye) - (Xs and Ys)
Picture1. Line (Xt, Yt) - (- 350, 0)
Picture1. Line (Xt - Yt) - (- 350, 0)
Picture1. Circle (Xs and Ys), Rr
Picture1. Circle (Xs and Ys), Rr 'line drawing and roller
F0=Sqr (L1 * L1 + l * l - 2 * l * L1 * Cos (k))
Xc1=L1 * Sin ((theta + c)/180 * PI) - l * Sin (k + theta + c)/(180 * PI)
Yc1=L1 * Cos ((theta + c)/180 * PI) - Cos l * (k + theta + c)/(180 * PI)
Xn1=Xc + Rr * ((- L1 * Sin ((theta + c)/180 * PI) + l * (g + 1) * Sin (k + c)/(180 * PI))/f0)
Yn1=Yc - Rr * ((L1 * Cos ((theta + c)/180 * PI) - (g + 1) * l * Cos (k + c)/(180 * PI))/f0)
For theta=0 To 360 Step 'g=0.6 bits (theta) derivative
If theta & gt;=0 And theta & lt; Then=90
Alpha=theta/3
Alpha beta=k
G=1/3
ElseIf theta & gt;=90 And theta & lt; Then=180
Alpha=30
Alpha beta=k
G=0
ElseIf theta & gt;=180 And theta & lt; Then=270
Alpha=90 - a third * theta
Alpha beta=k
G=1/3
The Else
Alpha=0
Alpha beta=k
G=0 'bits (theta)=beta bits 0=k - alpha bits 0
End the If 'red method, the relationship between the Angle of alpha and beta Angle beta and bits of the derivative of g (theta)
Xc=L1 * Sin ((theta + c)/180 * PI) - l * Sin (theta (beta + + c)/180 * PI)
Yc=L1 * Cos ((theta + c)/180 * PI) - l * Cos theta (beta + + c)/(180 * PI) 'bits (theta) + bits 0=beta
Picture1. PSet (Xc, Yc), vbBlack 'theoretical contour line
Picture1. PSet (Xc, Yc), vbBlue
F=Sqr (L1 ^ 2 + m ^ 2 * (g + 1) ^ 2-2 (g + 1) * L1 * l * * Cos (beta/180 * PI))
Xn=Xc + Rr * ((- L1 * Sin ((theta + c)/180 * PI) + l * (g + 1) * Sin (theta (beta + + c)/180 * PI))/f)
Yn=Yc - Rr * ((L1 * Cos (theta + c)/(180 * PI) - (g + 1) * l * Cos theta (beta + + c)/(180 * PI))/f)
Picture1. PSet (Xn, Yn), vbRed 'theoretical contour line
Picture1. PSet (Xn, Yn, vbYellow
Xc1=Xc
Yc1=Yc
Xn1=Xn
Yn1=Yn
Next theta.
End Sub
In the red tag is a little STEP, don't know if this reason I put up the STEP and then almost can't point set is formed in a straight line, has the flash is not obvious
Pray god help VB small white has just started to learn a few days ago

CodePudding user response:

Flash flash, curriculum design, there is no of these, have interest for the introduction of double buffer

CodePudding user response:

What is the matlab,,,

CodePudding user response:

Picture1 if set aotoredraw=false, the Cls under no circumstances can cause flashing

The Picture1 aotoredraw set to true, painting and invoke the Picture1, try refresh

CodePudding user response:

2 # + 10086

Don't directly on the target picturebox control drawing, because drawing takes time, so it seems that flash,
The solution is to prepare a picturebox (familiar with GDI, DC can also, of course), drawing in the picturebox first, and then paint on the target picturebox whole, so that even a time, see only card, flashing but it won't happen,

CodePudding user response:

1) with # 3, AutoRedraw + Refresh is to use buffer drawing, VB, realized the
2) the actual frequency and timer can only do it 18 times per second, you get the highest also just refresh continuous call for many times, to control the animation speed is better than the fixed frequency, change the step length is more effective,

CodePudding user response:

Animation to consider the human eye's persistence of vision effect, or flashing, at least to achieve more than 16 frames per second, the movie frames is 24 frames per second,

If the process is fixed, not to live, can draw well in advance and stored in the ImageList, demo panels when loading,
  • Related