peter
17-10-2012, 21:23
Hi,
You remember the old days at school? (trigonometry)
Uses "ui","math"
DWord hdc,hwin
hwin=Canvas_Window("Sinus Wave",1,1,640,240)
Canvas_Attach(hwin,0,%TRUE)
Canvas_Font("comic",16,%CANVAS_FONTSTYLE_BOLD)
Long i,width
Single px,py,px2,py2,angle,angle2,radius,frequency,frequency2,x,x2
radius=100
frequency=2
frequency2=2
width=640
While IsWindow(hwin)
Canvas_Clear(&h808080)
Canvas_Circle(width/8,75,radius/2,&hFFFFFF)
px= width/8 + Cos(DegToRad(angle))*(radius/2)
py= 75+Sin(DegToRad(angle))*(radius/2)
Canvas_Circle(px,py,6,&h00FF00)
Canvas_Line( (width/8,75),(px,py),0)
angle2=0
For i=0 To width
px2= width/8 + Cos(DegToRad(angle2))*(radius/2)
py2= 75 + Sin(DegToRad(angle2))*(radius/2)
Canvas_Color(0)
Canvas_SetPixel(width/8+radius/2+i,py2)
angle2 -= frequency2
Next
Canvas_Circle(width/8+radius/2+x,py,0)
angle -= frequency
x +=1
If x>= width-60 Then
x=0
angle=0
End If
Canvas_Line( (px,py),(width/8+radius/2+x,py),0)
SetText(0, 185,"y = sin x",&hFFFFFF,&h808080)
SetText(200,185,"px= " + px,&hFFFFFF,&h808080)
SetText(420,185,"py= " + py,&hFFFFFF,&h808080)
Canvas_Redraw
If GetAsyncKeyState(27) Then Exit While
sleep 10
Wend
Canvas_Window End
Sub SetText(x,y As Long, txt As String, xkol,ykol As Long)
Canvas_Color(xkol,ykol)
Canvas_SetPos(x,y)
Canvas_Print(txt)
End Sub
You remember the old days at school? (trigonometry)
Uses "ui","math"
DWord hdc,hwin
hwin=Canvas_Window("Sinus Wave",1,1,640,240)
Canvas_Attach(hwin,0,%TRUE)
Canvas_Font("comic",16,%CANVAS_FONTSTYLE_BOLD)
Long i,width
Single px,py,px2,py2,angle,angle2,radius,frequency,frequency2,x,x2
radius=100
frequency=2
frequency2=2
width=640
While IsWindow(hwin)
Canvas_Clear(&h808080)
Canvas_Circle(width/8,75,radius/2,&hFFFFFF)
px= width/8 + Cos(DegToRad(angle))*(radius/2)
py= 75+Sin(DegToRad(angle))*(radius/2)
Canvas_Circle(px,py,6,&h00FF00)
Canvas_Line( (width/8,75),(px,py),0)
angle2=0
For i=0 To width
px2= width/8 + Cos(DegToRad(angle2))*(radius/2)
py2= 75 + Sin(DegToRad(angle2))*(radius/2)
Canvas_Color(0)
Canvas_SetPixel(width/8+radius/2+i,py2)
angle2 -= frequency2
Next
Canvas_Circle(width/8+radius/2+x,py,0)
angle -= frequency
x +=1
If x>= width-60 Then
x=0
angle=0
End If
Canvas_Line( (px,py),(width/8+radius/2+x,py),0)
SetText(0, 185,"y = sin x",&hFFFFFF,&h808080)
SetText(200,185,"px= " + px,&hFFFFFF,&h808080)
SetText(420,185,"py= " + py,&hFFFFFF,&h808080)
Canvas_Redraw
If GetAsyncKeyState(27) Then Exit While
sleep 10
Wend
Canvas_Window End
Sub SetText(x,y As Long, txt As String, xkol,ykol As Long)
Canvas_Color(xkol,ykol)
Canvas_SetPos(x,y)
Canvas_Print(txt)
End Sub