metabrush/src/app/MetaBrush/Asset/Cursor.hs

50 lines
1.1 KiB
Haskell
Raw Normal View History

2020-08-07 22:41:08 +00:00
{-# LANGUAGE NamedFieldPuns #-}
2020-08-07 19:39:24 +00:00
module MetaBrush.Asset.Cursor
( drawCursor, drawCursorIcon )
where
-- gi-cairo-render
import qualified GI.Cairo.Render as Cairo
-- MetaBrush
2020-08-07 22:41:08 +00:00
import MetaBrush.Asset.Colours
( ColourRecord(..), Colours )
2020-09-01 19:56:59 +00:00
import MetaBrush.Util
2020-08-07 19:39:24 +00:00
( withRGBA )
--------------------------------------------------------------------------------
-- | "Selection" mouse cursor. 18 x 18.
2020-08-07 22:41:08 +00:00
drawCursor :: Colours -> Cairo.Render Bool
drawCursor ( Colours { cursor, cursorOutline } ) = do
2020-08-07 19:39:24 +00:00
Cairo.newPath
Cairo.moveTo 12.5 10.5
Cairo.curveTo 5.5 11.5 4.5 12.5 0.5 17.5
Cairo.lineTo 0.5 0
2020-08-07 19:39:24 +00:00
Cairo.closePath
2020-08-07 22:41:08 +00:00
withRGBA cursor Cairo.setSourceRGBA
2020-08-07 19:39:24 +00:00
Cairo.fillPreserve
Cairo.setLineWidth 1
withRGBA cursorOutline Cairo.setSourceRGBA
Cairo.strokePreserve
2020-08-07 19:39:24 +00:00
pure True
2020-08-07 22:41:08 +00:00
-- | "Selection" tool icon. 40 x 40.
drawCursorIcon :: Colours -> Cairo.Render Bool
drawCursorIcon ( Colours { cursor } ) = do
2020-08-07 19:39:24 +00:00
2020-08-07 22:41:08 +00:00
withRGBA cursor Cairo.setSourceRGBA
2020-08-07 19:39:24 +00:00
Cairo.newPath
Cairo.moveTo 29 22
Cairo.curveTo 20 22 18 24 12 31
Cairo.lineTo 12 8.5
2020-08-07 19:39:24 +00:00
Cairo.closePath
Cairo.fillPreserve
pure True