sdl2-gfx-0.2: Bindings to SDL2_gfx.

Copyright(c) 2015 Siniša Biđin
LicenseMIT
Maintainersinisa@bidin.eu
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

SDL.Primitive

Contents

Description

Bindings to SDL2_gfx's primitives drawing functionality. These functions should allow you to render various simple shapes such as lines, ellipses or polygons.

All of the monadic functions within this module are capable of throwing an SDLException if they encounter an error.

Synopsis

Pixels

type Pos = V2 CInt Source #

A position as a two-dimensional vector.

type Color = V4 Word8 Source #

A color as an RGBA byte-vector.

pixel :: MonadIO m => Renderer -> Pos -> Color -> m () Source #

Renders a single pixel at a given position.

Lines

line :: MonadIO m => Renderer -> Pos -> Pos -> Color -> m () Source #

Renders a line between two points.

type Length = CInt Source #

A length in pixels.

horizontalLine :: MonadIO m => Renderer -> Pos -> Length -> Color -> m () Source #

Renders a horizontal line of a certain Length, its left and starting point corresponding to a given Pos.

verticalLine :: MonadIO m => Renderer -> Pos -> Length -> Color -> m () Source #

Renders a vertical line of a certain Length, its top and starting point corresponding to a given Pos.

smoothLine :: MonadIO m => Renderer -> Pos -> Pos -> Color -> m () Source #

Renders an anti-aliased line between two points.

type Width = CInt Source #

A width in pixels.

thickLine :: MonadIO m => Renderer -> Pos -> Pos -> Width -> Color -> m () Source #

Same as line, but the rendered line is of a given Width.

Triangles

triangle :: MonadIO m => Renderer -> Pos -> Pos -> Pos -> Color -> m () Source #

Render a transparent triangle, its edges being of a given Color.

smoothTriangle :: MonadIO m => Renderer -> Pos -> Pos -> Pos -> Color -> m () Source #

Same as triangle, but the edges are anti-aliased.

fillTriangle :: MonadIO m => Renderer -> Pos -> Pos -> Pos -> Color -> m () Source #

Same as triangle, but the triangle is filled with the given Color instead.

Rectangles

rectangle :: MonadIO m => Renderer -> Pos -> Pos -> Color -> m () Source #

Renders a transparent rectangle spanning two points, bordered by a line of a given Color.

type Radius = CInt Source #

A radius in pixels.

roundRectangle :: MonadIO m => Renderer -> Pos -> Pos -> Radius -> Color -> m () Source #

Same as rectangle, but the rectangle's corners are rounded.

Control the roundness using the Radius argument, defining the radius of the corner arcs.

fillRectangle :: MonadIO m => Renderer -> Pos -> Pos -> Color -> m () Source #

Same as rectangle, but the rectangle is filled by the given Color.

fillRoundRectangle :: MonadIO m => Renderer -> Pos -> Pos -> Radius -> Color -> m () Source #

Same as roundRectangle, but the rectangle is filled by the given Color.

Curves

type Start = CInt Source #

A starting position in degrees.

type End = CInt Source #

An ending position in degrees.

arc :: MonadIO m => Renderer -> Pos -> Radius -> Start -> End -> Color -> m () Source #

Render an arc, its Pos being its center.

The Start and End arguments define the starting and ending points of the arc in degrees, zero degrees being south and increasing counterclockwise.

circle :: MonadIO m => Renderer -> Pos -> Radius -> Color -> m () Source #

Renders a transparent circle, bordered by a line of a given Color.

smoothCircle :: MonadIO m => Renderer -> Pos -> Radius -> Color -> m () Source #

Same as circle, but the border is anti-aliased.

fillCircle :: MonadIO m => Renderer -> Pos -> Radius -> Color -> m () Source #

Same as circle, but fills it with the given Color instead.

ellipse :: MonadIO m => Renderer -> Pos -> Radius -> Radius -> Color -> m () Source #

Renders a transparent ellipse, bordered by a line of a given Color.

The Radius arguments are the horizontal and vertical radius of the ellipse respectively, in pixels.

smoothEllipse :: MonadIO m => Renderer -> Pos -> Radius -> Radius -> Color -> m () Source #

Same as ellipse, but makes the border anti-aliased.

fillEllipse :: MonadIO m => Renderer -> Pos -> Radius -> Radius -> Color -> m () Source #

Same as ellipse, but fills it with the given Color instead.

pie :: MonadIO m => Renderer -> Pos -> Radius -> Start -> End -> Color -> m () Source #

Render a pie outline, its Pos being its center.

The Start and End arguments define the starting and ending points of the pie in degrees, zero degrees being east and increasing counterclockwise.

fillPie :: MonadIO m => Renderer -> Pos -> Radius -> Start -> End -> Color -> m () Source #

Same as pie, but fills it with the given Color instead.

type Steps = CInt Source #

How many interpolation steps when rendering a bezier curve?

The higher this is, the smoother the curve and more resource-intensive the render.

bezier :: MonadIO m => Renderer -> Vector Int16 -> Vector Int16 -> Steps -> Color -> m () Source #

Renders a bezier curve of a given Color.

The input vectors contain the bezier curve's point locations on the x and y-axis, respectively. The input vectors need to be the same length, and those lengths must be at least 3, otherwise bezier might raise an SDLException. The same applies for the number of interpolation Steps: it must be at least 2.

Polygons

polygon :: MonadIO m => Renderer -> Vector Int16 -> Vector Int16 -> Color -> m () Source #

Render a transparent polygon, its edges of a given Color.

The input vectors contain the points' locations on the x and y-axis, respectively. The input vectors need to be the of the same length, and the lengths must be at least 3, otherwise polygon might raise an SDLException.

smoothPolygon :: MonadIO m => Renderer -> Vector Int16 -> Vector Int16 -> Color -> m () Source #

Same as polygon, but the edges are drawn anti-aliased.

fillPolygon :: MonadIO m => Renderer -> Vector Int16 -> Vector Int16 -> Color -> m () Source #

Same as polygon, but the polygon is filled with the given Color.