Gesso.Geometry
- Package
- purescript-gesso
- Repository
- smilack/purescript-gesso
#fromMouseEvent Source
fromMouseEvent :: MouseEvent -> PointExtract x and y coordinates from a MouseEvent using the
pageX and pageY properties
Re-exports from Gesso.Geometry.Dimensions
Re-exports from Gesso.Geometry.Internal
#Scalers Source
type Scalers = { canvas :: Scaler, drawing :: Scaler, scale :: Number }Data and functions for converting between the coordinate systems of the canvas element on the page and the view box of the application/drawing.
scale is the amount that the view box has been scaled up or down to fit
within the canvas element.
canvas and drawing contain the dimensions of the named space and
functions for converting coordinates to itself.
Re-exports from Gesso.Geometry.Scaler
#Scaler Source
type Scaler = Record (Rectangular Number) + (rect :: Rect, scaling :: { all :: forall rl r. RowToList r rl => Scalable rl r Number => Record r -> Builder (Record ()) (Record r) | ScalingFunctions })Data and functions for working with a coordinate system:
The x, y, width, and height fields are the origin and size of the
system. The rect field contains all of them as well - sometimes it's
easier to access them indiviually, and sometimes it's easier to access them
as a complete Rect.
scaling contains functions to scale x, y, length, and entire
records, but they're more convenient to use with the to and from
functions rather than being called directly:
-- this:
{ x: 1.0, y: 2.0 } `to` canvas
-- not:
canvas.scaling.all { x: 1.0, y: 2.0 }
#to Source
to :: forall rl r. RowToList r rl => Scalable rl r Number => Record r -> Scaler -> Record rConvert fields in an arbitrary record to the coordinate system of a
Scaler. If any of these fields is found and has type Number, it will be
converted:
xfields:x,x1,x2yfields:y,y1,y2lengthfields:width,w,height,h,radius,r,length,len,l
line' = { x1: 0.0, y1: 0.0, x2: 1.0, y2: 1.0 } `to` canvas
circle' = { x: 0.0, y: 0.0, r: 1.0 } `to` canvas
#(|~>) Source
Operator alias for Gesso.Geometry.Scaler.yTo (non-associative / precedence 2)
Convert a single y value to the coordinate system of a Scaler:
y' = y |~> canvas
#(<~|) Source
Operator alias for Gesso.Geometry.Scaler.yFrom (non-associative / precedence 2)
yTo with arguments flipped:
y' = canvas <~| y
#(<~/) Source
Operator alias for Gesso.Geometry.Scaler.lengthFrom (non-associative / precedence 2)
lengthTo with arguments flipped:
l' = canvas <~/ l
#(<~-) Source
Operator alias for Gesso.Geometry.Scaler.xFrom (non-associative / precedence 2)
xTo with arguments flipped:
x' = canvas <~- x
#(<~*) Source
Operator alias for Gesso.Geometry.Scaler.from (non-associative / precedence 2)
to with arguments flipped:
line' = canvas <~* { x1: 0.0, y1: 0.0, x2: 1.0, y2: 1.0 }
circle' = canvas <~* { x: 0.0, y: 0.0, r: 1.0 }
#(/~>) Source
Operator alias for Gesso.Geometry.Scaler.lengthTo (non-associative / precedence 2)
Convert a single length value to the coordinate system of a Scaler:
l' = l /~> canvas