Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
N-pointed star
#5
Awesome stuff guys! A couple days ago I found out how to make a 5 sided star. But I've also wanted to make the user be able to add as many points as they wish. I tried and tried but since I don't know a lot of math, I used Chat GPT and got this.
Macalwen, you might want to look at this code and see the explanations if you want to make pointed stars. I use this kind of math for different graphics and my clocks. But since I don't know how they actually work, I just copy the code to each thing I use. I also like experimenting with the numbers, variables, and equations. But I do like the way you did yours with the circles! Smile 

B+, as usual, I am amazed. Smile 


Code: (Select All)

'This was created using Chat GPT with a tiny bit added by SierraKen.   

Screen _NewImage(800, 600, 32) ' Set graphics mode

start:
Clear
Cls ' Clear screen

' Get user input for the number of spikes
Input "Enter the number of spikes for the star (5 or more): "; numSpikes

If numSpikes > 10000 Then
    Print "The number of spikes cannot be more than 10000, using 10000 spikes instead"
    numSpikes = 10000
End If

' Validate the input to ensure it's at least 5
If numSpikes < 5 Then
    Print "The number of spikes must be at least 5. Using 5 spikes instead."
    numSpikes = 5
End If

' Define the center of the star
cx = 400
cy = 300

'Define Pi
Pi = _Pi

' Define the size of the star
size = 200

' Calculate the angle between each point
angleStep = 360 / numSpikes

' Initialize an array to store the points of the star
Dim pointsX(numSpikes)
Dim pointsY(numSpikes)

' Loop to calculate the coordinates of each point
For i = 0 To numSpikes - 1
    angle = i * angleStep
    pointsX(i) = cx + size * Cos(angle * Pi / 180)
    pointsY(i) = cy - size * Sin(angle * Pi / 180)
Next

' Draw the lines connecting the points to form the star
For i = 0 To numSpikes - 1
    ' Connect the current point to the next one, wrapping around at the end
    Line (pointsX(i), pointsY(i))-(pointsX((i + 2) Mod numSpikes), pointsY((i + 2) Mod numSpikes)), _RGB32(255, 255, 255)
Next

Locate 35, 5: Input "Again (Y/N): ", ag$
If Left$(ag$, 1) = "y" Or Left$(ag$, 1) = "Y" Then GoTo start:

End
Reply


Messages In This Thread
N-pointed star - by macalwen - 12-09-2024, 05:12 AM
RE: N-pointed star - by macalwen - 12-09-2024, 05:18 AM
RE: N-pointed star - by bplus - 12-09-2024, 12:26 PM
RE: N-pointed star - by bplus - 12-09-2024, 02:09 PM
RE: N-pointed star - by SierraKen - 12-09-2024, 09:44 PM
RE: N-pointed star - by James D Jarvis - 12-09-2024, 10:01 PM
RE: N-pointed star - by NakedApe - 12-10-2024, 12:26 AM
RE: N-pointed star - by macalwen - 12-10-2024, 10:57 AM



Users browsing this thread: 1 Guest(s)