metabrush/src/app/MetaBrush/Asset/TickBox.hs
2020-09-01 21:56:59 +02:00

104 lines
3.9 KiB
Haskell

{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NegativeLiterals #-}
module MetaBrush.Asset.TickBox
( drawBox, drawTickedBox )
where
-- gi-cairo-render
import qualified GI.Cairo.Render as Cairo
-- MetaBrush
import MetaBrush.Asset.Colours
( ColourRecord(..), Colours )
import MetaBrush.Util
( withRGBA )
--------------------------------------------------------------------------------
-- | Non-ticked box. Width = 14, height = 12.
drawBox :: Colours -> Cairo.Render Bool
drawBox ( Colours { plain } ) = do
withRGBA plain Cairo.setSourceRGBA
Cairo.newPath
Cairo.moveTo 2.015625 0.769531
Cairo.curveTo 0.910156 0.769531 0 1.6875 0 2.789063
Cairo.lineTo 0 10
Cairo.curveTo 0 11.101563 0.910156 12.015625 2.015625 12.015625
Cairo.lineTo 9.226563 12.015625
Cairo.curveTo 10.328125 12.015625 11.246094 11.101563 11.246094 10
Cairo.lineTo 11.246094 2.789063
Cairo.curveTo 11.246094 1.6875 10.328125 0.769531 9.226563 0.769531
Cairo.closePath
Cairo.moveTo 2.015625 2.375
Cairo.lineTo 9.226563 2.375
Cairo.curveTo 9.46875 2.375 9.640625 2.546875 9.640625 2.789063
Cairo.lineTo 9.640625 10
Cairo.curveTo 9.640625 10.242188 9.46875 10.414063 9.226563 10.414063
Cairo.lineTo 2.015625 10.414063
Cairo.curveTo 1.769531 10.414063 1.597656 10.242188 1.597656 10
Cairo.lineTo 1.597656 2.789063
Cairo.curveTo 1.597656 2.546875 1.769531 2.375 2.015625 2.375
Cairo.closePath
Cairo.setFillRule Cairo.FillRuleWinding
Cairo.fillPreserve
pure True
-- | Ticked box. Width = 14, height = 12.
drawTickedBox :: Colours -> Cairo.Render Bool
drawTickedBox ( Colours { plain } ) = do
-- Box
withRGBA plain Cairo.setSourceRGBA
Cairo.newPath
Cairo.moveTo 2.015625 0.769531
Cairo.curveTo 0.910156 0.769531 0 1.679688 0 2.785156
Cairo.lineTo 0 9.996094
Cairo.curveTo 0 11.097656 0.910156 12.015625 2.015625 12.015625
Cairo.lineTo 9.226563 12.015625
Cairo.curveTo 10.328125 12.015625 11.246094 11.097656 11.246094 9.996094
Cairo.lineTo 11.246094 5.867188
Cairo.lineTo 9.640625 7.476563
Cairo.lineTo 9.640625 9.996094
Cairo.curveTo 9.640625 10.238281 9.46875 10.410156 9.226563 10.410156
Cairo.lineTo 2.015625 10.410156
Cairo.curveTo 1.769531 10.410156 1.597656 10.238281 1.597656 9.996094
Cairo.lineTo 1.597656 2.785156
Cairo.curveTo 1.597656 2.539063 1.769531 2.371094 2.015625 2.371094
Cairo.lineTo 9.226563 2.371094
Cairo.curveTo 9.277344 2.371094 9.324219 2.378906 9.367188 2.394531
Cairo.lineTo 10.511719 1.25
Cairo.curveTo 10.160156 0.957031 9.710938 0.769531 9.226563 0.769531
Cairo.closePath
Cairo.fillPreserve
-- Tickmark
withRGBA plain Cairo.setSourceRGBA
Cairo.newPath
Cairo.moveTo 13.40625 0.0078125
Cairo.curveTo 13.191406 0.0390625 12.96875 0.144531 12.785156 0.328125
Cairo.lineTo 6.511719 6.605469
Cairo.lineTo 4.597656 4.691406
Cairo.curveTo 4.230469 4.328125 3.710938 4.257813 3.425781 4.542969
Cairo.lineTo 3.144531 4.820313
Cairo.curveTo 2.863281 5.105469 2.929688 5.628906 3.300781 5.992188
Cairo.lineTo 5.8125 8.5
Cairo.curveTo 5.925781 8.609375 6.046875 8.683594 6.175781 8.738281
Cairo.curveTo 6.261719 8.78125 6.332031 8.804688 6.417969 8.816406
Cairo.curveTo 6.425781 8.816406 6.429688 8.816406 6.445313 8.816406
Cairo.curveTo 6.53125 8.824219 6.605469 8.820313 6.6875 8.796875
Cairo.curveTo 6.71875 8.789063 6.746094 8.785156 6.773438 8.773438
Cairo.curveTo 6.929688 8.722656 7.085938 8.644531 7.21875 8.511719
Cairo.lineTo 14.097656 1.625
Cairo.curveTo 14.464844 1.261719 14.53125 0.738281 14.253906 0.453125
Cairo.lineTo 13.976563 0.179688
Cairo.curveTo 13.835938 0.0351563 13.632813 -0.0195313 13.421875 0.0078125
Cairo.closePath
Cairo.fillPreserve
pure True