-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A functionally reactive game engine. -- -- A functionally reactive game engine, with headgear to protect you from -- the headache of game development provided. @package helm @version 0.3.1 -- | Contains signals that sample input from the game window. module FRP.Helm.Window -- | The current dimensions of the window. dimensions :: SignalGen (Signal (Int, Int)) -- | The current width of the window. width :: SignalGen (Signal Int) -- | The current height of the window. height :: SignalGen (Signal Int) -- | Contains signals that sample input from the mouse. module FRP.Helm.Mouse -- | A data structure describing a button on a mouse. data Mouse LeftMouse :: Mouse MiddleMouse :: Mouse RightMouse :: Mouse -- | The current state of a certain mouse button. True if the mouse is -- down, false otherwise. isDown :: Mouse -> SignalGen (Signal Bool) -- | The current position of the mouse. position :: SignalGen (Signal (Int, Int)) -- | The current x-coordinate of the mouse. x :: SignalGen (Signal Int) -- | The current y-coordinate of the mouse. y :: SignalGen (Signal Int) instance Show Mouse instance Eq Mouse instance Ord Mouse instance Enum Mouse -- | Contains signals that sample input from the keyboard. module FRP.Helm.Keyboard -- | A data structure describing a physical key on a keyboard. data Key BackspaceKey :: Key TabKey :: Key ClearKey :: Key EnterKey :: Key PauseKey :: Key EscapeKey :: Key SpaceKey :: Key ExclaimKey :: Key QuotedBlKey :: Key HashKey :: Key DollarKey :: Key AmpersandKey :: Key QuoteKey :: Key LeftParenKey :: Key RightParenKey :: Key AsteriskKey :: Key PlusKey :: Key CommaKey :: Key MinusKey :: Key PeriodKey :: Key SlashKey :: Key Num0Key :: Key Num1Key :: Key Num2Key :: Key Num3Key :: Key Num4Key :: Key Num5Key :: Key Num6Key :: Key Num7Key :: Key Num8Key :: Key Num9Key :: Key ColonKey :: Key SemicolonKey :: Key LessKey :: Key EqualsKey :: Key GreaterKey :: Key QuestionKey :: Key AtKey :: Key LeftBracketKey :: Key BackslashKey :: Key RightBracketKey :: Key CaretKey :: Key UnderscoreKey :: Key BackquoteKey :: Key AKey :: Key BKey :: Key CKey :: Key DKey :: Key EKey :: Key FKey :: Key GKey :: Key HKey :: Key IKey :: Key JKey :: Key KKey :: Key LKey :: Key MKey :: Key NKey :: Key OKey :: Key PKey :: Key QKey :: Key RKey :: Key SKey :: Key TKey :: Key UKey :: Key VKey :: Key WKey :: Key XKey :: Key YKey :: Key ZKey :: Key DeleteKey :: Key KeypadNum0Key :: Key KeypadNum1Key :: Key KeypadNum2Key :: Key KeypadNum3Key :: Key KeypadNum4Key :: Key KeypadNum5Key :: Key KeypadNum6Key :: Key KeypadNum7Key :: Key KeypadNum8Key :: Key KeypadNum9Key :: Key KeypadPeriodKey :: Key KeypadDivideKey :: Key KeypadMultiplyKey :: Key KeypadMinusKey :: Key KeypadPlusKey :: Key KeypadEnterKey :: Key KeypadEqualsKey :: Key UpKey :: Key DownKey :: Key RightKey :: Key LeftKey :: Key InsertKey :: Key HomeKey :: Key EndKey :: Key PageUpKey :: Key PageDownKey :: Key F1Key :: Key F2Key :: Key F3Key :: Key F4Key :: Key F5Key :: Key F6Key :: Key F7Key :: Key F8Key :: Key F9Key :: Key F10Key :: Key F11Key :: Key F12Key :: Key F13Key :: Key F14Key :: Key F15Key :: Key NumLockKey :: Key CapsLockKey :: Key ScrollLockKey :: Key RShiftKey :: Key LShiftKey :: Key RCtrlKey :: Key LCtrlKey :: Key RAltKey :: Key LAltKey :: Key RMetaKey :: Key LMetaKey :: Key RSuperKey :: Key LSuperKey :: Key ModeKey :: Key ComposeKey :: Key HelpKey :: Key PrintKey :: Key SysReqKey :: Key BreakKey :: Key MenuKey :: Key PowerKey :: Key EuroKey :: Key UndoKey :: Key -- | Whether either shift key is pressed. shift :: SignalGen (Signal Bool) -- | Whether either control key is pressed. ctrl :: SignalGen (Signal Bool) -- | Whether the enter (a.k.a. return) key is pressed. enter :: SignalGen (Signal Bool) -- | Whether the space key is pressed. space :: SignalGen (Signal Bool) -- | Whether a key is pressed. isDown :: Key -> SignalGen (Signal Bool) -- | A list of keys that are currently being pressed. keysDown :: SignalGen (Signal [Key]) -- | A directional tuple combined from the arrow keys. When none of the -- arrow keys are being pressed this signal samples to (0, 0), -- otherwise it samples to a direction based on which keys are pressed. -- For example, pressing the left key results in (-1, 0), the down -- key (0, 1), up and right (1, -1), etc. arrows :: SignalGen (Signal (Int, Int)) -- | Similar to the arrows signal, but uses the popular WASD -- movement controls instead. wasd :: SignalGen (Signal (Int, Int)) instance Show Key instance Eq Key instance Ord Key instance Enum Key -- | Contains signals that sample input from joysticks. module FRP.Helm.Joystick -- | A type describing a joystick. type Joystick = Joystick -- | The amount of joysticks available. available :: SignalGen (Signal Int) -- | The name of a joystick. name :: Int -> SignalGen (Signal String) -- | The joystick at a certain slot. open :: Int -> SignalGen (Signal Joystick) -- | The index of a joystick. index :: Joystick -> SignalGen (Signal Int) -- | The amount of axes available for a joystick. availableAxes :: Joystick -> SignalGen (Signal Int) -- | The amount of balls available for a joystick. availableBalls :: Joystick -> SignalGen (Signal Int) -- | The amount of hats available for a joystick. availableHats :: Joystick -> SignalGen (Signal Int) -- | The amount of buttons available for a joystick. availableButtons :: Joystick -> SignalGen (Signal Int) -- | The current state of the axis of the joystick. axis :: Joystick -> Int -> SignalGen (Signal Int) -- | The current state of the hat of the joystick, returned as a -- directional tuple. For example, up is (0, -1), left (-1, -- 0), bottom-right is (1, 1), etc. hat :: Joystick -> Int -> SignalGen (Signal (Int, Int)) -- | The current state of the button of the joystick. button :: Joystick -> Int -> SignalGen (Signal Bool) -- | The current state of the ball of the joystick. ball :: Joystick -> Int -> SignalGen (Signal (Int, Int)) -- | Contains all data structures and functions for composing, calculating -- and creating automatons. module FRP.Helm.Automaton -- | A data structure describing an automaton. An automaton is essentially -- a high-level way to package piped behavior between an input signal and -- an output signal. Automatons can also be composed, allowing you to -- connect one automaton to another and pipe data between them. -- Automatons are an easy and powerful way to create composable dynamic -- behavior, like animation systems. data Automaton a b Step :: (a -> (Automaton a b, b)) -> Automaton a b -- | Creates a pure automaton that has no accumulated state. It applies -- input to a function at each step. pure :: (a -> b) -> Automaton a b -- | Creates an automaton that has an initial and accumulated state. It -- applies input and the last state to a function at each step. stateful :: b -> (a -> b -> b) -> Automaton a b -- | Combines a list of automatons that take some input and turns it into -- an automaton that takes the same input and outputs a list of all -- outputs from each separate automaton. combine :: [Automaton a b] -> Automaton a [b] -- | Steps an automaton forward, returning the next automaton to step and -- output of the step in a tuple. step :: a -> Automaton a b -> (Automaton a b, b) -- | Runs an automaton with an initial output value and input signal -- generator and creates an output signal generator that contains a -- signal that can be sampled for the output value. run :: Automaton a b -> b -> SignalGen (Signal a) -> SignalGen (Signal b) -- | A useful automaton that outputs the amount of times it has been -- stepped, discarding its input value. counter :: Automaton a Int instance Arrow Automaton instance Category Automaton -- | Contains all data structures and functions for composing colors. module FRP.Helm.Color -- | A data structure describing a color. It is represented interally as an -- RGBA color, but the utility functions hsva, hsv, etc. -- can be used to convert from other popular formats to this structure. data Color Color :: !Double -> !Double -> !Double -> !Double -> Color r :: Color -> !Double g :: Color -> !Double b :: Color -> !Double a :: Color -> !Double -- | A data structure describing a gradient. There are two types of -- gradients: radial and linear. Radial gradients are based on a set of -- colors transitioned over certain radii in an arc pattern. Linear -- gradients are a set of colors transitioned in a straight line. data Gradient Linear :: (Double, Double) -> (Double, Double) -> [(Double, Color)] -> Gradient Radial :: (Double, Double) -> Double -> (Double, Double) -> Double -> [(Double, Color)] -> Gradient -- | Creates an RGB color, with transparency. rgba :: Double -> Double -> Double -> Double -> Color -- | Creates an RGB color. rgb :: Double -> Double -> Double -> Color -- | Create an RGBA color from HSVA values. hsva :: Double -> Double -> Double -> Double -> Color -- | Create an RGB color from HSV values. hsv :: Double -> Double -> Double -> Color -- | Calculate a complementary color for a provided color. Useful for -- outlining a filled shape in a color clearly distinguishable from the -- fill color. complement :: Color -> Color -- | Creates a linear gradient. Takes a starting position, ending position -- and a list of color stops (which are colors combined with a floating -- value between 0.0 and 1.0 that describes at what step -- along the line between the starting position and ending position the -- paired color should be transitioned to). -- --
-- linear (0, 0) (100, 100) [(0, black), (1, white)] ---- -- The above example creates a gradient that starts at (0, 0) and -- ends at (100, 100). In other words, it's a diagonal gradient, -- transitioning from the top-left to the bottom-right. The provided -- color stops result in the gradient transitioning from black to white. linear :: (Double, Double) -> (Double, Double) -> [(Double, Color)] -> Gradient -- | Creates a radial gradient. Takes a starting position and radius, -- ending position and radius and a list of color stops. See the document -- for linear for more information on color stops. radial :: (Double, Double) -> Double -> (Double, Double) -> Double -> [(Double, Color)] -> Gradient -- | A bright red color. red :: Color -- | A bright green color. lime :: Color -- | A bright blue color. blue :: Color -- | A yellow color, made from combining red and green. yellow :: Color -- | A cyan color, combined from bright green and blue. cyan :: Color -- | A magenta color, combined from bright red and blue. magenta :: Color -- | A black color. black :: Color -- | A white color. white :: Color -- | A gray color, exactly halfway between black and white. gray :: Color -- | Common alternative spelling of gray. grey :: Color -- | A medium red color. maroon :: Color -- | A medium blue color. navy :: Color -- | A medium green color. green :: Color -- | A teal color, combined from medium green and blue. teal :: Color -- | A purple color, combined from medium red and blue. purple :: Color -- | A violet color. violet :: Color -- | A dark green color. forestGreen :: Color instance Show Color instance Eq Color instance Show Gradient instance Eq Gradient -- | Contains all the data structures and functions for composing and -- rendering graphics. module FRP.Helm.Graphics -- | A data structure describing something that can be rendered to the -- screen. Elements are the most important structure in Helm. Games -- essentially feed the engine a stream of elements which are then -- rendered directly to the screen. The usual way to render art in a Helm -- game is to call off to the collage function, which essentially -- renders a collection of forms together. data Element CollageElement :: Int -> Int -> [Form] -> Element ImageElement :: (Int, Int) -> Int -> Int -> FilePath -> Bool -> Element TextElement :: Text -> Element -- | A data structure describing a piece of formatted text. data Text Text :: String -> Color -> String -> Double -> FontWeight -> FontSlant -> Text textUTF8 :: Text -> String textColor :: Text -> Color fontTypeface :: Text -> String fontSize :: Text -> Double fontWeight :: Text -> FontWeight fontSlant :: Text -> FontSlant -- | A data structure describing a form. A form is essentially a notion of -- a transformed graphic, whether it be an element or shape. See -- FormStyle for an insight into what sort of graphics can be -- wrapped in a form. data Form Form :: Double -> Double -> Double -> Double -> FormStyle -> Form theta :: Form -> Double scalar :: Form -> Double x :: Form -> Double y :: Form -> Double style :: Form -> FormStyle -- | A data structure describing a few ways that graphics that can be -- wrapped in a form and hence transformed. data FormStyle PathForm :: LineStyle -> Path -> FormStyle ShapeForm :: (Either LineStyle FillStyle) -> Shape -> FormStyle ElementForm :: Element -> FormStyle GroupForm :: Matrix -> [Form] -> FormStyle -- | A data structure describing how a shape or path looks when filled. data FillStyle Solid :: Color -> FillStyle Texture :: String -> FillStyle Gradient :: Gradient -> FillStyle -- | A data structure describing the shape of the ends of a line. data LineCap Flat :: LineCap Round :: LineCap Padded :: LineCap -- | A data structure describing the shape of the join of a line, i.e. -- where separate line segments join. The Sharp variant takes an -- argument to limit the length of the join. data LineJoin Smooth :: LineJoin Sharp :: Double -> LineJoin Clipped :: LineJoin -- | A data structure describing how a shape or path looks when stroked. data LineStyle LineStyle :: Color -> Double -> LineCap -> LineJoin -> [Double] -> Double -> LineStyle color :: LineStyle -> Color width :: LineStyle -> Double cap :: LineStyle -> LineCap join :: LineStyle -> LineJoin dashing :: LineStyle -> [Double] dashOffset :: LineStyle -> Double -- | A data type made up a collection of points that form a path when -- joined. type Path = [(Double, Double)] -- | A data structure describing a some sort of graphically representable -- object, such as a polygon formed from a set of points or a rectangle. data Shape PolygonShape :: Path -> Shape RectangleShape :: (Double, Double) -> Shape ArcShape :: (Double, Double) -> Double -> Double -> Double -> (Double, Double) -> Shape -- | Create an element from an image with a given width, height and image -- file path. If the image dimensions are not the same as given, then it -- will stretch/shrink to fit. Only PNG files are supported currently. image :: Int -> Int -> FilePath -> Element -- | Create an element from an image with a given width, height and image -- file path. If the image dimensions are not the same as given, then it -- will only use the relevant pixels (i.e. cut out the given dimensions -- instead of scaling). If the given dimensions are bigger than the -- actual image, than irrelevant pixels are ignored. fittedImage :: Int -> Int -> FilePath -> Element -- | Create an element from an image by cropping it with a certain -- position, width, height and image file path. This can be used to -- divide a single image up into smaller ones. croppedImage :: (Int, Int) -> Int -> Int -> FilePath -> Element -- | Create an element from a collection of forms, with width and height -- arguments. Can be used to directly render a collection of forms. -- --
-- collage 800 600 [move (100, 100) $ filled red $ square 100, -- move (100, 100) $ outlined (solid white) $ circle 50] --collage :: Int -> Int -> [Form] -> Element -- | Creates the default line style. By default, the line is black with a -- width of 1, flat caps and regular sharp joints. defaultLine :: LineStyle -- | Create a solid line style with a color. solid :: Color -> LineStyle -- | Create a dashed line style with a color. dashed :: Color -> LineStyle -- | Create a dotted line style with a color. dotted :: Color -> LineStyle -- | Creates a form from a shape by filling it with a specific color. filled :: Color -> Shape -> Form -- | Creates a form from a shape with a tiled texture and image file path. textured :: String -> Shape -> Form -- | Creates a form from a shape filled with a gradient. gradient :: Gradient -> Shape -> Form -- | Creates a form from a shape by outlining it with a specific line -- style. outlined :: LineStyle -> Shape -> Form -- | Creates a form from a path by tracing it with a specific line style. traced :: LineStyle -> Path -> Form -- | Creates a form from a image file path with additional position, width -- and height arguments. Allows you to splice smaller parts from a single -- image. sprite :: Int -> Int -> (Int, Int) -> FilePath -> Form -- | Creates a form from an element. toForm :: Element -> Form -- | Groups a collection of forms into a single one. group :: [Form] -> Form -- | Groups a collection of forms into a single one, also applying a matrix -- transformation. groupTransform :: Matrix -> [Form] -> Form -- | Rotates a form by an amount (in radians). rotate :: Double -> Form -> Form -- | Scales a form by an amount, e.g. scaling by 2.0 will double the -- size. scale :: Double -> Form -> Form -- | Moves a form relative to its current position. move :: (Double, Double) -> Form -> Form -- | Moves a form's x-coordinate relative to its current position. moveX :: Double -> Form -> Form -- | Moves a form's y-coordinate relative to its current position. moveY :: Double -> Form -> Form -- | Creates a path for a collection of points. path :: [(Double, Double)] -> Path -- | Creates a path from a line segment, i.e. a start and end point. segment :: (Double, Double) -> (Double, Double) -> Path -- | Creates a shape from a path (a set of points). polygon :: Path -> Shape -- | Creates a rectangular shape with a width and height. rect :: Double -> Double -> Shape -- | Creates a square shape with a side length. square :: Double -> Shape -- | Creates an oval shape with a width and height. oval :: Double -> Double -> Shape -- | Creates a circle shape with a radius. circle :: Double -> Shape -- | Creates a generic n-sided polygon (e.g. octagon, pentagon, etc) with -- an amount of sides and radius. ngon :: Int -> Double -> Shape instance Show Text instance Eq Text instance Show FillStyle instance Eq FillStyle instance Show LineCap instance Eq LineCap instance Enum LineCap instance Ord LineCap instance Show LineJoin instance Eq LineJoin instance Show LineStyle instance Eq LineStyle instance Show Shape instance Eq Shape instance Show FormStyle instance Eq FormStyle instance Show Form instance Eq Form instance Show Element instance Eq Element -- | Contains all the data structures and functions for composing pieces of -- formatted text. module FRP.Helm.Text -- | Creates a text element from a string. plainText :: String -> Element -- | Creates a text element from any showable type, defaulting to the -- monospace typeface. asText :: Show a => a -> Element -- | Creates an element from a text. text :: Text -> Element -- | Creates the default text. By default the text is black sans-serif with -- a height of 14px. defaultText :: Text -- | Creates a text from a string. toText :: String -> Text -- | Sets the weight of a piece of text to bold. bold :: Text -> Text -- | Sets the slant of a piece of text to italic. italic :: Text -> Text -- | Sets the color of a piece of text. color :: Color -> Text -> Text -- | Sets the typeface of the text to monospace. monospace :: Text -> Text -- | Sets the typeface of the text. Only fonts supported by Cairo's toy -- font API are currently supported. typeface :: String -> Text -> Text -- | Sets the size of a text noticeably large. header :: Text -> Text -- | Sets the size of a piece of text. height :: Double -> Text -> Text -- | Contains miscellaneous utility functions and the main functions for -- interfacing with the engine. module FRP.Helm -- | Initializes and runs the game engine. The supplied signal generator is -- constantly sampled for an element to render until the user quits. -- --
-- import FRP.Helm -- import qualified FRP.Helm.Window as Window -- -- render :: (Int, Int) -> Element -- render (w, h) = collage w h [filled red $ rect (fromIntegral w) (fromIntegral h)] -- -- main :: IO () -- main = run $ do -- dims <- Window.dimensions -- -- return $ fmap render dims --run :: SignalGen (Signal Element) -> IO () -- | Converts radians into the standard angle measurement (radians). radians :: Double -> Double -- | Converts degrees into the standard angle measurement (radians). degrees :: Double -> Double -- | Converts turns into the standard angle measurement (radians). Turns -- are essentially full revolutions of the unit circle. turns :: Double -> Double