Cleanup arc drawing
This commit is contained in:
+52
-49
@@ -3,6 +3,7 @@
|
||||
|
||||
module Picture.Base (
|
||||
module Picture.Data,
|
||||
module Picture.Arc,
|
||||
module Color,
|
||||
blank,
|
||||
polygon,
|
||||
@@ -15,7 +16,7 @@ module Picture.Base (
|
||||
arc,
|
||||
arcSolid,
|
||||
thickArc,
|
||||
thickArcFull,
|
||||
--thickArcFull,
|
||||
thickCircle,
|
||||
thickLine,
|
||||
lineThick,
|
||||
@@ -51,6 +52,7 @@ import Color
|
||||
import Data.Foldable
|
||||
import Geometry
|
||||
import Picture.Data
|
||||
import Picture.Arc
|
||||
|
||||
blank :: Picture
|
||||
{-# INLINE blank #-}
|
||||
@@ -327,58 +329,59 @@ arc ::
|
||||
arc startA endA rad = thickArc startA endA rad 1
|
||||
{-# INLINE arc #-}
|
||||
|
||||
thickArcFull :: Float -> Float -> Color -> Float -> Float -> Color -> Float -> Picture
|
||||
{-# INLINE thickArcFull #-}
|
||||
thickArcFull sa sw sc ea ew ec rad
|
||||
| difference sa ea > pi / 2 = thickArcFull sa sw sc ma mw mc rad <> thickArcFull ma mw mc ea ew ec rad
|
||||
| otherwise = map f
|
||||
[ (V3 0 0 0, mc, V3 0 0 mw)
|
||||
, (V3 xa ya 0, sc, V3 1 0 sw)
|
||||
, (V3 xb yb 0, mc, V3 1 1 mw)
|
||||
, (V3 0 0 0, sc, V3 0 0 sw)
|
||||
, (V3 xb yb 0, mc, V3 1 1 mw)
|
||||
, (V3 xc yc 0, ec, V3 0 1 ew)
|
||||
]
|
||||
where
|
||||
(V2 xa ya) = rotateV sa (V2 rad 0)
|
||||
(V2 xb yb) = rotateV (0.5 * (sa + ea)) (V2 (rad * sqrt 2) 0)
|
||||
(V2 xc yc) = rotateV ea (V2 rad 0)
|
||||
f (pos, col, V3 a b c) = Verx pos col [a, b, c] BottomLayer arcNum
|
||||
ma = 0.5 * (sa + ea)
|
||||
mw = 0.5 * (sw + ew)
|
||||
mc = mixColors 0.5 0.5 sc ec
|
||||
--thickArcFull :: Float -> Float -> Color -> Float -> Float -> Color -> Float -> Picture
|
||||
--{-# INLINE thickArcFull #-}
|
||||
--thickArcFull sa sw sc ea ew ec rad
|
||||
-- | difference sa ea > pi / 2 = thickArcFull sa sw sc ma mw mc rad <> thickArcFull ma mw mc ea ew ec rad
|
||||
-- | otherwise = map f
|
||||
-- [ (V3 0 0 0, mc, V3 0 0 mw)
|
||||
-- , (V3 xa ya 0, sc, V3 1 0 sw)
|
||||
-- , (V3 xb yb 0, mc, V3 1 1 mw)
|
||||
-- , (V3 0 0 0, sc, V3 0 0 sw)
|
||||
-- , (V3 xb yb 0, mc, V3 1 1 mw)
|
||||
-- , (V3 xc yc 0, ec, V3 0 1 ew)
|
||||
-- ]
|
||||
-- where
|
||||
-- (V2 xa ya) = rotateV sa (V2 rad 0)
|
||||
-- (V2 xb yb) = rotateV (0.5 * (sa + ea)) (V2 (rad * sqrt 2) 0)
|
||||
-- (V2 xc yc) = rotateV ea (V2 rad 0)
|
||||
-- f (pos, col, V3 a b c) = Verx pos col [a, b, c] BottomLayer arcNum
|
||||
-- ma = 0.5 * (sa + ea)
|
||||
-- mw = 0.5 * (sw + ew)
|
||||
-- mc = mixColors 0.5 0.5 sc ec
|
||||
|
||||
thickArc :: Float -> Float -> Float -> Float -> Picture
|
||||
{-# INLINE thickArc #-}
|
||||
thickArc startA endA rad wdth
|
||||
| endA - startA > (pi / 2) =
|
||||
pictures
|
||||
[ thickArc (startA + pi / 2) endA rad wdth
|
||||
, thickArcHelp startA (startA + pi / 2) r w
|
||||
]
|
||||
| otherwise = thickArcHelp startA endA r w
|
||||
where
|
||||
r = rad + 0.5 * wdth
|
||||
w = 1 - wdth / r
|
||||
thickArc startA endA rad wdth = arcFull startA wdth white endA wdth white rad white
|
||||
--thickArc startA endA rad wdth
|
||||
-- | endA - startA > (pi / 2) =
|
||||
-- pictures
|
||||
-- [ thickArc (startA + pi / 2) endA rad wdth
|
||||
-- , thickArcHelp startA (startA + pi / 2) r w
|
||||
-- ]
|
||||
-- | otherwise = thickArcHelp startA endA r w
|
||||
-- where
|
||||
-- r = rad + 0.5 * wdth
|
||||
-- w = 1 - wdth / r
|
||||
|
||||
thickArcHelp :: Float -> Float -> Float -> Float -> Picture
|
||||
{-# INLINE thickArcHelp #-}
|
||||
thickArcHelp startA endA rad wdth =
|
||||
picFormat $
|
||||
map
|
||||
f
|
||||
[ (V3 0 0 0, black, V3 0 0 wdth)
|
||||
, (V3 xa ya 0, black, V3 1 0 wdth)
|
||||
, (V3 xb yb 0, black, V3 1 1 wdth)
|
||||
, (V3 0 0 0, black, V3 0 0 wdth)
|
||||
, (V3 xb yb 0, black, V3 1 1 wdth)
|
||||
, (V3 xc yc 0, black, V3 0 1 wdth)
|
||||
]
|
||||
where
|
||||
(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, V3 a b c) = Verx pos col [a, b, c] BottomLayer arcNum
|
||||
--thickArcHelp :: Float -> Float -> Float -> Float -> Picture
|
||||
--{-# INLINE thickArcHelp #-}
|
||||
--thickArcHelp startA endA rad wdth =
|
||||
-- picFormat $
|
||||
-- map
|
||||
-- f
|
||||
-- [ (V3 0 0 0, black, V3 0 0 wdth)
|
||||
-- , (V3 xa ya 0, black, V3 1 0 wdth)
|
||||
-- , (V3 xb yb 0, black, V3 1 1 wdth)
|
||||
-- , (V3 0 0 0, black, V3 0 0 wdth)
|
||||
-- , (V3 xb yb 0, black, V3 1 1 wdth)
|
||||
-- , (V3 xc yc 0, black, V3 0 1 wdth)
|
||||
-- ]
|
||||
-- where
|
||||
-- (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, V3 a b c) = Verx pos col [a, b, c] BottomLayer arcNum
|
||||
|
||||
-- Currently the lens version is much slower
|
||||
overPos :: (Point3 -> Point3) -> Verx -> Verx
|
||||
|
||||
Reference in New Issue
Block a user