-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A functional interface to 2D drawing in OpenGL -- -- This module is a functional wrapper around OpenGL, so you don't have -- to go into the deep, dark world of imperative stateful programming -- just to draw stuff. It supports 2D only (for now), with support -- drawing geometry, images, and text. @package graphics-drawingcombinators @version 0.1 -- | Drawing combinators as a functional interface to OpenGL (for 2D -- drawings only... for now). -- -- This module is intended to be imported qualified, as in: -- --
-- import Graphics.DrawingCombinators as Draw ---- -- It is recommended that you use this module in combination with SDL; it -- has not been tested in any other environments. module Graphics.DrawingCombinators -- | Drawing is the main type built by combinators in this module. It -- represents a picture that can be drawn using draw after -- possibly being transformed. -- -- The Monoid instance drawings works as follows: a mappend b -- draws b on top of a. data Drawing -- | Draw a Drawing on the screen in the current OpenGL coordinate system -- (which, in absense of information, is (-1,-1) in the lower left and -- (1,1) in the upper right. runDrawing :: Drawing -> IO () -- | Like runDrawing, but clears the screen first. This is so you can use -- this module and pretend that OpenGL doesn't exist at all. draw :: Drawing -> IO () -- | Convert an IO action into a drawing, for when you need some OpenGL -- capabilities that are not implemented in this module. If you use this, -- please behave. unsafeDraw :: IO () -> Drawing type Vec2 = (Double, Double) -- | Perform initialization of the library. This can fail. init :: IO () -- | Draw a single pixel at the specified point. point :: Vec2 -> Drawing -- | Draw a line connecting the two given points. line :: Vec2 -> Vec2 -> Drawing -- | Draw a regular polygon centered at the origin with n sides. regularPoly :: Int -> Drawing -- | Draw a unit circle centered at the origin. This is equivalent to -- regularPoly 24. circle :: Drawing -- | Translate the given drawing by the given amount. translate :: Vec2 -> Drawing -> Drawing -- | Rotate the given drawing counterclockwise by the given number of -- radians. rotate :: Double -> Drawing -> Drawing -- | scale x y d scales d by a factor of x in -- the horizontal direction and y in the vertical direction. scale :: Double -> Double -> Drawing -> Drawing type Color = (Double, Double, Double, Double) -- | color c d sets the color of the drawing to exactly -- c. color :: Color -> Drawing -> Drawing -- | colorFunc f d modifies all colors appearing in d -- with the function f. For example: -- --
-- colorFunc (\(r,g,b,a) -> (r,g,b,a/2)) d ---- -- Will draw d at greater transparency, regardless of the calls to color -- within. colorFunc :: (Color -> Color) -> Drawing -> Drawing -- | A sprite represents a bitmap image. data Sprite -- | Indicate how a nonrectangular image is to be mapped to a sprite. data SpriteScaling -- | ScaleMax will set the maximum of the height and width of the image to -- 1. ScaleMax :: SpriteScaling -- | ScaleWidth will set the width of the image to 1, and scale the height -- appropriately. ScaleWidth :: SpriteScaling -- | ScaleHeight will set the height of the image to 1, and scale the width -- appropriately. ScaleHeight :: SpriteScaling -- | Convert an SDL.Surface to a Sprite. surfaceToSprite :: SpriteScaling -> Surface -> IO Sprite -- | Load an image from a file and create a sprite out of it. imageToSprite :: SpriteScaling -> FilePath -> IO Sprite -- | Draw a sprite at the origin. sprite :: Sprite -> Drawing data Font -- | Load a TTF font from a file. openFont :: String -> Int -> IO Font -- | Draw a string using a font. The resulting string will have height 1. text :: Font -> String -> Drawing instance Monoid Drawing