Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Graphical Stopwatch showing Time Elapsed
Message
From
03/02/2004 11:27:16
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
03/02/2004 11:16:47
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00873094
Message ID:
00873433
Views:
24
>>The regular sin() and Cos() functions expect angle measured in radians, in positive direction (clockwise is negative), starting off x-axis. So I had to recalculate the angle - 15 seconds is a right angle (we're starting the stopwatch off y-axis, not x), and 30 seconds is a 180 degree angle, which we need to scale with Pi. So, 15-nSecs is our angle in seconds; divided by 30 it gives us the same angle divided by 180; multiplying this with Pi gives us actual angle in Cartesian coordinates, expressed in radians.
>>
>>The additional complication is that our on-screen coordinates have a negative direction of the y-axis (zero on top, positive numbers below)... made this a little more fun to do :).
>
>Ok, I'm with you on that, but I get an error on this line
>
>
>.HEIGHT=-SIN(lnAngle)* Radius
>
>
>because it evaluates to a negative number. lnAngle is 1.256637 and Radius = 100. Am I missing something else?

Shouldn't happen - I have a form where this works. Just in case, I may have missed something when I pasted the code. Here's a re-paste of the code which works.
** DrawHand custom method of the form
Lparameters nSecs

lnAngle=(15-nSecs)/30*Pi()
x0=Thisform.Width/2
y0=Thisform.Height/2
R=y0*.8

x1=x0+Cos(lnAngle)*R
y1=y0-Sin(lnAngle)*R
With Thisform.line1
	Do Case
		Case x0<=x1 And y0>=y1
			.Left=x0
			.Width=Cos(lnAngle)*R
			.Top=y1
			.Height=Sin(lnAngle)*R
			.LineSlant="/"
		Case x0<=x1 And y0<y1
			.Left=x0
			.Width=Cos(lnAngle)*R
			.Top=y0
			.Height=-Sin(lnAngle)*R
			.LineSlant="\"
		Case x0>x1 And y0>=y1
			.Left=x1
			.Width=-Cos(lnAngle)*R
			.Top=y1
			.Height=Sin(lnAngle)*R
			.LineSlant="\"
		Case x0>x1 And y0<y1
			.Left=x1
			.Width=-Cos(lnAngle)*R
			.Top=y0
			.Height=-Sin(lnAngle)*R
			.LineSlant="/"
	Endcase

Endwith
You can set your own values for x0, y0 and R, of course.
I can't catch what was wrong with the first version of code, could be a minus I didn't notice somewhere.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform