Safe Haskell | None |
---|---|
Language | Haskell2010 |
A picture in gelatin's context is a collection of vertices, organized into geometries of triangles, beziers, triangle strips, triangle fans and polylines. The vertices of these pictures can be anything, but the currently available backends already support these vertices:
(V2 Float, V4 Float)
, ie. colored points in 2d space(V2 Float, V2 Float)
, ie. textured points in 2d space
- newtype VerticesT a m b = Vertices {
- unVertices :: StateT (Vector a) m b
- runVerticesT :: (Monad m, Unbox a) => VerticesT a m b -> m (Vector a)
- type Vertices a = VerticesT a Identity ()
- runVertices :: Unbox a => Vertices a -> Vector a
- tri :: (Monad m, Unbox a) => a -> a -> a -> VerticesT a m ()
- bez :: (Monad m, Unbox a) => a -> a -> a -> VerticesT a m ()
- to :: (Monad m, Unbox a) => a -> VerticesT a m ()
- addVertexList :: (Monad m, Unbox a) => [a] -> VerticesT a m ()
- segment :: (Monad m, Unbox a) => a -> a -> VerticesT a m ()
- mapVertices :: (Monad m, Unbox a, Unbox c) => (a -> c) -> VerticesT a m b -> VerticesT c m ()
- data RawGeometry a
- = RawTriangles (Vector a)
- | RawBeziers (Vector a)
- | RawTriangleStrip (Vector a)
- | RawTriangleFan (Vector a)
- | RawLine (Vector a)
- mapRawGeometry :: (Unbox a, Unbox b) => (a -> b) -> RawGeometry a -> RawGeometry b
- newtype GeometryT a m b = Geometry {
- unGeometry :: StateT (Vector (RawGeometry a)) m b
- runGeometryT :: Monad m => GeometryT a m b -> m (Vector (RawGeometry a))
- type Geometry a = GeometryT a Identity ()
- runGeometry :: Geometry a -> Vector (RawGeometry a)
- triangles :: (Unbox a, Monad m) => VerticesT a m () -> GeometryT a m ()
- beziers :: (Monad m, Unbox a) => VerticesT a m () -> GeometryT a m ()
- strip :: (Monad m, Unbox a) => VerticesT a m () -> GeometryT a m ()
- fan :: (Monad m, Unbox a) => VerticesT a m () -> GeometryT a m ()
- line :: (Monad m, Unbox a) => VerticesT a m () -> GeometryT a m ()
- mapGeometry :: (Monad m, Unbox a, Unbox c) => (a -> c) -> GeometryT a m b -> GeometryT c m ()
- type PictureT tex vert = StateT (PictureData tex vert)
- runPictureT :: PictureT t v m a -> m (a, PictureData t v)
- type Picture t v = PictureT t v Identity
- runPicture :: Picture t v a -> (a, PictureData t v)
- setRawGeometry :: Monad m => Vector (RawGeometry v) -> PictureT t v m ()
- getRawGeometry :: Monad m => PictureT t v m (Vector (RawGeometry v))
- setGeometry :: Monad m => GeometryT v m () -> PictureT t v m ()
- setStroke :: Monad m => [StrokeAttr] -> PictureT t v m ()
- getStroke :: Monad m => PictureT t v m [StrokeAttr]
- setTextures :: Monad m => [t] -> PictureT t v m ()
- getTextures :: Monad m => PictureT t v m [t]
- setRenderingOptions :: Monad m => [RenderingOption] -> PictureT t v m ()
- getRenderingOptions :: Monad m => PictureT t v m [RenderingOption]
- mapPictureVertices :: (Monad m, Unbox v, Unbox s) => (v -> s) -> PictureT t v m (Vector s)
- pictureBounds2 :: (Monad m, Unbox v) => (v -> V2 Float) -> PictureT t v m (V2 Float, V2 Float)
- pictureSize2 :: (Monad m, Unbox v) => (v -> V2 Float) -> PictureT t v m (V2 Float)
- pictureOrigin2 :: (Monad m, Unbox v) => (v -> V2 Float) -> PictureT t v m (V2 Float)
- pictureCenter2 :: (Monad m, Unbox v) => (v -> V2 Float) -> PictureT t v m (V2 Float)
- pictureBounds3 :: (Monad m, Unbox v) => (v -> V3 Float) -> PictureT t v m BCube
- pictureSize3 :: (Monad m, Unbox v) => (v -> V3 Float) -> PictureT t v m (V3 Float)
- pictureOrigin3 :: (Monad m, Unbox v) => (v -> V3 Float) -> PictureT t v m (V3 Float)
- pictureCenter3 :: (Monad m, Unbox v) => (v -> V3 Float) -> PictureT t v m (V3 Float)
- data RenderingOption = StencilMaskOption
- data PictureData texture vertex = PictureData {
- _picDataGeometry :: Vector (RawGeometry vertex)
- _picDataStroke :: [StrokeAttr]
- _picDataTextures :: [texture]
- _picDataOptions :: [RenderingOption]
Defining Vertex Data
newtype VerticesT a m b Source #
A monad transformer for defining geometry.
Vertices | |
|
runVerticesT :: (Monad m, Unbox a) => VerticesT a m b -> m (Vector a) Source #
Extract the raw Vector
of vertices monadically.
bez :: (Monad m, Unbox a) => a -> a -> a -> VerticesT a m () Source #
Add a bezier of vertices.
This is an alias of tri
but looks better in the context
of drawing beziers.
mapVertices :: (Monad m, Unbox a, Unbox c) => (a -> c) -> VerticesT a m b -> VerticesT c m () Source #
Map all the vertices in the computation.
Defining Geometry (Vertex Data + Drawing Operation)
data RawGeometry a Source #
Mixed drawing types roughly corresponding to OpenGL's draw modes.
RawTriangles (Vector a) | A collection of points known to be triangles. |
RawBeziers (Vector a) | A collection of points known to be beziers. |
RawTriangleStrip (Vector a) | A collection of points known to be a triangle strip. |
RawTriangleFan (Vector a) | A collection of points known to be a triangle fan. |
RawLine (Vector a) | A collection of points known to be a polyline. *Note* that in the future polylines will be expressed in terms of the other constructors. |
mapRawGeometry :: (Unbox a, Unbox b) => (a -> b) -> RawGeometry a -> RawGeometry b Source #
Map all the vertices within a RawGeometry
.
newtype GeometryT a m b Source #
A monad transformer for defining collections of geometries, specifically mixed collections of triangles, beziers, strips, fans and polylines.
Geometry | |
|
runGeometryT :: Monad m => GeometryT a m b -> m (Vector (RawGeometry a)) Source #
Extract the raw Vector
of geometries monadically.
type Geometry a = GeometryT a Identity () Source #
A pure context for defining collections of geometry.
runGeometry :: Geometry a -> Vector (RawGeometry a) Source #
Extract the raw Vector
of geometries.
triangles :: (Unbox a, Monad m) => VerticesT a m () -> GeometryT a m () Source #
Define and add some triangles.
beziers :: (Monad m, Unbox a) => VerticesT a m () -> GeometryT a m () Source #
Define and add some beziers.
strip :: (Monad m, Unbox a) => VerticesT a m () -> GeometryT a m () Source #
Define and add a triangle strip.
fan :: (Monad m, Unbox a) => VerticesT a m () -> GeometryT a m () Source #
Define and add a triangle fan.
line :: (Monad m, Unbox a) => VerticesT a m () -> GeometryT a m () Source #
Define and add a polyline.
mapGeometry :: (Monad m, Unbox a, Unbox c) => (a -> c) -> GeometryT a m b -> GeometryT c m () Source #
Map all the vertices within all geometries in the computation.
The Picture API
type PictureT tex vert = StateT (PictureData tex vert) Source #
A monad transformer computation that defines a picture.
runPictureT :: PictureT t v m a -> m (a, PictureData t v) Source #
Extract the result and PictureData
from a PictureT
computation.
runPicture :: Picture t v a -> (a, PictureData t v) Source #
Extract the result and PictureData
of a pure Picture
computation.
setRawGeometry :: Monad m => Vector (RawGeometry v) -> PictureT t v m () Source #
getRawGeometry :: Monad m => PictureT t v m (Vector (RawGeometry v)) Source #
setGeometry :: Monad m => GeometryT v m () -> PictureT t v m () Source #
Define and set the geometries of the PictureT
.
setStroke :: Monad m => [StrokeAttr] -> PictureT t v m () Source #
Set the stroke attributes of the PictureT
.
getStroke :: Monad m => PictureT t v m [StrokeAttr] Source #
Get the current stroke attributes of the PictureT
.
setTextures :: Monad m => [t] -> PictureT t v m () Source #
Set the textures contained within the PictureT
.
These textures [t]
are backend dependent.
setRenderingOptions :: Monad m => [RenderingOption] -> PictureT t v m () Source #
Set any special rendering options. Nothing to see here.
getRenderingOptions :: Monad m => PictureT t v m [RenderingOption] Source #
Get any special rendering options. Nothing to see here.
An example of creating a Picture
Here is an example of drawing two colored beziers into a 2d picture using
colors from the Color
module:
bezierPicture :: Picture tex (V2 Float, V4 Float) () bezierPicture = setGeometry $ beziers $ do bez (V2 0 0, white) (V2 200 0, blue) (V2 200 200, green) bez (V2 400 200, white) (V2 400 0, blue) (V2 200 0, green)
Here is the rendering of that picture after being compiled by a backend:
As you can see the two beziers have different fill directions, the first is fill inner while the second is fill outer. This is determined by the bezier's winding.
Measuring Pictures (2d)
mapPictureVertices :: (Monad m, Unbox v, Unbox s) => (v -> s) -> PictureT t v m (Vector s) Source #
Evaluates the current geometry in the PictureT
, mapping each vertex.
pictureBounds2 :: (Monad m, Unbox v) => (v -> V2 Float) -> PictureT t v m (V2 Float, V2 Float) Source #
Determines the bounds of a PictureT
defined in 2d space.
pictureSize2 :: (Monad m, Unbox v) => (v -> V2 Float) -> PictureT t v m (V2 Float) Source #
Determines the size of a PictureT
defined in 2d space.
pictureOrigin2 :: (Monad m, Unbox v) => (v -> V2 Float) -> PictureT t v m (V2 Float) Source #
Determines the origin of a PictureT
defined in 2d space.
pictureCenter2 :: (Monad m, Unbox v) => (v -> V2 Float) -> PictureT t v m (V2 Float) Source #
Determines the center point of a PictureT
defined in 2d space.
Measuring Pictures (3d)
pictureBounds3 :: (Monad m, Unbox v) => (v -> V3 Float) -> PictureT t v m BCube Source #
Determines the bounds of a PictureT
defined in 3d space.
pictureSize3 :: (Monad m, Unbox v) => (v -> V3 Float) -> PictureT t v m (V3 Float) Source #
Determines the size of a PictureT
defined in 3d space.
pictureOrigin3 :: (Monad m, Unbox v) => (v -> V3 Float) -> PictureT t v m (V3 Float) Source #
Determines the origin of a PictureT
defined in 3d space.
pictureCenter3 :: (Monad m, Unbox v) => (v -> V3 Float) -> PictureT t v m (V3 Float) Source #
Determines the center point of a PictureT
defined in 3d space.
Underlying PictureData Exported for renderers
data PictureData texture vertex Source #
Underlying picture data used to accumulate a visible picture.
PictureData | |
|