Hi,

This is a traditional mathematical circle pattern called Mystic Rose… google it for more info, but essentially it is a circle with points marked equidistant around the circumference, and lines drawn between every point.

My approach was to work out the coordinates of the points, put them in a table and then read out the values to plot the lines. The loop increments to prevent duplicating lines.

To see how this works, un-comment the print instruction just before the end and set the points down to 4. this should just draw 6 lines. The numbers are the table key values so 1 2 3 4 indicates a line drawn from (c[1], c[2]) to (c[3], c[4]).

I’d be grateful to hear any feedback. Initially I was iterating angles and getting some very strange results which iterating points solved. And somehow I wonder if I should be using iPairs for coordinates, but would need help as to how to do this, and would it be more efficient anyway?

Many thanks,

David

```
-- Mystic Rose v3.1 by David Cockram
-- Use this function to perform your initial setup
function setup()
print("Hello World!")
parameter.integer ("points", 2,40,20)
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
-- This sets the line thickness
strokeWidth(2)
-- Do your drawing here
fill(31, 103, 38, 132)
ellipse(380, 370, 704)
a = 380 -- circle centre (a,b) radius r
b = 370
r = 350
angle = 360/points -- angle to increment
w = points*2 -- number of coordinates
c = {} -- table of coords {x1, y1, x2, y2 ... etc}
-- this part works out the coordinates, based on the number of points
for i = 0, points-1 do
t = i*angle
-- put coordinate pairs in a table, c
c[2*i+1] = a + r*math.sin(math.rad(t)) -- x coordinate
c[2*i+2] = b + r*math.cos(math.rad(t)) -- y coordinate
end
-- draw lines. The start value h+2 increments each loop to prevent repeating lines
for h = 1, w-3, 2 do
for i = h+2, w-1, 2 do
line(c[h], c[h+1], c[i], c[i+1])
-- print(h, h+1, i, i+1) -- line drawing key table values to check
end
end
end
```