gloss-1.7.8.3: Painless 2D vector graphics, animations and simulations.

Safe Haskell | None

Graphics.Gloss.Data.Picture

Contents

- Aliases for Picture constructors
- Compound shapes
- Loading Bitmaps

Description

Data types for representing pictures.

Synopsis

- type Point = (Float, Float)
- type Vector = Point
- type Path = [Point]
- data Picture
  - = Blank
  - | Polygon Path
  - | Line Path
  - | Circle Float
  - | ThickCircle Float Float
  - | Arc Float Float Float
  - | ThickArc Float Float Float Float
  - | Text String
  - | Bitmap Int Int BitmapData Bool
  - | Color Color Picture
  - | Translate Float Float Picture
  - | Rotate Float Picture
  - | Scale Float Float Picture
  - | Pictures [Picture]
- data BitmapData
- blank :: Picture
- polygon :: Path -> Picture
- line :: Path -> Picture
- circle :: Float -> Picture
- thickCircle :: Float -> Float -> Picture
- arc :: Float -> Float -> Float -> Picture
- thickArc :: Float -> Float -> Float -> Float -> Picture
- text :: String -> Picture
- bitmap :: Int -> Int -> BitmapData -> Bool -> Picture
- color :: Color -> Picture -> Picture
- translate :: Float -> Float -> Picture -> Picture
- rotate :: Float -> Picture -> Picture
- scale :: Float -> Float -> Picture -> Picture
- pictures :: [Picture] -> Picture
- lineLoop :: Path -> Picture
- circleSolid :: Float -> Picture
- arcSolid :: Float -> Float -> Float -> Picture
- sectorWire :: Float -> Float -> Float -> Picture
- rectanglePath :: Float -> Float -> Path
- rectangleWire :: Float -> Float -> Picture
- rectangleSolid :: Float -> Float -> Picture
- rectangleUpperPath :: Float -> Float -> Path
- rectangleUpperWire :: Float -> Float -> Picture
- rectangleUpperSolid :: Float -> Float -> Picture
- bitmapOfForeignPtr :: Int -> Int -> ForeignPtr Word8 -> Bool -> Picture
- bitmapOfByteString :: Int -> Int -> ByteString -> Bool -> Picture
- bitmapOfBMP :: BMP -> Picture
- loadBMP :: FilePath -> IO Picture

# Documentation

type Point = (Float, Float)Source

A point on the x-y plane. Points can also be treated as `Vector`s, so Graphics.Gloss.Data.Vector may also be useful.

type Vector = Point Source

A vector can be treated as a point, and vis-versa.

type Path = [Point]Source

A path through the x-y plane.

data Picture Source

A 2D picture

Constructors

Blank | A blank picture, with nothing in it.
Polygon Path | A convex polygon filled with a solid color.
Line Path | A line along an arbitrary path.
Circle Float | A circle with the given radius.
ThickCircle Float Float | A circle with the given thickness and radius. If the thickness is 0 then this is equivalent to `Circle`.
Arc Float Float Float | A circular arc drawn counter-clockwise between two angles (in degrees) at the given radius.
ThickArc Float Float Float Float | A circular arc drawn counter-clockwise between two angles (in degrees), with the given radius and thickness. If the thickness is 0 then this is equivalent to `Arc`.
Text String | Some text to draw with a vector font.
Bitmap Int Int BitmapData Bool | A bitmap image with a width, height and some 32-bit RGBA bitmap data. The boolean flag controls whether Gloss should cache the data between frames for speed. If you are programatically generating the image for each frame then use `False`. If you have loaded it from a file then use `True`.
Color Color Picture | A picture drawn with this color.
Translate Float Float Picture | A picture translated by the given x and y coordinates.
Rotate Float Picture | A picture rotated clockwise by the given angle (in degrees).
Scale Float Float Picture | A picture scaled by the given x and y factors.
Pictures [Picture] | A picture consisting of several others.

Instances

Eq Picture |
Show Picture |
Monoid Picture |

data BitmapData Source

Abstract 32-bit RGBA bitmap data.

Instances

Eq BitmapData |
Show BitmapData |

# Aliases for Picture constructors

blank :: Picture Source

A blank picture, with nothing in it.

polygon :: Path -> Picture Source

A convex polygon filled with a solid color.

line :: Path -> Picture Source

A line along an arbitrary path.

circle :: Float -> Picture Source

A circle with the given radius.

thickCircle :: Float -> Float -> Picture Source

A circle with the given thickness and radius. If the thickness is 0 then this is equivalent to `Circle`.

arc :: Float -> Float -> Float -> Picture Source

A circular arc drawn counter-clockwise between two angles (in degrees) at the given radius.

thickArc :: Float -> Float -> Float -> Float -> Picture Source

A circular arc drawn counter-clockwise between two angles (in degrees), with the given radius and thickness. If the thickness is 0 then this is equivalent to `Arc`.

text :: String -> Picture Source

Some text to draw with a vector font.

bitmap :: Int -> Int -> BitmapData -> Bool -> Picture Source

A bitmap image with a width, height and a Vector holding the 32-bit RGBA bitmap data.

The boolean flag controls whether Gloss should cache the data between frames for speed. If you are programatically generating the image for each frame then use `False`. If you have loaded it from a file then use `True`.

color :: Color -> Picture -> Picture Source

A picture drawn with this color.

translate :: Float -> Float -> Picture -> Picture Source

A picture translated by the given x and y coordinates.

rotate :: Float -> Picture -> Picture Source

A picture rotated clockwise by the given angle (in degrees).

scale :: Float -> Float -> Picture -> Picture Source

A picture scaled by the given x and y factors.

pictures :: [Picture] -> Picture Source

A picture consisting of several others.

# Compound shapes

lineLoop :: Path -> Picture Source

A closed loop along a path.

circleSolid :: Float -> Picture Source

A solid circle with the given radius.

arcSolid :: Float -> Float -> Float -> Picture Source

A solid arc, drawn counter-clockwise between two angles at the given radius.

sectorWire :: Float -> Float -> Float -> Picture Source

A wireframe sector of a circle. An arc is draw counter-clockwise from the first to the second angle at the given radius. Lines are drawn from the origin to the ends of the arc.

rectanglePath Source

Arguments

:: Float | width of rectangle
-> Float | height of rectangle
-> Path |

A path representing a rectangle centered about the origin

rectangleWire :: Float -> Float -> Picture Source

A wireframe rectangle centered about the origin.

rectangleSolid :: Float -> Float -> Picture Source

A solid rectangle centered about the origin.

rectangleUpperPath :: Float -> Float -> Path Source

A path representing a rectangle in the y > 0 half of the x-y plane.

rectangleUpperWire :: Float -> Float -> Picture Source

A wireframe rectangle in the y > 0 half of the x-y plane.

rectangleUpperSolid :: Float -> Float -> Picture Source

A solid rectangle in the y > 0 half of the x-y plane.

# Loading Bitmaps

bitmapOfForeignPtr :: Int -> Int -> ForeignPtr Word8 -> Bool -> Picture Source

O(1). Use a `ForeignPtr` of RGBA data as a bitmap with the given width and height.

bitmapOfByteString :: Int -> Int -> ByteString -> Bool -> Picture Source

O(size). Copy a `ByteString` of RGBA data into a bitmap with the given width and height.

The boolean flag controls whether Gloss should cache the data between frames for speed. If you are programatically generating the image for each frame then use `False`. If you have loaded it from a file then use `True`.

bitmapOfBMP :: BMP -> Picture Source

O(size). Copy a `BMP` file into a bitmap.

loadBMP :: FilePath -> IO Picture Source

Load an uncompressed 24 or 32bit RGBA BMP file as a bitmap.