Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Polar Orbit
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Polar Orbit
Divers
Thread ID:
01148443
Message ID:
01148443
Vues:
54
Why do two timers on the same form sync to the same interval even though their intervals are assigned different values?

I took timer 2 out of this because there was another way to affect rate. We don't often get to waste our lives with "play-time" prgs - but here's one that's really useless:
*PolarOrbit.prg Ellipse Plot
* Thurber 2006
* Red dot orbits the edge of a vertically
* Spinning disk. 
* Another classic example of wasting time writing
* "zero-gain" software.
* To affect speed of circle the the time interval
* through nRateMicroSeconds (defaults to 11).
* To change rate that dot orbits the circle
* chang the nPoints (defaults to 360)
* The path of the orbit at some rates makes a 
* symetrical "saddle" shaped infinity sign like
* those oscillo scopes in atomic age flicks.

nPoints=INT(360)
nRateMicroSeconds=11

*CALL eplot(lnXC,lnYC,lnANGLE,lnMAJOR,lnMINOR)
*nXC,nYC   - COORDINATES OF ELLIPSE CENTER
*nANGLE    - ANGLE OF ELLIPSE IN DEGREES (TILT)
*nMAJOR    - LENGTH ALONG SEMI-MAJOR AXIS
*nMINOR    - LENGTH ALONG SEMI-MINOR AXIS
PUBLIC oform,nMinor,nMajor,nC3,nS3,nXC,nYC,nC1,nS1,nS2,nS3,nc2,nc3,arVector,;
       nBallWidth,nCycles,nDotVector
nDotVector=0
nCycles=0
nXC =100
nYC =100
nAngle=0
nMajor=100
nMinor=100
nBallWidth=200
nNPTS=nPoints
DIMENSION arVector[1,2] && degrees avd vector
arVector[1,1]=0
arVector[1,2]=1
*CALCULATE THE INCREMENT ANGLE, IN RADIANS
nRINCR=DTOR(360/(nPoints-1))
*CONVERT THE INCLINATION ANGLE TO RADIANS.
nRINCL = DTOR(nAngle)
*CALCULATE THE COSINE AND SINE OF THE INCLINATION ANGLE.
nC1=COS(nRINCL)
nS1=SIN(nRINCL)
*CALCULATE THE COSINE AND SINE OF THE INCREMENT ANGLE.
nC2=COS(nRINCR)
nS2=SIN(nRINCR)
*INITIALIZE THE ACCUMULATION VARIABLES.
nC3=1.0
nS3=0.0
oform=CREATEOBJECT('theform')
oform.show
DEFINE CLASS theBigBall as Shape
curvature=99 && 99
height=200
width=200
fillstyle=1
backstyle=0
left=0
top=0
visible=.t.
borderwidth=0
bordercolor=RGB(0,0,0)
ENDDEFINE 

DEFINE CLASS theform as Form
Caption=[Polar Orbit]
width=200
height=220
scalemode=3  && Note 3 turned it off after sweep
drawmode=2 && Note 2 turned it off after sweep
visible=.t.
PROCEDURE init
this.t1.interval=nRateMicroSeconds
ENDPROC 
PROCEDURE queryunload
CLEAR EVENTS
ENDPROC 
ADD OBJECT t1 as theTimer
ADD OBJECT aDot as theDot
ADD OBJECT Ball1 as theBigBall
ENDDEFINE 

DEFINE CLASS theTimer as Timer
interval=0
PROCEDURE timer
movedot(thisform)
ENDPROC 
ENDDEFINE 

DEFINE CLASS theDot as Shape
width=7
height=7
top=0
left=0
curvature=99
borderwidth=3
backstyle=0
bordercolor=255
fillcolor=255
ENDDEFINE 

DEFINE CLASS thelabel as Label
ENDDEFINE 

PROCEDURE movedot(oform)
WITH oform
arVector[1,1]=arVector[1,1]+arVector[1,2]
arVector[1,2]=getvector(1)
nDelta=arVector[1,2]
.Ball1.width=nBallWidth*ABS(COS(DTOR(arVector[1,1])))
.Ball1.left=(nBallWidth-.Ball1.width)/2
nCycles=IIF(.ball1.width<2,IIF(nCycles<1,nCycles+1,0),nCycles)
nDotVector=IIF(nCycles>0,-1,1)
nX1=nMajor*nC3
nY1=(.Ball1.width/2)*nS3*nDotVector &&nMinor*nS3
*CALCULATE NEW X AND Y.
nX = nXC + ( nX1 * nC1 ) - ( nY1 * nS1 )
nY = nYC + ( nX1 * nS1 ) + ( nY1 * nC1 )
*arVector[1,2]=getvector(1)
*CALCULATE NEW ANGLE FORMULAS.
nT1 = ( nC3 * nC2 ) - ( nS3 * nS2 )
nS3 = ( nS3 * nC2 ) + ( nC3 * nS2 )
nC3 = nT1
*!*	IF nDelta#arVector[1,2]
*!*	   .Ball1.fillstyle=IIF(.Ball1.fillstyle=4,5,4)
*!*	ELSE
*!*	ENDIF 
oform.adot.top=ROUND(nX,0)
oform.adot.left=round(nY,0)
ENDWITH 
ENDPROC 

PROCEDURE getvector(nPtr)
RETURN IIF(arVector[nPtr,1]>179,-1,;
       IIF(arVector[nPtr,1]<1,1,arVector[nPtr,2]))
* END PolarOrbit
Imagination is more important than knowledge
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform