pub struct Point { /* private fields */ }
Expand description
Immutable point type, consisting of x and y.
Implementations§
Source§impl Point
impl Point
Sourcepub fn new(x: i32, y: i32) -> Point
pub fn new(x: i32, y: i32) -> Point
Creates a new point from the given coordinates.
Examples found in repository?
examples/simple.rs (line 12)
5fn main() {
6 let mut a = Axle::default();
7 let (mut old_x, mut old_y) = a.mouse_pos();
8
9 let (width, height) = a.size();
10 println!("{}x{}", width, height);
11
12 a.circle(Point::new(100, 100), 100);
13
14 let center = Point::new(width as i32 / 2, height as i32 / 2);
15
16 let fps = a.fps(60.0);
17
18 loop {
19 let (x, y) = a.mouse_pos();
20 a.line(Point::new(old_x, old_y), Point::new(x, y));
21 old_x = x;
22 old_y = y;
23
24 if a.mouse_pressed(MouseButton::Left) {
25 a.pen_down();
26 } else {
27 a.pen_up();
28 }
29
30 if a.keyboard_pressed(Key::L) {
31 a.line(Point::new(x, y), center);
32 }
33
34 if a.keyboard_pressed(Key::C) {
35 a.clear();
36 }
37
38 let events = a.events();
39 for e in &events {
40 if let Event::Quit { .. } = *e {
41 return;
42 }
43 }
44
45 a.background(Color::RGB(255, 128, 0));
46 a.set_draw_color(Color::RGB(0, 0, 0));
47 a.draw();
48 a.sleep(fps);
49 }
50}
pub fn from_ll(raw: SDL_Point) -> Point
pub fn raw_slice(slice: &[Point]) -> *const SDL_Point
pub fn raw(&self) -> *const SDL_Point
Sourcepub fn offset(&self, x: i32, y: i32) -> Point
pub fn offset(&self, x: i32, y: i32) -> Point
Returns a new point by shifting this point’s coordinates by the given x and y values.
Trait Implementations§
impl Copy for Point
impl Eq for Point
Auto Trait Implementations§
impl Freeze for Point
impl RefUnwindSafe for Point
impl Send for Point
impl Sync for Point
impl Unpin for Point
impl UnwindSafe for Point
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