{-# LANGUAGE GADTs #-}
module Graphics.Rendering.Chart.Backend.Impl where
import Control.Monad.Reader
import Control.Monad.Operational
import Graphics.Rendering.Chart.Geometry
import Graphics.Rendering.Chart.Backend.Types
data ChartBackendInstr a where
StrokePath :: Path -> ChartBackendInstr ()
FillPath :: Path -> ChartBackendInstr ()
GetTextSize :: String -> ChartBackendInstr TextSize
DrawText :: Point -> String -> ChartBackendInstr ()
GetAlignments :: ChartBackendInstr AlignmentFns
WithTransform :: Matrix -> Program ChartBackendInstr a -> ChartBackendInstr a
WithFontStyle :: FontStyle -> Program ChartBackendInstr a -> ChartBackendInstr a
WithFillStyle :: FillStyle -> Program ChartBackendInstr a -> ChartBackendInstr a
WithLineStyle :: LineStyle -> Program ChartBackendInstr a -> ChartBackendInstr a
WithClipRegion :: Rect -> Program ChartBackendInstr a -> ChartBackendInstr a
type BackendProgram a = Program ChartBackendInstr a
strokePath :: Path -> BackendProgram ()
strokePath :: Path -> BackendProgram ()
strokePath Path
p = ChartBackendInstr () -> BackendProgram ()
forall (instr :: * -> *) a (m :: * -> *).
instr a -> ProgramT instr m a
singleton (Path -> ChartBackendInstr ()
StrokePath Path
p)
fillPath :: Path -> BackendProgram ()
fillPath :: Path -> BackendProgram ()
fillPath Path
p = ChartBackendInstr () -> BackendProgram ()
forall (instr :: * -> *) a (m :: * -> *).
instr a -> ProgramT instr m a
singleton (Path -> ChartBackendInstr ()
FillPath Path
p)
textSize :: String -> BackendProgram TextSize
textSize :: String -> BackendProgram TextSize
textSize String
text = ChartBackendInstr TextSize -> BackendProgram TextSize
forall (instr :: * -> *) a (m :: * -> *).
instr a -> ProgramT instr m a
singleton (String -> ChartBackendInstr TextSize
GetTextSize String
text)
drawText :: Point -> String -> BackendProgram ()
drawText :: Point -> String -> BackendProgram ()
drawText Point
p String
text = ChartBackendInstr () -> BackendProgram ()
forall (instr :: * -> *) a (m :: * -> *).
instr a -> ProgramT instr m a
singleton (Point -> String -> ChartBackendInstr ()
DrawText Point
p String
text)
withTransform :: Matrix -> BackendProgram a -> BackendProgram a
withTransform :: Matrix -> BackendProgram a -> BackendProgram a
withTransform Matrix
t BackendProgram a
p = ChartBackendInstr a -> BackendProgram a
forall (instr :: * -> *) a (m :: * -> *).
instr a -> ProgramT instr m a
singleton (Matrix -> BackendProgram a -> ChartBackendInstr a
forall a.
Matrix -> Program ChartBackendInstr a -> ChartBackendInstr a
WithTransform Matrix
t BackendProgram a
p)
withFontStyle :: FontStyle -> BackendProgram a -> BackendProgram a
withFontStyle :: FontStyle -> BackendProgram a -> BackendProgram a
withFontStyle FontStyle
fs BackendProgram a
p = ChartBackendInstr a -> BackendProgram a
forall (instr :: * -> *) a (m :: * -> *).
instr a -> ProgramT instr m a
singleton (FontStyle -> BackendProgram a -> ChartBackendInstr a
forall a.
FontStyle -> Program ChartBackendInstr a -> ChartBackendInstr a
WithFontStyle FontStyle
fs BackendProgram a
p)
withFillStyle :: FillStyle -> BackendProgram a -> BackendProgram a
withFillStyle :: FillStyle -> BackendProgram a -> BackendProgram a
withFillStyle FillStyle
fs BackendProgram a
p = ChartBackendInstr a -> BackendProgram a
forall (instr :: * -> *) a (m :: * -> *).
instr a -> ProgramT instr m a
singleton (FillStyle -> BackendProgram a -> ChartBackendInstr a
forall a.
FillStyle -> Program ChartBackendInstr a -> ChartBackendInstr a
WithFillStyle FillStyle
fs BackendProgram a
p)
withLineStyle :: LineStyle -> BackendProgram a -> BackendProgram a
withLineStyle :: LineStyle -> BackendProgram a -> BackendProgram a
withLineStyle LineStyle
ls BackendProgram a
p = ChartBackendInstr a -> BackendProgram a
forall (instr :: * -> *) a (m :: * -> *).
instr a -> ProgramT instr m a
singleton (LineStyle -> BackendProgram a -> ChartBackendInstr a
forall a.
LineStyle -> Program ChartBackendInstr a -> ChartBackendInstr a
WithLineStyle LineStyle
ls BackendProgram a
p)
withClipRegion :: Rect -> BackendProgram a -> BackendProgram a
withClipRegion :: Rect -> BackendProgram a -> BackendProgram a
withClipRegion Rect
c BackendProgram a
p = ChartBackendInstr a -> BackendProgram a
forall (instr :: * -> *) a (m :: * -> *).
instr a -> ProgramT instr m a
singleton (Rect -> BackendProgram a -> ChartBackendInstr a
forall a.
Rect -> Program ChartBackendInstr a -> ChartBackendInstr a
WithClipRegion Rect
c BackendProgram a
p)
getPointAlignFn :: BackendProgram (Point->Point)
getPointAlignFn :: BackendProgram (Point -> Point)
getPointAlignFn = (AlignmentFns -> Point -> Point)
-> ProgramT ChartBackendInstr Identity AlignmentFns
-> BackendProgram (Point -> Point)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM AlignmentFns -> Point -> Point
afPointAlignFn (ChartBackendInstr AlignmentFns
-> ProgramT ChartBackendInstr Identity AlignmentFns
forall (instr :: * -> *) a (m :: * -> *).
instr a -> ProgramT instr m a
singleton ChartBackendInstr AlignmentFns
GetAlignments)
getCoordAlignFn :: BackendProgram (Point->Point)
getCoordAlignFn :: BackendProgram (Point -> Point)
getCoordAlignFn = (AlignmentFns -> Point -> Point)
-> ProgramT ChartBackendInstr Identity AlignmentFns
-> BackendProgram (Point -> Point)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM AlignmentFns -> Point -> Point
afCoordAlignFn (ChartBackendInstr AlignmentFns
-> ProgramT ChartBackendInstr Identity AlignmentFns
forall (instr :: * -> *) a (m :: * -> *).
instr a -> ProgramT instr m a
singleton ChartBackendInstr AlignmentFns
GetAlignments)