%begin
   %include "level1:graphinc.imp"
   %include ":l:b:inc:maths.imp"

   %const %real pib3 = pi/3,
                pib4 = pi/4

   %routine pole(%integer x, y, %real r)
      %integer i, xl, xr, yb, yt
      %real cr, sr
      %const %integer %array x0(1:11) = 0, 0, -5, -5, -2, -2, -2,
                                              -5, 5, -5, 5
      %const %integer %array y0(1:11) = 0, 300, 320, 340, 280, 300, 360,
                                              318, 318, 338, 338
      %const %integer %array x1(1:11) = 0, 0, 5, 5, 2, 2, 2, -5, 5, -5, 5
      %const %integer %array y1(1:11) = 280, 360, 320, 340, 280, 300, 360,
                                              322, 322, 342, 342
      cr = cos(r)
      sr = sin(r)
      %for i = 1, 1, 11 %cycle
         xl = x+int pt(x0(i)*cr-y0(i)*sr)
         yb = y+int pt(x0(i)*sr+y0(i)*cr)
         xr = x+int pt(x1(i)*cr-y1(i)*sr)
         yt = y+int pt(x1(i)*sr+y1(i)*cr)
         poly(xl-1, yb)
         poly(xr-1, yt)
         poly(xr, yt+1)
         poly(xr+1, yt)
         poly(xl+1, yb)
         poly(xl, yb-1)
         close poly
      %repeat
   %end

   %routine flash (%integer x, y, %real cr, sr)
      %integer i
      %const %integer %array xp(1:7) = -7, 7, 7, 22, 0, -22, -7
      %const %integer %array yp(1:7) = 180, 180, 60, 60, 25, 60, 60

      poly(x+int pt(xp(i)*cr-yp(i)*sr),
           y+int pt(xp(i)*sr+yp(i)*cr)) %for i = 1, 1, 7
      close poly
   %end

   %routine sparkle(%integer x, y, size)
      %integer i
      %real r, s

      s = size/400
      %for i = 1, 1, 6 %cycle
         r = i*pib3+pib4
         flash(x, y, s*cos(r), s*sin(r))
      %repeat
   %end

   %routine tri(%integer x, y)

      poly(x-26, y+26)
      poly(x, y)
      poly(x+26, y+26)
   close poly
   %end

   %routine rain(%integer x, y, l, w)

      w = (w+1)//2
      poly(x-w+1, y-w+1)
      poly(x-l-w+1, y+l-w+1)
      poly(x-l+w, y+l+w)
      poly(x+w, y+w)
      close poly
   %end

   %integer z = 0
   %integer i, j

   Printstring("Clear");newline
   clear
   Printstring("Zap colour map");newline
   colour map(i) = z %for i = 0, 1, 255
   Printstring("White");newline
   colour(white)
   printstring("Fill");newline
   fill(44, 0, 643, 511)
   printstring("Colour");newline
   colour(black)
   printstring("poly");newline
   poly(134, 430)
   poly(181, 383)
   poly(181, 176)
   poly(344, 90)
   poly(507, 176)
   poly(507, 383)
   poly(554, 430)
   printstring("Close poly");newline
   close poly
   printstring("Colour");newline
   colour(white)
   poly(191, 383)
   poly(191, 285)
   poly(337, 285)
   poly(337, 383)
   poly(304, 416)
   poly(264, 376)
   poly(224, 416)
   printstring("Close poly");newline
   close poly
   poly(497, 275)
   poly(497, 180)
   poly(351, 106)
   poly(351, 275)
   close poly
   colour(red)
   printstring("colour");newline
   poly(497, 383)
   poly(497, 285)
   poly(351, 285)
   poly(351, 383)
   poly(384, 416)
   poly(424, 376)
   poly(464, 416)
   close poly
   poly(191, 275)
   poly(191, 180)
   poly(337, 106)
   poly(337, 275)
   close poly
   colour(blue)
   printstring("Triangle");newline
   tri(186, 394)
   tri(264, 394)
   tri(344, 394)
   tri(424, 394)
   tri(502, 394)
   printstring("colour");newline
   colour(magenta)
   poly(431, 264)
   poly(419, 252)
   poly(414, 240)
   poly(414, 225)
   poly(419, 205)
   poly(422, 190)
   poly(419, 180)
   poly(409, 170)
   poly(413, 158)
   poly(426, 170)
   poly(431, 180)
   poly(433, 195)
   poly(431, 210)
   poly(427, 220)
   poly(424, 228)
   poly(424, 238)
   poly(429, 247)
   poly(434, 252)
   close poly
   colour(red)
   fill(366, 201, 376, 221)
   fill(377, 206, 395, 216)
   fill(389, 235, 409, 245)
   fill(389, 180, 409, 190)
   fill(394, 181, 404, 234)
   fill(439, 235, 459, 245)
   fill(439, 180, 459, 190)
   fill(444, 181, 454, 234)
   fill(472, 201, 482, 221)
   fill(455, 206, 471, 216)
   poly(405, 225)
   poly(405, 215)
   poly(424, 196)
   poly(443, 215)
   poly(443, 225)
   poly(424, 206)
   close poly
   colour(white)
   disc(376, 201, 4)
   disc(376, 221, 4)
   disc(389, 235, 4)
   disc(409, 235, 4)
   disc(389, 190, 4)
   disc(409, 190, 4)
   disc(439, 235, 4)
   disc(459, 235, 4)
   disc(439, 190, 4)
   disc(459, 190, 4)
   disc(472, 201, 4)
   disc(472, 221, 4)
   colour(black)
   poly(79, 330)
   poly(109, 250)
   poly(159, 320)
   poly(139, 370)
   close poly
   poly(609, 330)
   poly(579, 250)
   poly(529, 320)
   poly(549, 370)
   close poly
   colour(yellow)
   poly(89, 325)
   poly(111, 265)
   poly(149, 320)
   poly(136, 359)
   close poly
   poly(599, 325)
   poly(577, 265)
   poly(539, 320)
   poly(552, 359)
   close poly
   colour(black)
   poly(124, 345)
   poly(146, 302)
   poly(159, 320)
   poly(139, 370)
   close poly
   poly(564, 345)
   poly(542, 302)
   poly(529, 320)
   poly(549, 370)
   close poly
   colour(yellow)
   poly(132, 345)
   poly(146, 314)
   poly(151, 321)
   poly(138, 355)
   close poly
   poly(556, 345)
   poly(542, 314)
   poly(537, 321)
   poly(550, 355)
   close poly
   colour(black)
   pole(189, 120,0.3)
   pole(184, 90, 0.34)
   pole(499, 120, -0.3)
   pole(504, 90, -0.34)
   colour(black)
   poly(79, 330)
   poly(109, 250)
   poly(169, 225)
   poly(169, 305)
   close poly
   poly(609, 330)
   poly(579, 250)
   poly(519, 225)
   poly(519, 305)
   close poly
   colour(yellow)
   poly(92, 318)
   poly(115, 256)
   poly(161, 237)
   poly(161, 299)
   close poly
   poly(596, 318)
   poly(573, 256)
   poly(527, 237)
   poly(527, 299)
   close poly
   colour(red)
   sparkle(224, 357, 48)
   colour(black)
   sparkle(244, 316, 48)
   sparkle(294, 347, 48)
   rain(208, 296, 10, 1)
   rain(228, 296, 30, 1)
   rain(224, 320, 20, 1)
   rain(204, 356, 5, 1)
   rain(204, 377, 5, 1)
   rain(222, 378, 10, 1)
   rain(269, 330, 25, 1)
   rain(265, 294, 4, 1)
   rain(282, 296, 17, 1)
   rain(279, 319, 5, 1)
   rain(305, 293, 20, 1)
   rain(237, 383, 20, 1)
   rain(252, 368, 10, 1)
   rain(272, 348, 15, 1)
   rain(324, 295, 28, 1)
   rain(276, 365, 5, 1)
   rain(328, 312, 15, 1)
   rain(291, 369, 10, 1)
   rain(328, 332, 12, 1)
   rain(299, 380, 9, 1)
   rain(326, 353, 23, 1)
   rain(328, 373, 27, 1)
   colour map(white) = 16_7FFF
   colour map(red) = 16<<5+31
   colour map(blue) = 31<<10
   colour map(magenta) = 15<<10
   colour map(yellow) = 7<<10+21<<5+23
%end %of %program
