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

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

Transform operations

Required methods

fn translate(&self, by: Coord) -> 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: Coord) -> &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<'a, C> Transform for Image16BPP<'a, C> where
    C: PixelColor
[src]

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

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

// 1px x 1px test image
let image: Image16BPP<PixelColorU8> = Image16BPP::new(&[ 0xff ], 1, 1);
let moved = image.translate(Coord::new(25, 30));

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

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

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

// 1px x 1px test image
let mut image: Image16BPP<PixelColorU8> = Image16BPP::new(&[ 0xff ], 1, 1);
image.translate_mut(Coord::new(25, 30));

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

impl<'a, C> Transform for Image1BPP<'a, C>[src]

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

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

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

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

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

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

let mut image: Image1BPP<PixelColorU8> = Image1BPP::new(&[ 0xff ], 8, 1);
image.translate_mut(Coord::new(25, 30));

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

impl<'a, C> Transform for Image8BPP<'a, C> where
    C: PixelColor
[src]

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

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

// 1px x 1px test image
let image: Image8BPP<PixelColorU8> = Image8BPP::new(&[ 0xff ], 1, 1);
let moved = image.translate(Coord::new(25, 30));

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

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

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

// 1px x 1px test image
let mut image: Image8BPP<PixelColorU8> = Image8BPP::new(&[ 0xff ], 1, 1);
image.translate_mut(Coord::new(25, 30));

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

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

fn translate(&self, by: Coord) -> 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: Coord) -> &mut Self[src]

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

impl<'a, C, Conf> Transform for FontBuilder<'a, C, Conf> where
    C: PixelColor
[src]

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

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

// 8px x 1px test image
let text = Font8x16::render_str("Hello world")
let moved = text.translate(Coord::new(25, 30));

assert_eq!(text.pos, Coord::new(0, 0));
assert_eq!(moved.pos, Coord::new(25, 30));

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

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

// 8px x 1px test image
let mut text = Font8x16::render_str("Hello world")
text.translate_mut(Coord::new(25, 30));

assert_eq!(text.pos, Coord::new(25, 30));

impl<C> Transform for Circle<C> where
    C: PixelColor
[src]

fn translate(&self, by: Coord) -> 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(Coord::new(5, 10), 10)
let moved = circle.translate(Coord::new(10, 10));

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

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

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

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

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

impl<C> Transform for Line<C> where
    C: PixelColor
[src]

fn translate(&self, by: Coord) -> 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(Coord::new(5, 10), Coord::new(15, 20))
let moved = line.translate(Coord::new(10, 10));

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

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

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

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

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

impl<C> Transform for Rect<C> where
    C: PixelColor
[src]

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

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

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

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

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

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

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

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