pub struct DrawState { /* private fields */ }Implementations§
Source§impl DrawState
impl DrawState
Sourcepub fn fill(self, color: Color) -> Self
pub fn fill(self, color: Color) -> Self
Examples found in repository?
examples/mouse.rs (line 8)
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 9)
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 11)
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 10)
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}Sourcepub fn stroke(self, color: Color) -> Self
pub fn stroke(self, color: Color) -> Self
Examples found in repository?
examples/spinning.rs (line 21)
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}Sourcepub fn translate<X: Into<f64>, Y: Into<f64>>(self, x: X, y: Y) -> Self
pub fn translate<X: Into<f64>, Y: Into<f64>>(self, x: X, y: Y) -> Self
Examples found in repository?
examples/mouse.rs (line 14)
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 8)
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 17)
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 16)
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}Sourcepub fn rotate<A: Into<f64>>(self, angle: A) -> Self
pub fn rotate<A: Into<f64>>(self, angle: A) -> Self
Examples found in repository?
examples/spinning.rs (line 18)
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}Auto Trait Implementations§
impl Freeze for DrawState
impl RefUnwindSafe for DrawState
impl Send for DrawState
impl Sync for DrawState
impl Unpin for DrawState
impl UnwindSafe for DrawState
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more