Trait sfml::graphics::Shape

source ·
pub trait Shape<'s>: Drawable + Transformable {
Show 15 methods fn set_texture(&mut self, texture: &'s Texture, reset_rect: bool); fn disable_texture(&mut self); fn set_texture_rect(&mut self, rect: IntRect); fn set_fill_color(&mut self, color: Color); fn set_outline_color(&mut self, color: Color); fn set_outline_thickness(&mut self, thickness: f32); fn texture(&self) -> Option<&'s Texture>; fn texture_rect(&self) -> IntRect; fn fill_color(&self) -> Color; fn outline_color(&self) -> Color; fn outline_thickness(&self) -> f32; fn point_count(&self) -> usize; fn point(&self, index: usize) -> Vector2f; fn local_bounds(&self) -> FloatRect; fn global_bounds(&self) -> FloatRect;
}
Expand description

Trait for textured shapes with outline.

Required Methods§

Changes the source texture of the shape.

If reset_rect is true, the texture_rect property of the shape is automatically adjusted to the size of the new texture. If it is false, the texture rect is left unchanged.

Disables texturing for this shape.

Sets 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.

Sets 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 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.

Sets the outline color of the shape.

By default, the shape’s outline color is opaque white.

Sets the thickness of the shape’s outline.

Note that negative values are allowed (so that the outline expands towards the center of the shape), and using zero disables the outline. By default, the outline thickness is 0.

Gets the source texture of the shape.

If the shape has no source texture, None is returned.

Gets the sub-rectangle of the texture displayed by the shape.

Gets the fill color of this shape.

Gets the outline color of this shape.

Gets the outline thickness of this shape.

Gets the total number of points of the shape.

Gets a point of the shape.

The returned point is in local coordinates, that is, the shape’s transforms (position, rotation, scale) are not taken into account. The result is unspecified if index is out of the valid range (0..point_count()).

Gets 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.

Gets the global (non-minimal) bounding rectangle of the entity.

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

This function does not necessarily return the minimal bounding rectangle. It merely ensures that the returned rectangle covers all the vertices (but possibly more). This allows for a fast approximation of the bounds as a first check; you may want to use more precise checks on top of that.

Implementors§