// Draw various geometric shapes

graph landscape, hscale=15, vscale=15
// make hscale and vscale the same for correct aspect
degrees

// Draw a circle
plot color=(255,0,0),unsorted
rc = fndraw_circle (80,80,20,20)

// draw a square
plot color=(0,200,0), unsorted
rc = fndraw_rectangle (80,30, 40, 40)

// Draw an ellipse inside the square
plot color=(255,0,0),unsorted
rc = fndraw_circle (80,30,20,10)

// draw a rectangle inside the square
plot color=(0,0,255),unsorted
rc = fndraw_rectangle (80, 30, 20, 40)

// draw a right triangle
plot color=(0,0,255), unsorted
h=30: v=80
plot x=h-20, y=v-20
plot x=h-20, y=v+20
plot x=h+20, y=v-20
plot x=h-20, y=v-20

// Draw polygons
plot color=(180,180,0),unsorted
rc = fndraw_polygon (30, 30, 20, 7)
plot color=(180,0,0),unsorted
rc = fndraw_polygon (30, 30, 10, 7)

// draw a star inside the circle
plot color=(0,180,180),unsorted
rc = fndraw_star (80,80,20)

// Draw some more boxes
plot color=(0,180,180),unsorted
rc = fndraw_rectangle (130, 55, 10,80)
for i = 20 to 90 step 10
  plot color=(255,0,0), unsorted
  nrc = fndraw_rectangle (130, i, 15, 2.5)
next
end

//--------------------------------------
def fndraw_circle (h, v, rh, rv) = gosub 10000
10000
//plot red=r,green=g,blue=b,unsorted
for ang=0 to 360 step 5
  plot x=h+rh*cos(ang), y=v+rv*sin(ang)
next
return
// ------------------------------------
def fndraw_polygon (h, v, r, sides)=gosub 10010
10010
for a=0 to 361 step 360/sides
  plot x=h+r*cos(a), y=v+r*sin(a)
next
return
// ------------------------------------
def fndraw_rectangle (h, v, width, height)=gosub 10020
10020
plot x=h-width/2, y=v-height/2
plot x=h-width/2, y=v+height/2
plot x=h+width/2, y=v+height/2
plot x=h+width/2, y=v-height/2
plot x=h-width/2, y=v-height/2
return
// ------------------------------------
def fndraw_star (h, v, r)=gosub 10030
10030
for ang=18 to 1099 step 144
  plot x=h+r*cos(ang), y=v+r*sin(ang)
next
return
// ------------------------------------

