Class OcsfmlGraphics.shape

class shape : ?position:float * float -> ?scale:float * float -> ?rotation:float -> ?origin:float * float -> ?texture:#const_texture -> ?texture_rect:IntRect.t -> ?fill_color:Color.t -> ?outline_color:Color.t -> ?outline_thickness:float -> Shape.t -> object .. end
Base class for textured shapes with outline.

Ocsfml.Shape is a drawable class that allows to define and display a custom convex shape on a render target.

It's only an abstract base, it needs to be specialized for concrete types of shapes (circle, rectangle, convex polygon, star, ...).

In addition to the attributes provided by the specialized shape classes, a shape always has the following attributes:

Each feature is optional, and can be disabled easily:

You can write your own derived shape class, there are only two virtual functions to override:


Inherits
method destroy : unit
method get_fill_color : Color.t
Get the fill color of the shape.
Returns Fill color of the shape.
method get_global_bounds : FloatRect.t
Get the global bounding rectangle of the entity.

The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the sprite in the global 2D world's coordinate system.
Returns Global bounding rectangle of the entity

method get_local_bounds : FloatRect.t
Get the local bounding rectangle of the entity.

The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.
Returns Local bounding rectangle of the entity

method get_outline_color : Color.t
Get the outline color of the shape.
Returns Outline color of the shape.
method get_outline_thickness : float
Get the outline thickness of the shape.
Returns Outline thickness of the shape.
method get_point : int -> float * float
Get a point of the shape.

The result is undefined if the index is out of the valid range.
Returns Index-th point of the shape.

method get_point_count : int
Get the total number of points of the shape.
Returns Number of points of the shape.
method get_texture : const_texture reference option
Get the source texture of the shape.

If the shape has no source texture, none is returned. The returned value is const, which means that you can't modify the texture when you retrieve it with this function.
Returns Shape's texture.

method get_texture_rect : IntRect.t
Get the sub-rectangle of the texture displayed by the shape.
Returns Texture rectangle of the shape
method set_fill_color : Color.t -> unit
Set the fill color of the shape.

This color is modulated (multiplied) with the shape's texture if any. It can be used to colorize the shape, or change its global opacity. You can use OcsfmlGraphics.Color.Transparent to make the inside of the shape transparent, and have the outline alone. By default, the shape's fill color is opaque white.

method set_outline_color : Color.t -> unit
Set the outline color of the shape.

You can use OcsfmlGraphics.Color.Transparent to disable the outline. By default, the shape's outline color is opaque white.

method set_outline_thickness : float -> unit
Set the thickness of the shape's outline.

This number cannot be negative. Using zero disables the outline. By default, the outline thickness is 0.

method set_texture : 'a.
?texture:(#const_texture as 'a) ->
?reset_rect:bool -> unit -> unit
Change the source texture of the shape.

The texture argument refers to a texture that must exist as long as the shape uses it. Indeed, the shape doesn't store its own copy of the texture, but rather keeps a pointer to the one that you passed to this function. If the source texture is destroyed and the shape tries to use it, the behaviour is undefined. If reset_rect is true, the TextureRect property of the shape is automatically adjusted to the size of the new texture. If it is false (the default), the texture rect is left unchanged.

texture : The new texture. Default disables texturing
reset_rect : Should the texture rect be reset to the size of the new texture?
method set_texture_rect : IntRect.t -> unit
Set the sub-rectangle of the texture that the shape will display.

The texture rect is useful when you don't want to display the whole texture, but rather a part of it. By default, the texture rect covers the entire texture.