pub struct Rect {
pub x: f32,
pub y: f32,
pub w: f32,
pub h: f32,
}Fields§
§x: f32§y: f32§w: f32§h: f32Implementations§
source§impl Rect
impl Rect
sourcepub fn new(x: f32, y: f32, w: f32, h: f32) -> Rect
pub fn new(x: f32, y: f32, w: f32, h: f32) -> Rect
Examples found in repository?
examples/canvas.rs (line 35)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
fn run(&mut self, dt: f32, render: &mut Self::Render) -> bool {
let speed = 80.0 * dt;
self.time = self.time + (dt * 30.0);
if cafe::keyboard::is_down(Scancode::Left) {
self.pos -= Vec2::new(speed, 0.0);
}
else if cafe::keyboard::is_down(Scancode::Right) {
self.pos += Vec2::new(speed, 0.0);
}
render.begin();
render.set_clear_color(Color::black());
render.clear();
render.set_canvas(Some(&self.canvas));
render.clear();
render.draw_rect(&Rect::new(self.pos.x, self.pos.y, 32.0, 64.0));
// render.hello_triangle();
render.set_canvas(None);
render.blit(&self.canvas, None, 0.0, 0.0);
render.blit_rotate(&self.canvas, None, 32.0, 64.0, self.time);
render.fill_circle(32.0, 64.0, 8.0);
render.hello_triangle();
render.end();
true
}Trait Implementations§
source§impl PartialEq<Rect> for Rect
impl PartialEq<Rect> for Rect
source§impl PartialOrd<Rect> for Rect
impl PartialOrd<Rect> for Rect
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Copy for Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations§
impl RefUnwindSafe for Rect
impl Send for Rect
impl Sync for Rect
impl Unpin for Rect
impl UnwindSafe for Rect
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more