%begin
%include "inc:maths.imp"
%include "mach:extl1.imp"
%record %format point fm(%integer x, y)
%record %format trap fm(%integer x0, x1, y)
%record(point fm) a, b, c, aa, bb, cc
%record(trap fm) d, dd
%integer i, j, col, cols
%integer %array x, y(1:128)
%constant %integer step = 25, n = 5, k = 8, in = 1, out = 3

  %for i = 2, 2, n*2 %cycle
     x(i-1) = 343+intpt(sin(pi*(i-1)/n)*k)
     y(i-1) = 475+intpt(cos(pi*(i-1)/n)*k)
     x(i) = 343+intpt(sin(pi*i/n)*out*k/in)
     y(i) = 475+intpt(cos(pi*i/n)*out*k/in)
  %repeat
  clear
  a_x = 343; a_y = 500
  %for i = 2, 1, 7 %cycle
     a_y = a_y-step*3//2
     b_y = a_y-i*step
     c_y = b_y
     b_x = a_x-i*step
     c_x = a_x+i*step
     colour(green)
     triangle(a_x, a_y, b_x, b_y, c_x, c_y)
     colour(red)
     fill(b_x, b_y, b_x+step//4, b_y+step)
     fill(c_x-step//4, c_y, c_x, c_y+step)
     colour(yellow)
     aa_y = b_y+step*7//4
     bb_y = b_y+step*5//4
     cc_y = bb_y
     aa_x = b_x+step//8
     bb_x = b_x-step//8
     cc_x = b_x+step*3//8
     disc(aa_x, bb_y, step//4)
     triangle(aa_x, aa_y, bb_x, bb_y, cc_x, cc_y)
     aa_x = c_x-step//8
     bb_x = c_x-step*3//8
     cc_x = c_x+step//8
     disc(aa_x, bb_y, step//4)
     triangle(aa_x, aa_y, bb_x, bb_y, cc_x, cc_y)
  %repeat
  colour(red)
  fill(a_x-step//3, b_y, a_x+step//3, b_y-step)
  fill(a_x-step//3, b_y, a_x+step//3, b_y-step)
  colour(blue)
  d_x0 = a_x-step*2
  d_x1 = a_x+step*2
  d_y = b_y-step*4
  dd_x0 = d_x0-step//2
  dd_x1 = d_x1+step//2
  dd_y = b_y-step
  trapeze(d_x0, d_x1, d_y, dd_x0, dd_x1, dd_y)
  col = yellow
  cols = yellow
  %cycle
     colour(cols)
     %if cols=yellow %start
        cols = magenta
     %finish %else %if cols=magenta %start
        cols = cyan
     %else
        cols = yellow
     %finish
     poly(x(j), y(j)) %for j = 1, 1, 2*n
     close poly
     col = col!!2
     a_y = 500
     %for i = 2, 1, 7 %cycle
        a_y = a_y-step*3//2
        b_y = a_y-i*step
        c_y = b_y
        b_x = a_x-i*step
        c_x = a_x+i*step
        colour(col)
        aa_y = b_y+step*7//4
        bb_y = b_y+step*5//4
        cc_y = bb_y
        aa_x = b_x+step//8
        bb_x = b_x-step//8
        cc_x = b_x+step*3//8
        disc(aa_x, bb_y, step//4)
        triangle(aa_x, aa_y, bb_x, bb_y, cc_x, cc_y)
        aa_x = c_x-step//8
        bb_x = c_x-step*3//8
        cc_x = c_x+step//8
        disc(aa_x, bb_y, step//4)
        triangle(aa_x, aa_y, bb_x, bb_y, cc_x, cc_y)
     %repeat
  %repeat

%end %of %program
