Safe Haskell | None |
---|
Contains all the data structures and functions for composing and rendering graphics.
- data Element
- data FontWeight
- data FontStyle
- data Text = Text {}
- data Form = Form {}
- data FormStyle
- data FillStyle
- data LineCap
- data LineJoin
- = SmoothJoin
- | SharpJoin Double
- | ClippedJoin
- data LineStyle = LineStyle {}
- type Path = [(Double, Double)]
- data Shape
- image :: Int -> Int -> FilePath -> Element
- fittedImage :: Int -> Int -> FilePath -> Element
- croppedImage :: (Int, Int) -> Int -> Int -> FilePath -> Element
- collage :: Int -> Int -> [Form] -> Element
- centeredCollage :: Int -> Int -> [Form] -> Element
- fixedCollage :: Int -> Int -> (Double, Double) -> [Form] -> Element
- defaultLine :: LineStyle
- solid :: Color -> LineStyle
- dashed :: Color -> LineStyle
- dotted :: Color -> LineStyle
- filled :: Color -> Shape -> Form
- textured :: String -> Shape -> Form
- gradient :: Gradient -> Shape -> Form
- outlined :: LineStyle -> Shape -> Form
- traced :: LineStyle -> Path -> Form
- sprite :: Int -> Int -> (Int, Int) -> FilePath -> Form
- toForm :: Element -> Form
- blank :: Form
- group :: [Form] -> Form
- groupTransform :: Matrix -> [Form] -> Form
- rotate :: Double -> Form -> Form
- scale :: Double -> Form -> Form
- move :: (Double, Double) -> Form -> Form
- moveX :: Double -> Form -> Form
- moveY :: Double -> Form -> Form
- path :: [(Double, Double)] -> Path
- segment :: (Double, Double) -> (Double, Double) -> Path
- polygon :: Path -> Shape
- rect :: Double -> Double -> Shape
- square :: Double -> Shape
- oval :: Double -> Double -> Shape
- circle :: Double -> Shape
- ngon :: Int -> Double -> Shape
Types
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 FontWeight Source
A data structure describing the weight of a piece of font.
A data structure describing the style of of a piece of font.
A data structure describing a piece of formatted text.
Text | |
|
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.
A data structure describing a few ways that graphics that can be wrapped in a form and hence transformed.
A data structure describing how a shape or path looks when filled.
A data structure describing the shape of the ends of a line.
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.
A data structure describing how a shape or path looks when stroked.
type Path = [(Double, Double)]Source
A data type made up a collection of points that form a path when joined.
A data structure describing a some sort of graphically representable object, such as a polygon formed from a list of points or a rectangle.
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. All forms are centered and clipped within the supplied dimensions. It is generally 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]
centeredCollage :: Int -> Int -> [Form] -> ElementSource
Like collage
, but it centers the forms within the supplied dimensions.
fixedCollage :: Int -> Int -> (Double, Double) -> [Form] -> ElementSource
Like centeredCollage
, but it centers the forms around a specific point.
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.
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.
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.
Grouping
groupTransform :: Matrix -> [Form] -> FormSource
Groups a collection of forms into a single one, also applying a matrix transformation.
Transforming
scale :: Double -> Form -> FormSource
Scales a form by an amount, e.g. scaling by 2.0 will double the size.
Paths
segment :: (Double, Double) -> (Double, Double) -> PathSource
Creates a path from a line segment, i.e. a start and end point.