{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
module Eventloop.Module.Websocket.Canvas.Types where
import Control.Concurrent.MVar
import GHC.Generics (Generic)
import Control.DeepSeq
import Eventloop.Types.Common
type CanvasSystemReceiveBuffer = MVar SystemCanvasIn
instance Show (MVar a) where
show _ = "CanvasSystemReceiveBuffer"
type Opcode = Int
type ScreenMetric = Int
type ScreenX = ScreenMetric
type ScreenY = ScreenMetric
type ScreenWidth = ScreenMetric
type ScreenHeight = ScreenMetric
type ScreenRadius = ScreenMetric
type ScreenAngle = ScreenMetric
type ScreenPoint = (ScreenX, ScreenY)
type ScreenDimensions = (ScreenWidth, ScreenHeight)
type ScreenStartingPoint = ScreenPoint
type ScreenControlPoint = ScreenPoint
type ScreenEndPoint = ScreenPoint
type ScreenStartingAngle = ScreenAngle
type ScreenEndAngle = ScreenAngle
type CanvasId = NumericId
type ZIndex = Int
type ScreenColorMetric = Int
type ScreenRed = ScreenColorMetric
type ScreenGreen = ScreenColorMetric
type ScreenBlue = ScreenColorMetric
type ScreenAlpha = Float
type ScreenColor = (ScreenRed, ScreenGreen, ScreenBlue, ScreenAlpha)
type ScreenPixel = ScreenColor
type ColorStopOffset = Float
type ScreenCircle = (ScreenPoint, ScreenRadius)
type ScaleUnit = Float
type ScaleX = ScaleUnit
type ScaleY = ScaleUnit
type ScreenLineThickness = Float
type FontFamily = [Char]
type FontSize = Int
data RoutedMessageIn = InUserCanvas CanvasIn
| InSystemCanvas SystemCanvasIn
deriving (Eq, Show)
data RoutedMessageOut = OutUserCanvas CanvasOut
| OutSystemCanvas SystemCanvasOut
deriving (Eq, Show, Generic, NFData)
data SystemCanvasIn = SystemMeasuredText CanvasText ScreenDimensions
deriving (Eq, Show)
data SystemCanvasOut = SystemMeasureText CanvasText
deriving (Eq, Show, Generic, NFData)
data CanvasIn = MeasuredText CanvasText ScreenDimensions
deriving (Eq, Show)
data CanvasOut = SetupCanvas CanvasId ZIndex ScreenDimensions CSSPosition
| TeardownCanvas CanvasId
| CanvasOperations CanvasId [CanvasOperation]
| MeasureText CanvasText
deriving (Eq, Show, Generic, NFData)
data CanvasOperation = DrawPath ScreenStartingPoint [ScreenPathPart] PathStroke PathFill
| DrawText CanvasText ScreenPoint TextStroke TextFill
| DoTransform CanvasTransform
| Clear ClearPart
| Frame
deriving (Eq, Show, Generic, NFData)
data ScreenPathPart = MoveTo ScreenPoint
| LineTo ScreenPoint
| BezierCurveTo ScreenControlPoint ScreenControlPoint ScreenEndPoint
| QuadraticCurveTo ScreenControlPoint ScreenEndPoint
| ArcTo ScreenControlPoint ScreenControlPoint ScreenRadius
| Arc ScreenCircle ScreenStartingAngle ScreenEndAngle
| Rectangle ScreenPoint ScreenDimensions
| ClosePath
deriving (Eq, Show, Generic, NFData)
type PathRenderStrokeStyle = RenderStyle
data PathStroke = PathStroke ScreenLineThickness PathRenderStrokeStyle
| NoPathStroke
deriving (Eq, Show, Generic, NFData)
type PathRenderFillStyle = RenderStyle
data PathFill = PathFill PathRenderFillStyle
| NoPathFill
deriving (Eq, Show, Generic, NFData)
type CanvasColorStop = (ColorStopOffset, ScreenColor)
data RenderStyle = CanvasColor ScreenColor
| CanvasGradient CanvasGradientType [CanvasColorStop]
| CanvasPattern CanvasImage PatternRepetition
deriving (Eq, Show, Generic, NFData)
data CanvasImage = CanvasElement CanvasId ScreenPoint ScreenDimensions
| ImageData ScreenDimensions [ScreenPixel]
deriving (Eq, Show, Generic, NFData)
data PatternRepetition = Repeat
| RepeatX
| RepeatY
| NoRepeat
deriving (Eq, Show, Generic, NFData)
data CanvasGradientType = RadialGradient ScreenCircle ScreenCircle
| LinearGradient ScreenPoint ScreenPoint
deriving (Eq, Show, Generic, NFData)
data CanvasText = CanvasText [Char] Font Alignment
deriving (Eq, Show, Generic, NFData)
data Font = Font FontFamily FontSize
deriving (Eq, Show, Generic, NFData)
type TextStrokeRenderStyle = RenderStyle
type TextFillRenderStyle = RenderStyle
data TextStroke = TextStroke ScreenLineThickness TextStrokeRenderStyle
| NoTextStroke
deriving (Eq, Show, Generic, NFData)
data TextFill = TextFill TextFillRenderStyle
| NoTextFill
deriving (Eq, Show, Generic, NFData)
data Alignment = AlignLeft
| AlignRight
| AlignCenter
deriving (Eq, Show, Generic, NFData)
type TransformUnit = Float
type TransformationMatrix = (TransformUnit, TransformUnit, TransformUnit, TransformUnit, TransformUnit, TransformUnit)
data CanvasTransform = Save
| Restore
| Translate ScreenPoint
| Rotate ScreenAngle
| Scale ScaleX ScaleY
| Transform TransformationMatrix
| SetTransform TransformationMatrix
| ResetTransform
deriving (Eq, Show, Generic, NFData)
type CSSLeftOffset = CSSUnit
type CSSTopOffset = CSSUnit
type CSSMeasurements = (CSSLeftOffset, CSSTopOffset)
data CSSPosition = CSSPosition CSSBindPoint CSSMeasurements
deriving (Eq, Show, Generic, NFData)
data CSSBindPoint = CSSFromCenter
| CSSFromDefault
deriving (Eq, Show, Generic, NFData)
data CSSUnit = CSSPixels Int
| CSSPercentage Int
deriving (Eq, Show, Generic, NFData)
data ClearPart = ClearRectangle ScreenPoint ScreenDimensions
| ClearCanvas
deriving (Eq, Show, Generic, NFData)