Move button data

This commit is contained in:
2022-07-21 18:22:08 +01:00
parent aabd8a2cb8
commit b58444f931
16 changed files with 185 additions and 89 deletions
+36
View File
@@ -0,0 +1,36 @@
module Dodge.Button.Draw where
import Dodge.Data.Button
import Geometry
import Color
import ShapePicture
import Shape
drawButton :: ButtonDraw -> Button -> SPic
drawButton bd = case bd of
DefaultDrawButton col -> defaultDrawButton col
DefaultDrawSwitch col1 col2 -> drawSwitch col1 col2
DrawNoButton -> const mempty
drawSwitch :: Color -> Color -> Button -> SPic
drawSwitch col1 col2 bt
| _btState bt == BtOff
= flick $ pi/4
| otherwise = flick (negate (pi/4))
where
flick a = ( mconcat
[ colorSH col1 . upperPrismPoly 20 $ reverse $ rectNSWE (-2) (-5) (-10) 10
, colorSH col2 . translateSH (V3 0 (-2) 20) . rotateSH a . upperPrismPoly 2 $ reverse
$ rectNSWE 10 0 (-2) 2
]
, mempty)
defaultDrawButton :: Color -> Button -> SPic
defaultDrawButton col bt =
( translateSHz 15 . colorSH col $ upperPrismPoly 5 buttonGeometry
, mempty
)
where
buttonGeometry
| _btState bt == BtOff = reverse $ rectNSWE 10 (-1) (-width) width
| otherwise = reverse $ rectNSWE 2 (-1) (-width) width
width = 8