package toffee

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Geometry.PointSource

2-dimensional point representation.

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

'a t represents a 2-dimensional point with x and y coordinates.

Constants

Sourceval zero : float t

zero is a point at the origin (0.0, 0.0).

Sourceval none : 'a option t

none is a point with both coordinates set to None.

Creation

Sourceval make : 'a -> 'a -> 'a t

make x y creates a point.

Arithmetic operations

Sourceval add : float t -> float t -> float t

add a b adds corresponding coordinates of a and b.

Sourceval sub : float t -> float t -> float t

sub a b subtracts corresponding coordinates of b from a.

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

a + b is add a b.

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

a - b is sub a b.

Sourceval mul_scalar : float t -> float -> float t

mul_scalar point scalar multiplies both components of point by scalar.

Sourceval div_scalar : float t -> float -> float t

div_scalar point scalar divides both components of point by scalar.

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

point * scalar is mul_scalar point scalar.

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

point / scalar is div_scalar point scalar.

Mapping

Sourceval map : ('a -> 'b) -> 'a t -> 'b t

map f point applies f to both coordinates.

Sourceval map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

map2 f p1 p2 applies f to corresponding coordinates of p1 and p2.

Axis accessors

Sourceval get : Abstract_axis.t -> 'a t -> 'a

get axis point retrieves the component corresponding to axis.

Sourceval set : Abstract_axis.t -> 'a -> 'a t -> 'a t

set axis value point returns a new point with the component corresponding to axis set to value.

Transformations

Sourceval transpose : 'a t -> 'a t

transpose point swaps the x and y components.

Conversions

Sourceval to_size : 'a t -> 'a Size.t

to_size point converts a point to a size by mapping x -> width and y -> height.

Sourceval of_size : 'a Size.t -> 'a t

of_size size converts a size to a point by mapping width -> x and height -> y.

Comparison and string functions

Sourceval compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

compare cmp a b compares a and b lexicographically using cmp.

Sourceval equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool

equal eq a b tests equality using eq for each coordinate.

Sourceval to_string : ('a -> string) -> 'a t -> string

to_string f point converts point to a string using f.

Sourceval pp : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit

pp f fmt point prints point using fmt and f.