-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Declarative graphics for the browser using GHCJS -- -- Shine wraps javascript's drawing functions in a declarative API. -- Heavily inspired by Gloss. -- -- Read the README for an overview of the library. @package shine @version 0.2.0.0 -- | Datatypes representing inputs. module Graphics.Shine.Input -- | The state of a button on the keyboard data KeyState Down :: KeyState Up :: KeyState -- | The four key modifiers data Modifiers Modifiers :: KeyState -> KeyState -> KeyState -> KeyState -> Modifiers [ctrl] :: Modifiers -> KeyState [alt] :: Modifiers -> KeyState [shift] :: Modifiers -> KeyState [meta] :: Modifiers -> KeyState -- | The three mouse buttons data MouseBtn BtnLeft :: MouseBtn BtnRight :: MouseBtn BtnMiddle :: MouseBtn -- | Datatype representing all possible inputs data Input Keyboard :: Key -> KeyState -> Modifiers -> Input MouseBtn :: MouseBtn -> KeyState -> Modifiers -> Input MouseWheel :: (Double, Double) -> Input MouseMove :: (Int, Int) -> Input -- | Convert a js mouse button identifier to the corresponding datatype toMouseBtn :: Word -> Maybe MouseBtn -- | Convert a bool (from js) to a keystate toKeyState :: Bool -> KeyState instance GHC.Classes.Eq Graphics.Shine.Input.Input instance GHC.Show.Show Graphics.Shine.Input.Input instance GHC.Classes.Eq Graphics.Shine.Input.MouseBtn instance GHC.Show.Show Graphics.Shine.Input.MouseBtn instance GHC.Classes.Eq Graphics.Shine.Input.Modifiers instance GHC.Show.Show Graphics.Shine.Input.Modifiers instance GHC.Classes.Eq Graphics.Shine.Input.KeyState instance GHC.Show.Show Graphics.Shine.Input.KeyState -- | Handling of external image (.png, .svg and all browser-supported -- formats). module Graphics.Shine.Image -- | Makes an image element from an URL makeImage :: FilePath -> IO ImageData -- | How big (and how stretched/cropped) the Image is drawn data ImageSize -- | The orizinal size of the image Original :: ImageSize -- | Scale the image to the given dimensions Stretched :: Float -> Float -> ImageSize -- | Clip the image from the given coordinates to the given width and -- height Clipped :: Float -> Float -> Float -> Float -> ImageSize -- | Clip (x,y,width,height) and scale (width, height) the image ClippedStretched :: Float -> Float -> Float -> Float -> Float -> Float -> ImageSize -- | Just a wrapper around the HTMLImageElement type. Needed for the -- Show instance. newtype ImageData ImageData :: HTMLImageElement -> ImageData [unImageData] :: ImageData -> HTMLImageElement instance GHC.Show.Show Graphics.Shine.Image.ImageSize instance GHC.Classes.Eq Graphics.Shine.Image.ImageSize instance GHC.Classes.Eq Graphics.Shine.Image.ImageData instance GHC.Show.Show Graphics.Shine.Image.ImageData -- | This module contains the Picture datatype, used to represent -- the image to draw on the canvas, and some functions to operate on it. module Graphics.Shine.Picture -- | A drawable element. All Pictures are centered. data Picture -- | The empty picture. Draws nothing. Empty :: Picture -- | A rectangle from the dimensions Rect :: Double -> Double -> Picture -- | Same thing but filled RectF :: Double -> Double -> Picture -- | A line from the coordinates of two points Line :: Double -> Double -> Double -> Double -> Picture -- | A polygon from a list of vertices Polygon :: [(Double, Double)] -> Picture -- | An arc from the radius, start angle, end angle. If the last parameter -- is True, the direction is counterclockwise TODO replace with Clockwise -- | Counterclockwise or remove entirely Arc :: Double -> Double -> Double -> Bool -> Picture -- | A filled circle from the radius CircleF :: Double -> Picture -- | Draws some text. The Maybe Double is the optional max -- width. Text :: Font -> TextAlignment -> (Maybe Double) -> String -> Picture -- | Draws an image Image :: ImageSize -> ImageData -> Picture -- | Draws the second Picture over the first Over :: Picture -> Picture -> Picture -- | Applies the Color to the picture. Innermost colors have the -- precedence, so you can set a "global color" and override it Colored :: Color -> Picture -> Picture -- | Rotates the Picture (in radians) Rotate :: Double -> Picture -> Picture -- | Moves the Picture by the given x and y distances Translate :: Double -> Double -> Picture -> Picture -- | A color given r, g, b (all from 0 to 255) and alpha (from 0 to 1) data Color Color :: Int -> Int -> Int -> Float -> Color -- | How the text should be aligned data TextAlignment LeftAlign :: TextAlignment CenterAlign :: TextAlignment RightAlign :: TextAlignment -- | Js-style font, ex. "12px Sans" type Font = String -- | A circle from the center coordinates and radius circle :: Double -> Picture -- | Shorthand to draw a series of lines path :: [(Double, Double)] -> Picture -- | An infix synonym for mappend. (<>) :: Monoid m => m -> m -> m infixr 6 <> instance GHC.Show.Show Graphics.Shine.Picture.Picture instance GHC.Classes.Eq Graphics.Shine.Picture.Picture instance GHC.Show.Show Graphics.Shine.Picture.Color instance GHC.Classes.Eq Graphics.Shine.Picture.Color instance GHC.Show.Show Graphics.Shine.Picture.TextAlignment instance GHC.Classes.Eq Graphics.Shine.Picture.TextAlignment instance GHC.Base.Monoid Graphics.Shine.Picture.Picture -- | One-shot rendering, mostly used internally. module Graphics.Shine.Render -- | Renders a picture on a 2D context. render :: CanvasRenderingContext2D -> Picture -> JSM () -- | The main module. Here are defined all the functions needed to get an -- animation on the screen. -- -- If you want to render a single Picture only once, use -- render from Render module Graphics.Shine -- | Get a context from a canvas element. toContext :: Element -> JSM CanvasRenderingContext2D -- | Create a full screen canvas fullScreenCanvas :: Document -> JSM CanvasRenderingContext2D -- | Create a fixed size canvas given the dimensions fixedSizeCanvas :: Document -> Int -> Int -> JSM CanvasRenderingContext2D -- | Draws a picture which depends only on the time animate :: CanvasRenderingContext2D -> Double -> (Double -> Picture) -> JSM () -- | Draws a picture which depends only on the time... and everything else, -- since you can do I/O. animateIO :: CanvasRenderingContext2D -> Double -> (Double -> IO Picture) -> JSM () -- | Lets you manage the input. play :: (IsEventTarget eventElement, IsDocument eventElement) => CanvasRenderingContext2D -> eventElement -> Double -> state -> (state -> Picture) -> (Input -> state -> state) -> (Double -> state -> state) -> JSM () -- | Same thing with I/O playIO :: (IsEventTarget eventElement, IsDocument eventElement) => CanvasRenderingContext2D -> eventElement -> Double -> state -> (state -> IO Picture) -> (Input -> state -> IO state) -> (Double -> state -> IO state) -> JSM ()