import Picture
r1, r2, r3, r4 :: Region
r1 = Shape (Rectangle 3 2)
r2 = Shape (Ellipse 1 1.5)
r3 = Shape (RtTriangle 3 2)
r4 = Shape (Polygon [(-2.5, 2.5), (-3, 0), (-1.7, -1), (-1.1, 0.2), (-1.5, 2)])
reg1, reg2 :: Region
pic1, pic2, pic3 :: Picture
reg1 = r3 `xUnion` (r1 `Intersect` Complement r2 `Union` r4)
pic1 = Region Blue reg1
reg2 = let circle = Shape (Ellipse 0.5 0.5)
square = Shape (Rectangle 1 1)
in (Scale (2,2) circle)
`Union` (Translate (1,0) square)
`Union` (Translate (-1,0) square)
pic2 = Region Yellow (Translate (0, -1) reg2)
pic3 = pic2 `Over` pic1
main1 = draw "Pic1" pic1
main2 = draw "Pic2" pic2
main3 = draw "Pic3" pic3
-----
oneCircle = Shape (Ellipse 1 1)
manyCircles = [Translate (x,0) oneCircle | x <- [0,2..]]
fiveCircles = foldr Union Empty (take 5 manyCircles)
main4 = draw "5 circles" (Region Blue $ Scale (0.3, 0.3) fiveCircles)
This entry was posted
on Sunday, June 10th, 2007 at 12:30 pm and is filed under Haskell - SOE.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.