1extern crate axle;
2
3use axle::{Axle, Color, Event, Key, MouseButton, Point};
4
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}