package toffee

  1. Overview
  2. Docs

Module Toffee_geometry.PointfSource

Points of floats.

A t holds two coordinates in floats, flat, as Sizef.t holds a size: layout computes its locations as ts. Point remains for points of other values.

Sourcetype t = {
  1. x : float;
  2. y : float;
}

Two coordinates.

Constants and creation

Sourceval zero : t

zero is the origin.

Sourceval make : float -> float -> t

make x y is { x; y }.

Arithmetic

Sourceval add : t -> t -> t

add a b adds a and b coordinate by coordinate.

Sourceval sub : t -> t -> t

sub a b subtracts b from a coordinate by coordinate.

Sourceval (+) : t -> t -> t

a + b is add a b.

Sourceval (-) : t -> t -> t

a - b is sub a b.

Sourceval mul_scalar : t -> float -> t

mul_scalar point scalar multiplies both coordinates by scalar.

Sourceval div_scalar : t -> float -> t

div_scalar point scalar divides both coordinates by scalar.

Sourceval (*) : t -> float -> t

point * scalar is mul_scalar point scalar.

Sourceval (/) : t -> float -> t

point / scalar is div_scalar point scalar.

Axis accessors

Sourceval get : Abstract_axis.t -> t -> float

get axis point is x for Inline and y for Block.

Conversions

Sourceval of_point : float Point.t -> t

of_point point has the coordinates of point.

Sourceval to_point : t -> float Point.t

to_point point has the coordinates of point.

Comparison and formatting

Sourceval equal : t -> t -> bool

equal a b is true iff both coordinates are equal floats.

Sourceval compare : t -> t -> int

compare a b orders by x, then y, as Float.compare.

Sourceval to_string : t -> string

to_string point is a readable representation of point.

Sourceval pp : Format.formatter -> t -> unit

pp formats a point as to_string.