[][src]Struct canrust::canvas::Polygon

pub struct Polygon { /* fields omitted */ }

An abstraction over SFMLs ConvexShape

Implementations

impl Polygon[src]

pub fn new(points: Vec<(f32, f32)>) -> Option<Self>[src]

Creates a shape from a vector of coordinates

pub fn from_polygon(polygon: &Polygon) -> Option<Self>[src]

Creates a new shape with the same points and settings

impl Polygon[src]

pub fn set_fill_color(&mut self, color: Color) -> Result<(), String>[src]

Sets object fill color.

pub fn set_outline_color(&mut self, color: Color) -> Result<(), String>[src]

Set objects outline color

pub fn set_outline_thickness(&mut self, size: f32) -> Result<(), String>[src]

Set objects outline thickness

pub fn set_point_count(&mut self, pc: u32) -> Result<(), String>[src]

Set objects point count. For example if point count is 3, we get an equilateral triangle.

pub fn set_origin(&mut self, origin: (f32, f32)) -> Result<(), String>[src]

Sets shapes origin point(by default its the top left corner, or objects 0, 0 coordinates). This is the point, around which objects rotate and which will be used to set objects position.

If if you have a Rectangle with the default origin point which is 0, 0 on position x = 320 and y = 180 and width and height of 80 and 100 pixels, valid origin points are coordinates x+width and y + height.

pub fn set_rotation(&mut self, angle: f32) -> Result<(), String>[src]

Sets the rotation of the object

pub fn rotate(&mut self, angle: f32) -> Result<(), String>[src]

Adds to objects existing rotation

pub fn set_position(&mut self, position: (f32, f32)) -> Result<(), String>[src]

Sets objects position on Canvas

pub fn get_fill_color(&self) -> Option<Color>[src]

Returns fill color of the object

pub fn get_outline_color(&self) -> Option<Color>[src]

Return the outline color of the object

pub fn get_outline_thickness(&self) -> Option<f32>[src]

Returns the outline thickness of the object

pub fn get_position(&self) -> Option<(f32, f32)>[src]

Returns objects position on the Canvas

pub fn get_rotation(&self) -> Option<f32>[src]

Returns the angle at which the object is rotated.

pub fn get_origin(&self) -> Option<(f32, f32)>[src]

Returns the objects origin point.

pub fn get_point_count(&self) -> Option<u32>[src]

Returns objects point count

Auto Trait Implementations

impl RefUnwindSafe for Polygon

impl !Send for Polygon

impl !Sync for Polygon

impl Unpin for Polygon

impl UnwindSafe for Polygon

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.