3 /** Example library to demonstrate the use of Existential Types.
4 The library implements a simple set of drawing objects.
6 Create a new project. Set the Environment to "Object IO".
7 Set "Project Options" to "No Console".
16 Start :: *World -> *World
17 Start world = drawFigure figure6 world
22 , text "Hello" (movePoint {vx=(b.x-a.x)/5,vy=(b.y-a.y)/2} a)
29 [ ellips a (movePoint {vx=r,vy=r} a) \\ r <- [10,20..400]]
34 [ text (toString c) {x=r,y=r} \\ c <- ['a'..'z'] & r <- [0,25..]]
36 figure3 = mkFigures [figure0,figure1,figure2]
39 [ line c (movePoint {vx=toInt (r*(cos angle)),vy=toInt (r*(sin angle))} c)
40 \\ angle <- [0.0,2.0*PI/360.0..2.0*PI]
47 [ text (toString cc) (movePoint {vx=toInt (radius*(cos angle)),vy=toInt (radius*(sin angle))} c)
48 \\ angle <- [0.0,2.0*PI/(toReal nrchars)..2.0*PI]
55 nrchars = length chars
58 [ mkFigures [pencolour colour, text (toString cc) (movePoint {vx=toInt (radius*(cos angle)),vy=toInt (radius*(sin angle))} c)]
59 \\ angle <- [0.0,2.0*PI/(toReal nrchars)..2.0*PI]
61 & colour <- [ RGB { r = begin.r + (eind.r-begin.r)*i/nrchars
62 , g = begin.g + (eind.g-begin.g)*i/nrchars
63 , b = begin.b + (eind.b-begin.b)*i/nrchars
72 nrchars = length chars
73 begin = {r=255, g= 20, b=200}
74 eind = {r=0, g=234, b=100}
78 [ move {vx=(edges-1)*(toInt (2.0 * radius)),vy=toInt (1.5 * radius)}
79 ( mkFigures [ line {x=toInt (cos ( i *2.0*PI/(toReal edges))*radius), y=toInt (sin ( i *2.0*PI/(toReal edges))*radius)}
80 {x=toInt (cos ((i+1.0)*2.0*PI/(toReal edges))*radius), y=toInt (sin ((i+1.0)*2.0*PI/(toReal edges))*radius)}
81 \\ i <- map toReal [1..edges]