Gleam-0.1.0.1: HTML Canvas graphics, animations and simulations.

Safe HaskellNone
LanguageHaskell2010

Gleam

Contents

Synopsis

Documentation

play Source #

Arguments

:: GleamConfig

Canvas size.

-> model

Initial model for the simulation.

-> (model -> Picture)

Function to generate a picture from a model.

-> (model -> model)

Function to update the state of the simulation.

-> (InputEvent -> model -> model)

Function to handle input events.

-> IO () 

Run a simulation in a window. You decide how the model is represented, how to convert the model to a picture and how to update the model. This function does the rest. The simulation can be seen on `127.0.0.1:8023`

playMultiple :: [Simulation] -> IO () Source #

Run multiple simulations in a window. You decide how each model is represented, how to convert each model to a picture and how to update the model. This function does the rest. The simulations can be seen on `127.0.0.1:8023`

data Picture Source #

A 2D picture

Constructors

Blank

A blank picture, with nothing in it.

Line Path

A line along an arbitrary path.

Polygon Path

A polygon filled with a solid color.

Circle Double

A circle with the given radius.

Arc Double Double Double

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

Rectangle Double Double

A rectangle drawn with given width and height.

Image Source Double Double

Image to draw from a certain with given width and height.

Text String Font FontSize

Some text to draw with a vector font.

Color Color Picture

A picture drawn with this color.

Stroke Color Double Picture

A picture drawn with this stroke, given a color and size.

Translate Double Double Picture

A picture translated by the given x and y coordinates.

Scale Double Double Picture

A picture scaled by the given x and y factors.

Pictures [Picture]

A picture consisting of several others.

Instances

Eq Picture Source # 

Methods

(==) :: Picture -> Picture -> Bool

(/=) :: Picture -> Picture -> Bool

Show Picture Source # 

Methods

showsPrec :: Int -> Picture -> ShowS

show :: Picture -> String

showList :: [Picture] -> ShowS

Semigroup Picture Source # 

Methods

(<>) :: Picture -> Picture -> Picture

sconcat :: NonEmpty Picture -> Picture

stimes :: Integral b => b -> Picture -> Picture

Monoid Picture Source # 

type Point = (Double, Double) Source #

A point on the x-y plane.

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 Source Source #

An image location

Constructors

File String

Path to an image inside ./images.

Url String

An image url.

Instances

Eq Source Source # 

Methods

(==) :: Source -> Source -> Bool

(/=) :: Source -> Source -> Bool

Show Source Source # 

Methods

showsPrec :: Int -> Source -> ShowS

show :: Source -> String

showList :: [Source] -> ShowS

Compound shapes

lineLoop :: Path -> Picture Source #

A closed loop along a path.

sectorWire :: Double -> Double -> Double -> 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.

rectanglePath Source #

Arguments

:: Double

width of rectangle

-> Double

height of rectangle

-> Path 

A path representing a rectangle centered about the origin

rectangleWire :: Double -> Double -> Picture Source #

A wireframe rectangle centered about the origin.

rectangleSolid Source #

Arguments

:: Double

width of rectangle

-> Double

height of rectangle

-> Picture 

A solid rectangle centered about the origin.

convertColor :: Color -> String Source #

Converts a color to a html color string.

defaultGleamConfig :: GleamConfig Source #

The default config for Gleam