pub fn create_window(title: &str, width: u32, height: u32) -> WindowBuilderExamples found in repository?
examples/mouse.rs (line 4)
3fn main() {
4 jp::create_window("Test", 150, 150)
5 .draw(|mut g, c| {
6 g.rectangle(
7 c.state()
8 .fill([1.0, 1.0, 1.0, 1.0]),
9 c.width(),
10 c.height()
11 );
12 g.rectangle(
13 c.state()
14 .translate(c.mouse_x, c.mouse_y)
15 .fill([1.0, 0.0, 0.0, 1.0]),
16 50.0, 50.0);
17 })
18 .run();
19}More examples
examples/most_basic.rs (line 4)
3fn main() {
4 jp::create_window("Test", 150, 150)
5 .draw(|mut g, c| {
6 g.rectangle(
7 c.state()
8 .translate(c.width() / 2.0, c.height() / 2.0)
9 .fill([1.0, 0.0, 0.0, 1.0]),
10 50, 50);
11 g.ellipse(
12 c.state()
13 .translate(c.width() / 2.0, c.height() / 2.0)
14 .fill([0.0, 1.0, 0.0, 1.0]),
15 50, 50);
16 })
17 .run();
18}examples/spinning.rs (line 7)
5fn main() {
6 let mut angle = 0.0;
7 jp::create_window("Test", 150, 150)
8 .draw(move |mut g, c| {
9 g.rectangle(
10 c.state()
11 .fill([1.0, 1.0, 1.0, 1.0]),
12 c.width(),
13 c.height()
14 );
15 g.rectangle(
16 c.state()
17 .translate(c.width() / 2.0, c.height() / 2.0)
18 .rotate(angle)
19 .translate(-RADIUS, -RADIUS)
20 .fill([1.0, 0.0, 0.0, 1.0])
21 .stroke([0.0, 1.0, 0.0, 1.0]),
22 RADIUS * 2.0, RADIUS * 2.0);
23 angle += c.dt * 3.0;
24 })
25 .run();
26}examples/keyboard.rs (line 6)
3fn main() {
4 let mut pos_x = 75.0;
5 let mut pos_y = 75.0;
6 jp::create_window("Test", 150, 150)
7 .draw(move |mut g, c| {
8 g.rectangle(
9 c.state()
10 .fill([1.0, 1.0, 1.0, 1.0]),
11 c.width(),
12 c.height()
13 );
14 g.rectangle(
15 c.state()
16 .translate(pos_x, pos_y)
17 .fill([1.0, 0.0, 0.0, 1.0]),
18 50.0, 50.0);
19 let speed = c.dt * 40.0;
20 if c.is_pressed(jp::input::Button::Keyboard(jp::input::Key::Left)) {
21 pos_x -= speed;
22 }
23 if c.is_pressed(jp::input::Button::Keyboard(jp::input::Key::Right)) {
24 pos_x += speed;
25 }
26 if c.is_pressed(jp::input::Button::Keyboard(jp::input::Key::Up)) {
27 pos_y -= speed;
28 }
29 if c.is_pressed(jp::input::Button::Keyboard(jp::input::Key::Down)) {
30 pos_y += speed;
31 }
32 })
33 .run();
34}