move draw_exterior into utils

main
annieversary 2021-08-28 00:20:17 +02:00
parent 906e2a66c5
commit e315d00bb3
3 changed files with 40 additions and 37 deletions

View File

@ -63,8 +63,8 @@ fn view(app: &App, _model: &Model, frame: Frame) {
} }
} }
// draw exteriors // draw exterior
draw_exterior(&draw); drawing::draw_exterior(&draw, 200.0, SNOW);
// outer draw // outer draw
for i in 0..50 { for i in 0..50 {
@ -80,38 +80,3 @@ fn view(app: &App, _model: &Model, frame: Frame) {
draw.to_frame(app, &frame).unwrap(); draw.to_frame(app, &frame).unwrap();
utils::record::record(app, &frame); utils::record::record(app, &frame);
} }
fn draw_exterior(draw: &Draw) {
draw.quad()
.points(
vec2(200.0, -1000.0),
vec2(200.0, 1000.0),
vec2(1000.0, 1000.0),
vec2(1000.0, -1000.0),
)
.color(SNOW);
draw.quad()
.points(
vec2(-200.0, -1000.0),
vec2(-200.0, 1000.0),
vec2(-1000.0, 1000.0),
vec2(-1000.0, -1000.0),
)
.color(SNOW);
draw.quad()
.points(
vec2(-1000.0, 200.0),
vec2(-1000.0, 1000.0),
vec2(1000.0, 1000.0),
vec2(1000.0, 200.0),
)
.color(SNOW);
draw.quad()
.points(
vec2(-1000.0, -200.0),
vec2(-1000.0, -1000.0),
vec2(1000.0, -1000.0),
vec2(1000.0, -200.0),
)
.color(SNOW);
}

View File

@ -0,0 +1,37 @@
use nannou::{color::IntoLinSrgba, draw::properties::ColorScalar, prelude::*};
/// Draws the opposite of a box
pub fn draw_exterior(draw: &Draw, size: f32, color: impl IntoLinSrgba<ColorScalar> + Clone) {
draw.quad()
.points(
vec2(size, -1000.0),
vec2(size, 1000.0),
vec2(1000.0, 1000.0),
vec2(1000.0, -1000.0),
)
.color(color.clone());
draw.quad()
.points(
vec2(-size, -1000.0),
vec2(-size, 1000.0),
vec2(-1000.0, 1000.0),
vec2(-1000.0, -1000.0),
)
.color(color.clone());
draw.quad()
.points(
vec2(-1000.0, size),
vec2(-1000.0, 1000.0),
vec2(1000.0, 1000.0),
vec2(1000.0, size),
)
.color(color.clone());
draw.quad()
.points(
vec2(-1000.0, -size),
vec2(-1000.0, -1000.0),
vec2(1000.0, -1000.0),
vec2(1000.0, -size),
)
.color(color);
}

View File

@ -1,4 +1,5 @@
pub mod color; pub mod color;
pub mod drawing;
pub mod record; pub mod record;
pub mod sequences; pub mod sequences;