Add layered drawing of pictures
This commit is contained in:
+23
-7
@@ -40,6 +40,7 @@ module Picture
|
||||
, mixColors
|
||||
, zeroZ
|
||||
, setDepth
|
||||
, setLayer
|
||||
)
|
||||
where
|
||||
import Geometry
|
||||
@@ -69,11 +70,11 @@ black = (0,0,0,1)
|
||||
|
||||
polygon :: [Point2] -> Picture
|
||||
{-# INLINE polygon #-}
|
||||
polygon = Polygon
|
||||
polygon = Polygon 0
|
||||
|
||||
polygonCol :: [(Point2,RGBA)] -> Picture
|
||||
{-# INLINE polygonCol #-}
|
||||
polygonCol = PolygonCol
|
||||
polygonCol = PolygonCol 0
|
||||
|
||||
--polygon :: [Point2] -> Picture
|
||||
--{-# INLINE polygon #-}
|
||||
@@ -101,6 +102,21 @@ setDepth :: Float -> Picture -> Picture
|
||||
{-# INLINE setDepth #-}
|
||||
setDepth d pic = SetDepth d pic
|
||||
|
||||
setLayer :: Int -> Picture -> Picture
|
||||
setLayer _ Blank = Blank
|
||||
setLayer i (Polygon _ ps) = Polygon i ps
|
||||
setLayer i (PolygonCol _ ps) = PolygonCol i ps
|
||||
setLayer i (Circle _ x) = Circle i x
|
||||
setLayer i (ThickArc _ a b r w) = ThickArc i a b r w
|
||||
setLayer i (Line _ x) = Line i x
|
||||
setLayer i (Scale x y p) = Scale x y $ setLayer i p
|
||||
setLayer i (Translate x y p) = Translate x y $ setLayer i p
|
||||
setLayer i (Rotate x p) = Rotate x $ setLayer i p
|
||||
setLayer i (SetDepth x p) = SetDepth x $ setLayer i p
|
||||
setLayer i (Color x p) = Color x $ setLayer i p
|
||||
setLayer i (Pictures p) = Pictures $ map (setLayer i) p
|
||||
|
||||
|
||||
scale3 :: Float -> Float -> Point3 -> Point3
|
||||
{-# INLINE scale3 #-}
|
||||
scale3 a b (x,y,z) = (x*a,y*b,z)
|
||||
@@ -134,19 +150,19 @@ makeArc rad (a,b) = zipWith rotateV as $ repeat (0,rad)
|
||||
circleSolid :: Float -> Picture
|
||||
{-# INLINE circleSolid #-}
|
||||
--circleSolid rad = polygon $ makeArc rad (0,2*pi)
|
||||
circleSolid = Circle
|
||||
circleSolid = Circle 0
|
||||
|
||||
circle :: Float -> Picture
|
||||
{-# INLINE circle #-}
|
||||
circle rad = line $ makeArc rad (0,2*pi)
|
||||
circle rad = thickArc 0 (2*pi) rad 1
|
||||
|
||||
text :: String -> Picture
|
||||
{-# INLINE text #-}
|
||||
text = Text
|
||||
text = Text 2
|
||||
|
||||
line :: [Point2] -> Picture
|
||||
{-# INLINE line #-}
|
||||
line = Line
|
||||
line = Line 0
|
||||
|
||||
thickLine :: [Point2] -> Float -> Picture
|
||||
{-# INLINE thickLine #-}
|
||||
@@ -173,7 +189,7 @@ arc startA endA rad = thickArc startA endA rad 1
|
||||
|
||||
thickArc :: Float -> Float -> Float -> Float -> Picture
|
||||
{-# INLINE thickArc #-}
|
||||
thickArc = ThickArc
|
||||
thickArc = ThickArc 0
|
||||
--thickArc startA endA rad wdth
|
||||
-- = thickLine (makeArc rad (startA,endA)) wdth
|
||||
|
||||
|
||||
Reference in New Issue
Block a user