peter
02-04-2014, 14:33
Hello,
Nice butterflies. (carpenter moth)
Uses "ui","math"
#INCLUDE "abc.inc"
OpenWindow 800,800
SetHandleDC hdc, hwnd
Canvas_Clear 0
Canvas_Redraw
Dim scale,ofs,flag,sp1,sd1,cm1,yy,xx,x,y,oldx,oldy As Single
Dim theta,cv1,r,a As Single
scale=80:ofs=400:flag=0:a=100*Pi
While IsWindow(hwnd) And Key(27)=0
DrawString 20,20,"Press any key for alternative image",&HFFFFFF
If flag=0 Then
cv1=2:cm1=4:sp1=5:sd1=12
End If
If flag=1 Then
cv1=2.1:sp1=7:sd1=30:cm1=6
End If
For theta=0 To a Step 0.010
r=Exp(Cos(theta)) - cv1*Cos(cm1*theta)+(Sin(theta/sd1))^sp1
x=r*Cos(theta)
y=r*Sin(theta)
yy=(x*scale)+ofs
xx=(y*scale)+ofs
If theta=0 Then
oldx=xx
oldy=yy
End If
If theta <>0 Then
DrawLine oldx,oldy,xx,yy,1,Rgb(Rnd(32,255),Rnd(32,255),Rnd(32,255)) '%ABC_WHITE
oldx=xx
oldy=yy
End If
Next
Canvas_Redraw
Canvas_WaitKey
Canvas_Clear 0
' Sleep(25)
flag = flag XOR 1
Wend
Canvas_Window End
Nice butterflies. (carpenter moth)
Uses "ui","math"
#INCLUDE "abc.inc"
OpenWindow 800,800
SetHandleDC hdc, hwnd
Canvas_Clear 0
Canvas_Redraw
Dim scale,ofs,flag,sp1,sd1,cm1,yy,xx,x,y,oldx,oldy As Single
Dim theta,cv1,r,a As Single
scale=80:ofs=400:flag=0:a=100*Pi
While IsWindow(hwnd) And Key(27)=0
DrawString 20,20,"Press any key for alternative image",&HFFFFFF
If flag=0 Then
cv1=2:cm1=4:sp1=5:sd1=12
End If
If flag=1 Then
cv1=2.1:sp1=7:sd1=30:cm1=6
End If
For theta=0 To a Step 0.010
r=Exp(Cos(theta)) - cv1*Cos(cm1*theta)+(Sin(theta/sd1))^sp1
x=r*Cos(theta)
y=r*Sin(theta)
yy=(x*scale)+ofs
xx=(y*scale)+ofs
If theta=0 Then
oldx=xx
oldy=yy
End If
If theta <>0 Then
DrawLine oldx,oldy,xx,yy,1,Rgb(Rnd(32,255),Rnd(32,255),Rnd(32,255)) '%ABC_WHITE
oldx=xx
oldy=yy
End If
Next
Canvas_Redraw
Canvas_WaitKey
Canvas_Clear 0
' Sleep(25)
flag = flag XOR 1
Wend
Canvas_Window End