Remove bezier shader

This commit is contained in:
2023-03-23 00:38:14 +00:00
parent db53a1ffb2
commit 68b43f29ff
6 changed files with 35 additions and 92 deletions
+13 -55
View File
@@ -11,7 +11,6 @@ module Picture.Base (
polygonCol,
poly3,
poly3Col,
bezierQuad,
arc,
arcSolid,
thickArc,
@@ -88,61 +87,20 @@ poly3Col = map f . polyToTris
where
f (pos, col) = Verx pos col [] BottomLayer 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
bezierQuad cola colc ra rc a b c
| a == b && b == c = blank
| a == b || b == c = bezierQuad cola colc ra rc a (0.5 *.* (a +.+ c)) c
| otherwise =
bzhelp
[ (aIn, cola, V2 (fa aIn) (fc aIn), V2 1 0)
, (aIn, cola, V2 (fa aIn) (fc aIn), V2 1 0)
, (cIn, colc, V2 (fa cIn) (fc cIn), V2 0 1)
, (aX, cola, V2 1 0, V2 (fa' aX) (fc' aX))
, (cX, colc, V2 0 1, V2 (fa' cX) (fc' cX))
, (bX, colb, V2 0 0, V2 (fa' bX) (fc' bX))
, (bX, colb, V2 0 0, V2 (fa' bX) (fc' bX))
]
where
colb = mixColors 0.5 0.5 cola colc
b2a
| isLHS a b c = a -.- b
| otherwise = b -.- a
aRadVec = 0.5 * ra *.* normalizeV (vNormal b2a)
aX = a -.- aRadVec
aIn = a +.+ aRadVec
b2c
| isLHS a b c = b -.- c
| otherwise = c -.- b
cRadVec = 0.5 * rc *.* normalizeV (vNormal b2c)
cX = c -.- cRadVec
cIn = c +.+ cRadVec
bRadVec = 0.25 * (ra + rc) *.* normalizeV (a +.+ b -.- 2 *.* c)
bX = b +.+ bRadVec
bIn = b -.- bRadVec
fa = extrapolate aX cX bX
fc = extrapolate cX aX bX
fa' = extrapolate aIn cIn bIn
fc' = extrapolate cIn aIn bIn
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 [a, b, c, d] BottomLayer bezNum
-- given a one and two zeros of a linear function over x and y,
-- determine the function
-- so if f(ox,oy) = 1 and f(ax,ay) = f(bx,by) = 0, determines f
extrapolate :: Point2 -> Point2 -> Point2 -> Point2 -> Float
extrapolate (V2 ox oy) (V2 ax ay) (V2 bx by) (V2 x y) =
( x * (ay - by)
+ y * (bx - ax)
+ (ax * by - bx * ay)
)
/ ( ox * (ay - by)
+ ax * (by - oy)
+ bx * (oy - ay)
)
---- given a one and two zeros of a linear function over x and y,
---- determine the function
---- so if f(ox,oy) = 1 and f(ax,ay) = f(bx,by) = 0, determines f
--extrapolate :: Point2 -> Point2 -> Point2 -> Point2 -> Float
--extrapolate (V2 ox oy) (V2 ax ay) (V2 bx by) (V2 x y) =
-- ( x * (ay - by)
-- + y * (bx - ax)
-- + (ax * by - bx * ay)
-- )
-- / ( ox * (ay - by)
-- + ax * (by - oy)
-- + bx * (oy - ay)
-- )
color :: RGBA -> Picture -> Picture
{-# INLINE color #-}