Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shape Maker
#1
Now that I'm learning degrees, I decided to make a shape maker today. You type in how many sides you want, from 3 to 100 and what basic color (15 to choose from) you want and if you want it filled-in or not. Then it makes the shape. It makes it with a white background so you can press C to copy it to the clipboard and paste it to your favorite graphics program.


[Image: Shape-Maker-by-Sierra-Ken.jpg]

 

Code: (Select All)
Dim img As Long
Dim cl As Long
Screen _NewImage(800, 600, 32)
start:
_Title "Shape Maker by SierraKen"
x = 400
y = 300
fill = 0
Cls
again:
Print: Print: Print
Input "Number Of Sides (3-100): ", sides
If sides > 100 Then Print "Too many, type between 3 to 100.": GoTo again:
If sides < 3 Then Print "Too few, type between 3 to 100.": GoTo again:
again2:
Print
Print "(1) Red"
Print "(2) Green"
Print "(3) Blue"
Print "(4) Purple"
Print "(5) Pink"
Print "(6) Orange"
Print "(7) Brown"
Print "(8) Gray"
Print "(9) Black"
Print "(10) Yellow"
Print "(11) Sky Blue"
Print "(12) Tan"
Print "(13) Light Green"
Print "(14) Light Red"
Print "(15) Dark Yellow"
Print
Input "Type color here (1-15): ", c
If c < 1 Or c > 15 Or Int(c) <> c Then Print "Type 1-15 only, without decimals.": GoTo again2:
If c = 1 Then cl = _RGB32(255, 0, 0)
If c = 2 Then cl = _RGB32(0, 255, 0)
If c = 3 Then cl = _RGB32(0, 0, 255)
If c = 4 Then cl = _RGB32(188, 0, 255)
If c = 5 Then cl = _RGB32(255, 0, 255)
If c = 6 Then cl = _RGB32(255, 122, 0)
If c = 7 Then cl = _RGB32(183, 83, 0)
If c = 8 Then cl = _RGB32(127, 127, 127)
If c = 9 Then cl = _RGB32(0, 0, 0)
If c = 10 Then cl = _RGB32(255, 255, 0)
If c = 11 Then cl = _RGB32(0, 255, 255)
If c = 12 Then cl = _RGB32(222, 150, 127)
If c = 13 Then cl = _RGB32(89, 255, 0)
If c = 14 Then cl = _RGB32(255, 0, 83)
If c = 15 Then cl = _RGB32(255, 188, 67)
Print
Input "Do you wish to have the shape filled in (Y/N)"; yn$
If Left$(yn$, 1) = "y" Or Left$(yn$, 1) = "Y" Then fill = 1
Cls
_Title "Shape Maker - C copies to clipboard, Space Bar starts over, Esc quits"
Paint (0, 0), _RGB32(255, 255, 255)
st = 360 / sides
For deg = 0 To 360 Step st
    deg2 = 90 + deg
    'Plot 300 points with equations.
    oldx = x
    oldy = y
    For t = 1 To 800 / sides Step .25
        x = (Sin(_D2R(deg2)) * t) + oldx
        y = (Cos(_D2R(deg2)) * t) + oldy
        Circle (x - 400 / sides, y), 1, cl
    Next t
Next deg
If fill = 1 Then Paint (400, 250), cl

Do
    a$ = InKey$
    If a$ = Chr$(27) Then End
    If a$ = " " Then GoTo start:
    If a$ = "c" Or a$ = "C" Then
        If img <> 0 Then _FreeImage (img&)
        img& = _CopyImage(0)
        _ClipboardImage = img&
        Locate 1, 1: Print "Image Copied To Clipboard."
    End If
Loop
Reply
#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
#3
Wow thanks B+! Your demo is cool too, I think you even showed it to me years ago. I really don't use the clipboard image but I tossed it on there so people can paste it to any graphics program and change it, resize it, add to it, etc. and save it. I did test it a few times and it works good.
Reply
#4
(07-11-2022, 10:07 PM)bplus Wrote: 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

B+ mod time

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)
xC = _Width / 2 '  middle of screen
yC = _Height / 2 ' ditto
r = 200 '          radius = less than half screen height
For n = 5 To 12
for m = 1 to 4
    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(m*_D2R(angle)) ' x coordinate of outter edge point
        y = yC + r * Sin(m*_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
    Next
    Print "press any to see next polygon up to 12..."
    Sleep
next
Next
Print "Demo is done."
Reply
#5
Yeah find the prime numbers by looking at polygons m = 1 to SQR(n), you see a simpler one than m = 1 like a straight line, a triangle a square, then n is not prime.
b = b + ...
Reply
#6
Simple and incredible Vince. Smile
Reply
#7
We should show everything, number of sides and multiplier. Have to go to 720 degrees because some drawings aren't completing.
Code: (Select All)
_Title "Basic Polygon with Multiplier Mod" 'b+ 2022-07-13

' 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)
_ScreenMove 350, 100
xC = _Width / 2 '  middle of screen
yC = _Height / 2 ' ditto
r = 200 '          radius = less than half screen height
For n = 5 To 32
    For m = 1 To n - 1
        Cls
        Print "Sides ="; n; " Multiplier ="; m
        Circle (xC, yC), r ' here is our pie,  Apple or Pepperroni :-))
        For angle = 0 To 720 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(m * _D2R(angle) - _Pi / 2) ' x coordinate of outter edge point
            y = yC + r * Sin(m * _D2R(angle) - _Pi / 2) ' 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
        Next
        Print "press any to see next ..."
        Sleep
    Next
Next
Print "Demo is done."

   
b = b + ...
Reply
#8
B+, thanks so much for that code, I just made a mod of snowflakes falling down. I'll put it in a different thread and put credit to you.
Reply




Users browsing this thread: 1 Guest(s)