Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use nannou::prelude::*;
- fn main() {
- nannou::sketch(view).run();
- }
- fn view(app: &App, frame: Frame) {
- let columns = 5.0;
- let rows = 4.0;
- let draw = app.draw();
- let win = app.window_rect();
- let x_step = (win.w() / columns) as usize;
- let y_step = (win.h() / rows) as usize;
- let stroke_w = win.w() / 50.0;
- let x_min = win.left() as isize;
- let x_max = win.right() as isize;
- let y_min = win.top() as isize;
- let y_max = win.bottom() as isize;
- app.set_loop_mode(LoopMode::rate_fps(60.0));
- // draw.background().color(rgba(0.0, 0.0, 0.0, 0.0));
- draw.rect().rgba(0.0, 0.0, 0.0, 0.25).w(win.w()).h(win.h());
- let radius = (app.time / 5.0).sin().abs() * 300.0 ;
- let color_yellow = rgba(1.0, 1.0, 0.0, 0.25);
- let color_cyan = rgba(0.0, 1.0, 1.0, 0.25);
- let color_magenta= rgba(1.0, 0.0, 1.0, 0.25);
- for x in (x_min..=x_max).step_by(x_step) {
- for y in (y_max..=y_min).step_by(y_step) {
- draw.ellipse()
- .x_y(x as f32, y as f32)
- .radius(radius )
- .stroke(color_yellow)
- .stroke_weight(stroke_w)
- .no_fill();
- draw.ellipse()
- .x_y(x as f32, y as f32)
- .radius(radius * 2.0 )
- .stroke(color_cyan)
- .stroke_weight(stroke_w)
- .no_fill();
- draw.ellipse()
- .x_y(x as f32, y as f32)
- .radius(radius * 4.0 )
- .stroke(color_magenta)
- .stroke_weight(stroke_w)
- .no_fill();
- }
- }
- draw.to_frame(app, &frame).unwrap()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement