Struct polystrip::pixel::PixelTranslator[][src]

pub struct PixelTranslator { /* fields omitted */ }

When constructed from a WindowTarget, tracks the window’s size and provides methods which convert between pixel space and screen space for that window.

Rectangles

The various rectangle methods defined on this struct output vertices in the following layout:

(0)---(1)
 |     |
(3)---(2)

Implementations

impl PixelTranslator[src]

pub fn pixel_position(&self, x: i32, y: i32) -> Vector2[src]

Converts a pixel value into an absolute screen space position. Doing arithmetic operations with absolute screen space positions will not give expected values. See the pixel_offset method to create screen space offsets

pub fn pixel_offset(&self, x: i32, y: i32) -> Vector2[src]

Converts a pixel value into a screen space offset.

pub fn colored_rect(&self, rect: Rect, color: Color) -> [ColorVertex; 4][src]

Converts a Rect into a set of ColorVertexes with the given Color and height 0.0.

pub fn textured_rect(&self, rect: Rect) -> [TextureVertex; 4][src]

Converts a Rect into a set of TextureVertexes with height 0.0.

The texture will be scaled to fit entirely onto the Rect.

pub fn texture_at(
    &self,
    texture: &Texture,
    x: i32,
    y: i32
) -> [TextureVertex; 4]
[src]

Creates a set of TextureVertexes with the width and height of the passed Texture and height 0.0.

pub fn texture_scaled(
    &self,
    texture: &Texture,
    x: i32,
    y: i32,
    scale: f32
) -> [TextureVertex; 4]
[src]

Creates a set of TextureVertexes with the width and height of the passed Texture and height 0.0.

The dimensions of the texture will be scaled by the provided scale factor. The x and y positions will not change.

pub fn texture_cropped(
    &self,
    texture: &Texture,
    x: i32,
    y: i32,
    crop: Rect
) -> [TextureVertex; 4]
[src]

Creates a set of TextureVertexes with the width and height of the passed Texture and height 0.0.

Only the part of the texture inside the passed crop rectangle is shown. The top-left corner of the crop rectangle is drawn at (x, y)

pub fn texture_scaled_cropped(
    &self,
    texture: &Texture,
    destination: Rect,
    crop: Rect
) -> [TextureVertex; 4]
[src]

Creates a set of TextureVertexes with the width and height of the passed Texture and height 0.0.

Only the part of the texture inside the passed crop rectangle is shown. The top-left corner of the crop rectangle is drawn at (x, y)

Auto Trait Implementations

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.