{- Function Programming Final Project Quadtree Representation Peng Ling Apr 28, 2001 Supporting module /home/classes/cs429/class/ling.peng.pl68/project/RenderPolygon.hs -} module RenderPolygon (renderPoly) where import qualified SOEGraphics as G -- int pixels type Point = (Int, Int) type Polygon = [Point] type Polygons = [Polygon] -- draw one polygon drawPoly :: Polygons -> G.Window -> [G.Color] -> IO() drawPoly [] w (c : _) = return () --G.drawInWindow w (G.withColor c (G.polygon [])) drawPoly (t : ts) w (c : cs) = do G.drawInWindow w (G.withColor c (G.polygon t)) drawPoly ts w cs -- color stream colors = tail (map fst G.colorList) ++ colors -- top level function renderPoly :: Polygons -> IO() renderPoly p = -- G.runGraphics $ do w <- G.openWindow "Polygons" (300, 300) drawPoly p w colors -- test cases poly1 :: Polygon poly1 = [(1, 3), (40, 3), (20, 30)] poly2 :: Polygon poly2 = [(30, 30), (100, 30), (80, 130), (1, 60), (50, 80)] poly :: Polygons poly = [poly1, poly2]