Module OgamlGraphics.Shape

Creation and manipulation of 2D shapes
type t
Type of shapes
val create_polygon : points:OgamlMath.Vector2f.t list -> color:Color.t -> ?origin:OgamlMath.Vector2f.t -> ?position:OgamlMath.Vector2f.t -> ?scale:OgamlMath.Vector2f.t -> ?rotation:float -> ?thickness:float -> ?border_color:Color.t -> unit -> t
Creates a convex polygon given a list of points. points is this list of points, origin is the origin of the polygon. All coordinates are taken with respect to the top-left corner of the shape.
val create_rectangle : position:OgamlMath.Vector2f.t -> size:OgamlMath.Vector2f.t -> color:Color.t -> ?origin:OgamlMath.Vector2f.t -> ?scale:OgamlMath.Vector2f.t -> ?rotation:float -> ?thickness:float -> ?border_color:Color.t -> unit -> t
Creates a rectangle. Its origin is positioned with respect to the top-left corner.
val create_regular : position:OgamlMath.Vector2f.t -> radius:float -> amount:int -> color:Color.t -> ?origin:OgamlMath.Vector2f.t -> ?scale:OgamlMath.Vector2f.t -> ?rotation:float -> ?thickness:float -> ?border_color:Color.t -> unit -> t
Creates a regular polygon with a given number of vertices. When this number is high, one can expect a circle.
val create_line : thickness:float -> color:Color.t -> ?top:OgamlMath.Vector2f.t -> tip:OgamlMath.Vector2f.t -> ?position:OgamlMath.Vector2f.t -> ?origin:OgamlMath.Vector2f.t -> ?rotation:float -> unit -> t
Creates a line from top (zero by default) to tip .
val draw : (module RenderTarget.T with type t = 'a) -> ?parameters:DrawParameter.t -> target:'a -> shape:t -> unit -> unit
Draws a shape on a window using the given parameters.
parameters defaults to DrawParameter.make ~depth_test:false ~blend_mode:DrawParameter.BlendMode.alpha

See : OgamlGraphics.DrawParameter
See : OgamlGraphics.Window
val set_position : t -> OgamlMath.Vector2f.t -> unit
Sets the position of the origin in the window.
val set_origin : t -> OgamlMath.Vector2f.t -> unit
Sets the position of the origin with respect to the top-left corner of the shape.
val set_rotation : t -> float -> unit
Sets the angle of rotation of the shape.
val set_scale : t -> OgamlMath.Vector2f.t -> unit
Sets the scale of the shape.
val set_thickness : t -> float -> unit
Sets the thickness of the outline.
val set_color : t -> Color.t -> unit
Sets the filling color of the shape.
val translate : t -> OgamlMath.Vector2f.t -> unit
Translates the shape by the given vector.
val rotate : t -> float -> unit
Rotates the shape by the given angle.
val scale : t -> OgamlMath.Vector2f.t -> unit
Scales the shape.
val position : t -> OgamlMath.Vector2f.t
Returns the position of the origin in window coordinates.
val origin : t -> OgamlMath.Vector2f.t
Returns the position of the origin with respect to the first point of the shape.
val rotation : t -> float
Returns the angle of rotation of the shape.
val get_scale : t -> OgamlMath.Vector2f.t
Returns the scale of the shape.
val thickness : t -> float
Returns the thickness of the outline.
val color : t -> Color.t
Returns the filling color of the shape.

Vertex array access

val to_source : t -> VertexArray.SimpleVertex.T.s VertexArray.VertexSource.t -> unit
Outputs a shape to a vertex array source.
This outputs triangles with position and color attributes.
Use DrawMode.Triangles with this source.
val map_to_source : t -> (VertexArray.SimpleVertex.T.s VertexArray.Vertex.t -> 'b VertexArray.Vertex.t) -> 'b VertexArray.VertexSource.t -> unit
Outputs a shape to a vertex array source by mapping its vertices.
See to_source for more information.