helm-0.3.1: A functionally reactive game engine.

Safe HaskellNone

FRP.Helm.Graphics

Contents

Description

Contains all the data structures and functions for composing and rendering graphics.

Synopsis

Types

data Element Source

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.

Instances

data Text Source

A data structure describing a piece of formatted text.

Instances

data Form Source

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.

Constructors

Form 

Fields

theta :: Double
 
scalar :: Double
 
x :: Double
 
y :: Double
 
style :: FormStyle
 

Instances

data FormStyle Source

A data structure describing a few ways that graphics that can be wrapped in a form and hence transformed.

data FillStyle Source

A data structure describing how a shape or path looks when filled.

data LineCap Source

A data structure describing the shape of the ends of a line.

Constructors

Flat 
Round 
Padded 

data LineJoin Source

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.

Constructors

Smooth 
Sharp Double 
Clipped 

Instances

data LineStyle Source

A data structure describing how a shape or path looks when stroked.

Constructors

LineStyle 

type Path = [(Double, Double)]Source

A data type made up a collection of points that form a path when joined.

data Shape Source

A data structure describing a some sort of graphically representable object, such as a polygon formed from a set of points or a rectangle.

Instances

Elements

image :: Int -> Int -> FilePath -> ElementSource

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.

fittedImage :: Int -> Int -> FilePath -> ElementSource

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.

croppedImage :: (Int, Int) -> Int -> Int -> FilePath -> ElementSource

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.

collage :: Int -> Int -> [Form] -> ElementSource

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]

Styles & Forms

defaultLine :: LineStyleSource

Creates the default line style. By default, the line is black with a width of 1, flat caps and regular sharp joints.

solid :: Color -> LineStyleSource

Create a solid line style with a color.

dashed :: Color -> LineStyleSource

Create a dashed line style with a color.

dotted :: Color -> LineStyleSource

Create a dotted line style with a color.

filled :: Color -> Shape -> FormSource

Creates a form from a shape by filling it with a specific color.

textured :: String -> Shape -> FormSource

Creates a form from a shape with a tiled texture and image file path.

gradient :: Gradient -> Shape -> FormSource

Creates a form from a shape filled with a gradient.

outlined :: LineStyle -> Shape -> FormSource

Creates a form from a shape by outlining it with a specific line style.

traced :: LineStyle -> Path -> FormSource

Creates a form from a path by tracing it with a specific line style.

sprite :: Int -> Int -> (Int, Int) -> FilePath -> FormSource

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.

toForm :: Element -> FormSource

Creates a form from an element.

Grouping

group :: [Form] -> FormSource

Groups a collection of forms into a single one.

groupTransform :: Matrix -> [Form] -> FormSource

Groups a collection of forms into a single one, also applying a matrix transformation.

Transforming

rotate :: Double -> Form -> FormSource

Rotates a form by an amount (in radians).

scale :: Double -> Form -> FormSource

Scales a form by an amount, e.g. scaling by 2.0 will double the size.

move :: (Double, Double) -> Form -> FormSource

Moves a form relative to its current position.

moveX :: Double -> Form -> FormSource

Moves a form's x-coordinate relative to its current position.

moveY :: Double -> Form -> FormSource

Moves a form's y-coordinate relative to its current position.

Paths

path :: [(Double, Double)] -> PathSource

Creates a path for a collection of points.

segment :: (Double, Double) -> (Double, Double) -> PathSource

Creates a path from a line segment, i.e. a start and end point.

Shapes

polygon :: Path -> ShapeSource

Creates a shape from a path (a set of points).

rect :: Double -> Double -> ShapeSource

Creates a rectangular shape with a width and height.

square :: Double -> ShapeSource

Creates a square shape with a side length.

oval :: Double -> Double -> ShapeSource

Creates an oval shape with a width and height.

circle :: Double -> ShapeSource

Creates a circle shape with a radius.

ngon :: Int -> Double -> ShapeSource

Creates a generic n-sided polygon (e.g. octagon, pentagon, etc) with an amount of sides and radius.