Module OgamlGraphics.Sprite

Creation and manipulation of 2D sprites
type t
Type of sprites
val create : texture:Texture.Texture2D.t -> ?subrect:OgamlMath.IntRect.t -> ?origin:OgamlMath.Vector2f.t -> ?position:OgamlMath.Vector2f.t -> ?scale:OgamlMath.Vector2f.t -> ?color:Color.t -> ?size:OgamlMath.Vector2f.t -> ?rotation:float -> unit -> t
Creates a sprite.
val draw : (module RenderTarget.T with type t = 'a) -> ?parameters:DrawParameter.t -> target:'a -> sprite:t -> unit -> unit
Draws a sprite 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 of the sprite 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 sprite. The origin is the center of all transformations.
val set_rotation : t -> float -> unit
Sets the angle of rotation of the sprite.
val set_scale : t -> OgamlMath.Vector2f.t -> unit
Sets the scale of the sprite.
val set_size : t -> OgamlMath.Vector2f.t -> unit
Sets the base size of a sprite.
val set_color : t -> Color.t -> unit
Sets the color of a sprite.
val translate : t -> OgamlMath.Vector2f.t -> unit
Translates the sprite by the given vector.
val rotate : t -> float -> unit
Rotates the sprite by the given angle.
val scale : t -> OgamlMath.Vector2f.t -> unit
Scales the sprite.
val size : t -> OgamlMath.Vector2f.t
Returns the base size of a sprite
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 sprite.
val rotation : t -> float
Returns the angle of rotation of the sprite.
val color : t -> Color.t
Returns the color of a sprite.
val get_scale : t -> OgamlMath.Vector2f.t
Returns the scale of the sprite.

Vertex array access

val to_source : t -> VertexArray.SimpleVertex.T.s VertexArray.VertexSource.t -> unit
Outputs a sprite to a vertex array source.
This outputs two triangles with UV coordinates and position 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 sprite to a vertex array source by mapping its vertices.
See to_source for more information.