Files
loop/src/Dodge/Placement/TopDecoration.hs
T
2022-06-03 09:20:03 +01:00

64 lines
2.1 KiB
Haskell

module Dodge.Placement.TopDecoration where
import Dodge.Data
import Dodge.Room.Foreground
--import Dodge.LevelGen.Data
import Shape
import Geometry
import Color
decorationToShape :: DecorationShape
-> Float -> Float -> Float -> Color -> Color -> Shape
decorationToShape dec = case dec of
PLUS -> plusDecoration
SQUARE -> squareDecoration
CIRCLE -> circleDecoration
THREELINES -> threeLineDecoration
midBarDecoration :: Float -> Float -> Float -> Color -> Color -> Shape
midBarDecoration w h z _ c = embossingR
<> rotateSH pi embossingR
<> colorSH c (thinHighBar (z + 7) (V2 (-0.3*w) 0) (V2 (0.3*w) 0))
where
w' = 0.3 * w
embossingR = colorSH c $ prismPoly
[V3 w h z,V3 w (0.3*h) 41,V3 w (-0.3*h) 41,V3 w (-h) z]
[V3 w' h z,V3 w' (0.3*h) 41,V3 w' (-0.3*h) 41,V3 w' (-h) z]
fourEmbossDecoration :: Float -> Float -> Float -> Color -> Color -> Shape
fourEmbossDecoration w h z _ c = colorSH c $ foldMap f [(w,h),(-w,h),(w,-h),(-w,-h)]
where
f (a,b) = translateSH (V3 (a/2) (b/2) z) embossing
embossing = upperPrismPolyHalf 10 $ rectNSEW (h/2) (-h/2) (w/2) (-w/2)
plusDecoration :: Float -> Float -> Float -> Color -> Color -> Shape
plusDecoration w h z _ c = colorSH c $ thinHighBar z (V2 w 0) (V2 (-w) 0)
<> thinHighBar z (V2 0 h) (V2 0 (-h))
squareDecoration :: Float -> Float -> Float -> Color -> Color -> Shape
squareDecoration w h z _ col = colorSH col $ foldMap f
[(w',-w',h',h')
,(w',-w',-h',-h')
,(w',w',h',-h')
,(-w',-w',h',-h')
]
where
w' = w - 1.5
h' = h - 1.5
f (a,c,b,d) = thinHighBar z (V2 a b) (V2 c d)
circleDecoration :: Float -> Float -> Float -> Color -> Color -> Shape
circleDecoration w _ z _ c = colorSH c $ foldMap toprail (take 8 [0,pi/4..])
where
toprail a = rotateSH a $ thinHighBar z (V2 0 w) (rotateV (pi/4) $ V2 0 w)
threeLineDecoration :: Float -> Float -> Float -> Color -> Color -> Shape
threeLineDecoration w h z _ col = colorSH col $ foldMap f
[(w',-w',h',h')
,(w',-w',0,0)
,(w',-w',-h',-h')
]
where
w' = w - 1.5
h' = h - 1.5
f (a,c,b,d) = thinHighBar z (V2 a b) (V2 c d)