Shape Maker
#2
Yep that was big step for me, learning to draw regular polygons with Sin and Cos. Nice job. How do you use a clipboard image?

Here's a quickie:
Code: (Select All)
_Title "Basic Polygon" 'b+ 2020-08-27

' a circle is 360 degree
' a polyon of n side has central angles 360 / n  > think of a pie the central angle are the angle of slices in center
Screen _NewImage(500, 500, 32)
_Delay .25
_ScreenMove _Middle
xC = _Width / 2 '  middle of screen
yC = _Height / 2 ' ditto
r = 200 '          radius = less than half screen height
For n = 3 To 12
    Cls
    Print "Sides = "; n
    Circle (xC, yC), r ' here is our pie,  Apple or Pepperroni :-))
    For angle = 0 To 360 Step 360 / n ' step the size of pie angles
        ' let xC, yC be the coordinates at the center of the pie circle
        ' let r be the radius of the pie
        ' then the n outside points are
        x = xC + r * Cos(_D2R(angle)) ' x coordinate of outter edge point
        y = yC + r * Sin(_D2R(angle)) ' y coordinate of outter edge point
        If angle = 0 Then PSet (x, y) Else Line -(x, y) ' outter edge edge
        Line (xC, yC)-(x, y) ' slice from center of pie
        _Limit 4
    Next
    _Delay 2
    Print "press any to see next polygon up to 12..."
    Sleep
Next
Print "Demo is done."
b = b + ...
Reply


Messages In This Thread
Shape Maker - by SierraKen - 07-11-2022, 06:29 PM
RE: Shape Maker - by bplus - 07-11-2022, 10:07 PM
RE: Shape Maker - by vince - 07-13-2022, 04:56 AM
RE: Shape Maker - by SierraKen - 07-12-2022, 12:13 AM
RE: Shape Maker - by bplus - 07-13-2022, 01:16 PM
RE: Shape Maker - by SierraKen - 07-13-2022, 07:06 PM
RE: Shape Maker - by bplus - 07-13-2022, 10:07 PM
RE: Shape Maker - by SierraKen - 07-14-2022, 02:35 AM



Users browsing this thread: 2 Guest(s)