Code archives/Miscellaneous/Shapes with points moving on a straight line
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Points moving on straight lines spread at a constant angle produce a nice visual effect. | |||||
Graphics 800,600 Local lines:Float = 20 Local radius:Int = 250 Type TLine Global list:TList = CreateList() Field lineAngle:Float Field pointAngle:Float End Type For Local i:Int = 0 To lines-1 Local line:TLine = New TLine line.lineAngle = 180/lines*i line.pointAngle = 180/lines*i ListAddLast TLine.list,line Next While Not KeyHit(KEY_ESCAPE) And Not AppTerminate() Cls SetColor 50,50,50 For line = EachIn TLine.list DrawLine GraphicsWidth()/2-Cos(line.lineAngle)*radius,GraphicsHeight()/2-Sin(line.lineAngle)*radius,GraphicsWidth()/2+Cos(line.lineAngle)*radius,GraphicsHeight()/2+Sin(line.lineAngle)*radius Next SetColor 255,255,255 For line = EachIn TLine.list line.pointAngle = line.pointAngle + 1 If line.pointAngle > 360 Then line.pointAngle = line.pointAngle - 360 Local x:Float = GraphicsWidth()/2 + Cos(line.lineAngle)*radius*Sin(line.pointAngle) Local y:Float = GraphicsHeight()/2 + Sin(line.lineAngle)*radius*Sin(line.pointAngle) DrawOval x-5,y-5,11,11 Next Flip Wend End |
Comments
None.
Code Archives Forum