Stk.G
Geometry.
This module is used to represent and compute widget coordinates.
A geometry is rectangle. x
and y
are coordinates of top-left corner.
val to_string : t -> string
val pp : Stdlib.Format.formatter -> t -> unit
seg_inter x1 w1 x2 w2
returns the intersection segment (left..right) between segments (x1..(x1+w1))
and (x2..(x2+w2))
, if any.
val zero : t
Zero geometry, all fields set to 0
.
val is_zero : t -> bool
val inside : x:int -> y:int -> t -> bool
inside ~x ~y g
returns true
is point (x, y)
is inside g
.
translate ~x ~y g
returns a new geometry, adding x
(resp. y
) to g.x
(resp. g.y
) if specified.
enlarge ~w ~h g
returns a new geometry whose width (resp. height) is increased by 2 * w
(resp. 2 * h
). g.x
(resp. g.y
) is translated by -w
(resp. -h
) so that the final geometry remains centered with report to the original one.
val to_rect : t -> Tsdl.Sdl.rect
to_rect g
creates a Tsdl
.Sdl.rect from g
.
val remove_border : t -> int Props.trbl -> t
remove_border g borders
returns a new geometry by removing borders from g
. It is ensured that the returned geometry has non-negative width and height.