Refactor vertex poking

This commit is contained in:
2021-08-10 02:29:17 +02:00
parent 79eb031637
commit 51b8fab214
4 changed files with 57 additions and 66 deletions
+8 -8
View File
@@ -73,19 +73,19 @@ polygon :: [Point2] -> Picture
{-# INLINE polygon #-}
polygon ps = map (f . zeroZ) $ polyToTris ps
where
f pos = Verx pos black PolyV 0 polyNum
f pos = Verx pos black [] 0 polyNum
polygonZ :: [Point2] -> Float -> Picture
{-# INLINE polygonZ #-}
polygonZ ps z = map (f . zeroZ) $ polyToTris ps
where
f pos = Verx pos black (PolyzV z) 0 polyzNum
f pos = Verx pos black [z] 0 polyzNum
polygonCol :: [(Point2,RGBA)] -> Picture
{-# INLINE polygonCol #-}
polygonCol vs = polyToTris $ map f vs
where
f (V2 x y,col) = Verx (V3 x y 0) col PolyV 0 polyNum
f (V2 x y,col) = Verx (V3 x y 0) col [] 0 polyNum
poly3 :: [Point3] -> Picture
{-# INLINE poly3 #-}
@@ -95,7 +95,7 @@ poly3Col :: [(Point3,RGBA)] -> Picture
{-# INLINE poly3Col #-}
poly3Col vs = map f $ polyToTris vs
where
f (pos,col) = Verx pos col PolyV 0 polyNum
f (pos,col) = Verx pos col [] 0 polyNum
-- note that much of work computing the width of the bezier curve is done here
bezierQuad :: Color -> Color -> Float -> Float -> Point2 -> Point2 -> Point2 -> Picture
@@ -134,7 +134,7 @@ bezierQuad cola colc ra rc a b c
bzhelp :: [(Point2, Point4, Point2, Point2)] -> Picture
bzhelp = map f
where
f (V2 x y,col,V2 a b,V2 c d) = Verx (V3 x y 0) col (BezV (V4 a b c d)) 0 bezNum
f (V2 x y,col,V2 a b,V2 c d) = Verx (V3 x y 0) col [a,b,c,d] 0 bezNum
-- given a one and two zeros of a linear function over x and y,
-- determine the function
@@ -215,7 +215,7 @@ circleSolidCol colC colE r = map f
,( (V3 ( r) (-r) (0)), black)
]
where
f (pos,col) = Verx pos col EllV 0 ellNum
f (pos,col) = Verx pos col [] 0 ellNum
circle :: Float -> Picture
{-# INLINE circle #-}
@@ -225,7 +225,7 @@ text :: String -> Picture
{-# INLINE text #-}
text s = map f $ stringToList s
where
f (pos,col,val) = Verx pos col (TextV val) 0 textNum
f (pos,col,V2 a b) = Verx pos col [a,b] 0 textNum
line :: [Point2] -> Picture
{-# INLINE line #-}
@@ -306,7 +306,7 @@ thickArcHelp startA endA rad wdth = map f
(V2 xa ya) = rotateV startA (V2 rad 0)
(V2 xb yb) = rotateV (0.5 * (startA + endA)) (V2 (rad * sqrt 2) (0))
(V2 xc yc) = rotateV endA (V2 rad 0)
f (pos,col,val) = Verx pos col (ArcV val) 0 arcNum
f (pos,col,V3 a b c) = Verx pos col [a,b,c] 0 arcNum
withAlpha :: Float -> RGBA -> RGBA
{-# INLINE withAlpha #-}