Module

Hylograph.Isometric

Package
purescript-hylograph-isometric
Repository
afcondon/purescript-hylograph-isometric

hylograph-isometric: an orthographic camera for Hylograph.

An isometric view is a projection, not a layout: a 2D layout is put on a plane in the world, given heights, and projected by a camera with two angles. This module re-exports the pure geometry; the HATS drawing helpers are in Hylograph.Isometric.HATS.

Re-exports from Hylograph.Isometric.Camera

#Viewpoint Source

data Viewpoint

The four isometric viewpoints, a quarter turn apart, named for the corner of the floor the camera stands beyond (y grows to the south).

Constructors

Instances

#Point3 Source

type Point3 = { x :: Number, y :: Number, z :: Number }

A point in the world: a layout's x and y, and a height z.

#Point Source

type Point = { x :: Number, y :: Number }

A point on the screen (SVG user units, y down), or in a 2D layout.

#Degrees Source

newtype Degrees

An angle in degrees. The camera's angles are kept in degrees because that is how they are chosen and read; radians converts.

Constructors

Instances

#Camera Source

newtype Camera

scale is screen units per world unit along the line of sight's perpendicular plane (a true orthographic scale): a unit along an axis is drawn shorter than scale by the cosine of its angle to that plane.

Constructors

Instances

#turnedBy Source

turnedBy :: Degrees -> Camera -> Camera

The camera turned about the vertical through the origin.

#towardsCamera Source

towardsCamera :: Camera -> Point3

The unit vector from the scene towards the camera.

#screenRight Source

screenRight :: Camera -> Point

The horizontal unit vector that the camera draws pointing right.

#project Source

project :: Camera -> Point3 -> Point

Where a point of the world is drawn: SVG user units, y down, the world's origin at the screen's.

#nextViewpoint Source

nextViewpoint :: Viewpoint -> Viewpoint

A quarter turn of the camera, anticlockwise seen from above (azimuth + 90°).

#isometricUnit Source

isometricUnit :: Number -> Camera

The isometric camera (from the south-east) at the scale that draws a unit along any axis length screen units long.

#isometric Source

isometric :: Camera

The isometric camera from the south-east, at scale 1.

#floorTowardsCamera Source

floorTowardsCamera :: Camera -> Point

The horizontal direction towards the camera, as a unit vector in the floor.

#depth Source

depth :: Camera -> Point3 -> Number

How near a point is to the camera, along the line of sight: larger is nearer. Only differences mean anything.

#between Source

between :: Number -> Camera -> Camera -> Camera

The camera a fraction t of the way from one to the other, every parameter linearly (the azimuth as given, not reduced: to turn the short way, give azimuths less than 180° apart).

Re-exports from Hylograph.Isometric.Outline

#Rectangle Source

type Rectangle = { x0 :: Number, x1 :: Number, y0 :: Number, y1 :: Number }

#Outline Source

data Outline

Polygon must be convex; its winding does not matter.

Constructors

Instances

#rectangle Source

rectangle :: Rectangle -> Outline

An axis-aligned rectangle.

#circlePoints Source

circlePoints :: { centre :: Point, radius :: Number } -> { count :: Int, from :: Number, sweep :: Number } -> Array Point

count points round a circle, anticlockwise about +z, starting at angle from (radians, from +x towards +y) and sweeping sweep.

Re-exports from Hylograph.Isometric.Painter

#paintersOrder Source

paintersOrder :: forall a. Camera -> (a -> Outline) -> Array a -> Array a

The items in an order to draw them in, back to front.

#behind Source

behind :: Camera -> Outline -> Outline -> Boolean

behind camera a b: the footprint a is behind b and must be drawn before it (a horizontal line towards the camera meets a, then b).

Re-exports from Hylograph.Isometric.Plane

#Plane Source

newtype Plane

Constructors

Instances

#rightWall Source

rightWall :: { at :: Number, top :: Number } -> Plane

The wall y = at, seen from the south-east on the right: a layout's x runs along the world's x, and its y runs down from top.

#onPlane Source

onPlane :: Plane -> Point -> Point3

A point of a layout, put on the plane.

#leftWall Source

leftWall :: { at :: Number, top :: Number, width :: Number } -> Plane

The wall x = at, seen from the south-east on the left: a layout's x runs from the front corner (y = width) to the back (y = 0), and its y runs down from top.

#floor Source

floor :: Number -> Plane

The floor at a height: a layout keeps its x and y.

Re-exports from Hylograph.Isometric.Prism

#Prism Source

newtype Prism

An outline on the floor at height base, extruded height upwards.

Constructors

Instances

#Facing Source

data Facing

Which way a drawn face looks, on the screen: the usual three tones of an isometric drawing (a top and the sides turned left and right), plus the underside and a cylinder's round side.

Constructors

Instances

#FaceKind Source

data FaceKind

Which face: the top, the bottom, the side standing on edge n of the outline (edge n runs from corner n to corner n + 1, the corners wound anticlockwise about +z), or a cylinder's curved side.

Constructors

Instances

#Face Source

type Face = { corners :: Array Point3, kind :: FaceKind, normal :: Point3 }

A face in the world: its corners, wound anticlockwise seen from outside, and its outward unit normal.

#DrawnFace Source

type DrawnFace = { facing :: Facing, kind :: FaceKind, lightness :: Number, normal :: Point3, outline :: Array Point }

A face as drawn: its outline on the screen, which way it looks, and a flat lightness in [0, 1] (see lightness).

#visibleFaces Source

visibleFaces :: Camera -> Prism -> Array DrawnFace

What the camera sees of a prism: the faces turned towards it, projected. A prism is convex, so its visible faces never overlap one another; they come sides first and top last, so the top's outline is drawn over the edges it shares with them.

A flat face is kept when its projected outline winds the way a face seen from outside does, which is the same as its normal facing the camera. A cylinder's curved side is drawn as one face: the half of it towards the camera.

#prismOutline Source

#lightness Source

lightness :: Camera -> Point3 -> Number

A flat (Lambertian) lightness in [0, 1] for a face with this outward normal, lit from above, over the viewer's left shoulder. The light turns with the camera, so a turned scene keeps its tones: tops lightest, faces turned left next, faces turned right darkest.

#faces Source

faces :: Prism -> Array Face

Every face of a polygon prism: the bottom, the sides, the top. A cylinder's curved side has no single normal, so for a cylinder this gives only the top and the bottom.

#faceKey Source

faceKey :: FaceKind -> String

A key for a face, stable while the camera turns.

#cylinder Source

cylinder :: { centre :: Point, radius :: Number } -> { base :: Number, height :: Number } -> Prism

#box Source

box :: Rectangle -> { base :: Number, height :: Number } -> Prism

Re-exports from Hylograph.Isometric.Spike

#SpikeShape Source

data SpikeShape

A needle tapers to a point; a bar keeps its width.

Constructors

Instances

#Spike Source

newtype Spike

Constructors

Instances

#spikeOutline Source

spikeOutline :: Camera -> Spike -> Array Point

The spike as drawn: a triangle or a rectangle across the line of sight.

#spikeFootprint Source

spikeFootprint :: Spike -> Outline

What the painter's order should take a lone spike to cover on the floor.

#shadowOutline Source

shadowOutline :: Camera -> Spike -> Array Point

The spike's shadow on the plane it stands on, cast away from a light over the viewer's left shoulder (the light Prism.lightness uses), half as long as the spike is tall.