pub struct Rect {
pub x: f32,
pub y: f32,
pub w: f32,
pub h: f32,
}
Fields§
§x: f32
§y: f32
§w: f32
§h: f32
Implementations§
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 fn run(&mut self, dt: f32, render: &mut Self::Render) -> bool {
21 let speed = 80.0 * dt;
22 self.time = self.time + (dt * 30.0);
23 if cafe::keyboard::is_down(Scancode::Left) {
24 self.pos -= Vec2::new(speed, 0.0);
25 }
26 else if cafe::keyboard::is_down(Scancode::Right) {
27 self.pos += Vec2::new(speed, 0.0);
28 }
29 render.begin();
30 render.set_clear_color(Color::black());
31 render.clear();
32
33 render.set_canvas(Some(&self.canvas));
34 render.clear();
35 render.draw_rect(&Rect::new(self.pos.x, self.pos.y, 32.0, 64.0));
36 // render.hello_triangle();
37 render.set_canvas(None);
38
39 render.blit(&self.canvas, None, 0.0, 0.0);
40 render.blit_rotate(&self.canvas, None, 32.0, 64.0, self.time);
41 render.fill_circle(32.0, 64.0, 8.0);
42 render.hello_triangle();
43
44 render.end();
45 true
46 }
Trait Implementations§
Source§impl PartialOrd for Rect
impl PartialOrd for Rect
impl Copy for Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations§
impl Freeze for Rect
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