frawa / elm-contour / Contour

This library calculate contour level lines for a two-dimensional scalar field, based on the Marching Squares algorithm https://en.wikipedia.org/wiki/Marching_squares.

Definition of a two-dimensional scalar field


type alias GridFunction =
Internal.GridFunction

Represent a two-dimensioal scalar field

gridFunction : Grid -> (Point -> Basics.Float) -> GridFunction

Construct a two-dimensial scalar field from a function

    f : (Float,Float) -> Float

taking values in [0,1]x[0,1]


type alias Point =
Internal.Point

Represent a point as (Float,Float)


type alias Grid =
Internal.Grid

Represent the discretization grid

pointAt : Grid -> Basics.Int -> Point

Get the point, ithat is (x,y) coordinates, in the grid for a data index.

fromList : Grid -> List Basics.Float -> GridFunction

Construct a two-dimensial scalar field from a data in a list of values

Values are expected in the order of indices in the given grid,
running from min to max, incrementing the first component first.

Use pointAt to get (x,y) coordinates for an data index.

Calculate contour lines

contourLines : Basics.Float -> GridFunction -> List Line

Calculate contour lines for a given level


type alias Line =
Internal.Line

A line within a contour

points : Line -> ( Point, Point )

Get a line's end points

Draw contour lines

viewGridFunction : Style -> GridFunction -> List Basics.Float -> Html msg

Render SVG with contours for several levels of a grid function.

drawGridFunction : Style -> GridFunction -> List Basics.Float -> Collage msg

Draw contours for several levels of a grid function.

traceLine : Style -> Line -> Collage msg

Draw a line as a traced path.

drawContour : Style -> GridFunction -> Basics.Float -> Collage msg

Draw contour for one level of a grid function.


type alias Style =
{ width : Basics.Int
, height : Basics.Int
, lineStyle : Collage.LineStyle 
}

Rendering style properties.

defaultStyle : Style

Default style.