[][src]Trait embedded_graphics::transform::Transform

pub trait Transform {
    fn translate(&self, by: Point) -> Self;
fn translate_mut(&mut self, by: Point) -> &mut Self; }

Transform operations

Required methods

fn translate(&self, by: Point) -> Self

Move the origin of an object by a given number of (x, y) pixels, returning a new object

fn translate_mut(&mut self, by: Point) -> &mut Self

Move the origin of an object by a given number of (x, y) pixels, mutating the object in place

Loading content...

Implementors

impl Transform for Circle[src]

fn translate(&self, by: Point) -> Self[src]

Translate the circle center from its current position to a new position by (x, y) pixels, returning a new Circle. For a mutating transform, see translate_mut.

let circle = Circle::new(Point::new(5, 10), 10);
let moved = circle.translate(Point::new(10, 10));

assert_eq!(moved.center, Point::new(15, 20));

fn translate_mut(&mut self, by: Point) -> &mut Self[src]

Translate the circle center from its current position to a new position by (x, y) pixels.

let mut circle = Circle::new(Point::new(5, 10), 10);
circle.translate_mut(Point::new(10, 10));

assert_eq!(circle.center, Point::new(15, 20));

impl Transform for Line[src]

fn translate(&self, by: Point) -> Self[src]

Translate the line from its current position to a new position by (x, y) pixels, returning a new Line. For a mutating transform, see translate_mut.

let line = Line::new(Point::new(5, 10), Point::new(15, 20));
let moved = line.translate(Point::new(10, 10));

assert_eq!(moved.start, Point::new(15, 20));
assert_eq!(moved.end, Point::new(25, 30));

fn translate_mut(&mut self, by: Point) -> &mut Self[src]

Translate the line from its current position to a new position by (x, y) pixels.

let mut line = Line::new(Point::new(5, 10), Point::new(15, 20));
line.translate_mut(Point::new(10, 10));

assert_eq!(line.start, Point::new(15, 20));
assert_eq!(line.end, Point::new(25, 30));

impl Transform for Rectangle[src]

fn translate(&self, by: Point) -> Self[src]

Translate the rect from its current position to a new position by (x, y) pixels, returning a new Rectangle. For a mutating transform, see translate_mut.

let rect = Rectangle::new(Point::new(5, 10), Point::new(15, 20));
let moved = rect.translate(Point::new(10, 10));

assert_eq!(moved.top_left, Point::new(15, 20));
assert_eq!(moved.bottom_right, Point::new(25, 30));

fn translate_mut(&mut self, by: Point) -> &mut Self[src]

Translate the rect from its current position to a new position by (x, y) pixels.

let mut rect = Rectangle::new(Point::new(5, 10), Point::new(15, 20));
rect.translate_mut(Point::new(10, 10));

assert_eq!(rect.top_left, Point::new(15, 20));
assert_eq!(rect.bottom_right, Point::new(25, 30));

impl Transform for Triangle[src]

fn translate(&self, by: Point) -> Self[src]

Translate the triangle from its current position to a new position by (x, y) pixels, returning a new Triangle. For a mutating transform, see translate_mut.

let tri = Triangle::new(Point::new(5, 10), Point::new(15, 20), Point::new(8, 15));
let moved = tri.translate(Point::new(10, 10));

assert_eq!(moved.p1, Point::new(15, 20));
assert_eq!(moved.p2, Point::new(25, 30));
assert_eq!(moved.p3, Point::new(18, 25));

fn translate_mut(&mut self, by: Point) -> &mut Self[src]

Translate the triangle from its current position to a new position by (x, y) pixels.

let mut tri = Triangle::new(Point::new(5, 10), Point::new(15, 20), Point::new(10, 15));
tri.translate_mut(Point::new(10, 10));

assert_eq!(tri.p1, Point::new(15, 20));
assert_eq!(tri.p2, Point::new(25, 30));
assert_eq!(tri.p3, Point::new(20, 25));

impl<'_> Transform for Text<'_>[src]

impl<'a, C> Transform for ImageBmp<'a, C> where
    C: PixelColor + From<<C as PixelColor>::Raw>, 
[src]

fn translate(&self, by: Point) -> Self[src]

Translate the image from its current position to a new position by (x, y) pixels, returning a new ImageBmp. For a mutating transform, see translate_mut.

fn translate_mut(&mut self, by: Point) -> &mut Self[src]

Translate the image from its current position to a new position by (x, y) pixels.

impl<'a, C> Transform for ImageTga<'a, C> where
    C: PixelColor + From<<C as PixelColor>::Raw>, 
[src]

fn translate(&self, by: Point) -> Self[src]

Translate the image from its current position to a new position by (x, y) pixels, returning a new ImageTga. For a mutating transform, see translate_mut.

fn translate_mut(&mut self, by: Point) -> &mut Self[src]

Translate the image from its current position to a new position by (x, y) pixels.

impl<'a, C, BO> Transform for Image<'a, C, BO> where
    C: PixelColor + From<<C as PixelColor>::Raw>,
    BO: ByteOrder
[src]

fn translate(&self, by: Point) -> Self[src]

Translate the image from its current position to a new position by (x, y) pixels, returning a new Image. For a mutating transform, see translate_mut.

// 8px x 1px test image
let image: Image<BinaryColor> = Image::new(&[0xff], 8, 1);
let moved = image.translate(Point::new(25, 30));

assert_eq!(image.offset(), Point::new(0, 0));
assert_eq!(moved.offset(), Point::new(25, 30));

fn translate_mut(&mut self, by: Point) -> &mut Self[src]

Translate the image from its current position to a new position by (x, y) pixels.

let mut image: Image<BinaryColor> = Image::new(&[0xff], 8, 1);
image.translate_mut(Point::new(25, 30));

assert_eq!(image.offset(), Point::new(25, 30));

impl<T, S> Transform for Styled<T, S> where
    T: Transform,
    S: Clone
[src]

Loading content...