39 lines
1.2 KiB
Haskell
39 lines
1.2 KiB
Haskell
module Dodge.Button.Draw where
|
|
|
|
import Color
|
|
import Dodge.Data.Button
|
|
import Geometry
|
|
import Shape
|
|
import ShapePicture
|
|
import Control.Lens
|
|
|
|
drawButton :: Button -> SPic
|
|
drawButton bt = case bt ^. btEvent of
|
|
ButtonPress {_bpColor = col} -> defaultDrawButton col bt
|
|
ButtonSimpleSwith {_bssColor1 = col1, _bssColor2 = col2} -> drawSwitch col1 col2 bt
|
|
ButtonAccessTerminal -> mempty
|
|
ButtonDoNothing -> mempty
|
|
|
|
drawSwitch :: Color -> Color -> Button -> SPic
|
|
drawSwitch col1 col2 bt
|
|
| _btState bt == BtOff = flick $ pi / 4
|
|
| otherwise = flick (negate (pi / 4))
|
|
where
|
|
flick a = noPic
|
|
( mconcat
|
|
[ colorSH col1 . upperBox Small Typical 20 $ rectNSWE (-2) (-5) (-10) 10
|
|
, colorSH col2 . translateSH (V3 0 (-2) 20) . rotateSH a . upperBox Small Typical 2 $
|
|
rectNSWE 10 0 (-2) 2
|
|
]
|
|
)
|
|
|
|
defaultDrawButton :: Color -> Button -> SPic
|
|
defaultDrawButton col bt = noPic
|
|
( translateSHz 15 . colorSH col $ upperBox Small Typical 5 buttonGeometry
|
|
)
|
|
where
|
|
buttonGeometry
|
|
| _btState bt == BtOff = rectNSWE 10 (-1) (- width) width
|
|
| otherwise = rectNSWE 2 (-1) (- width) width
|
|
width = 8
|