More idiomatic constructors.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use anyhow::{bail, Result};
|
||||
|
||||
use rtchallenge::{
|
||||
canvas::{canvas, Canvas},
|
||||
tuples::{color, point, vector, Tuple},
|
||||
canvas::Canvas,
|
||||
tuples::{Color, Tuple},
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -23,7 +23,7 @@ fn tick(env: &Environment, proj: &Projectile) -> Projectile {
|
||||
}
|
||||
|
||||
fn draw_dot(c: &mut Canvas, x: usize, y: usize) {
|
||||
let red = color(1., 0., 0.);
|
||||
let red = Color::new(1., 0., 0.);
|
||||
c.set(x.saturating_sub(1), y.saturating_sub(1), red);
|
||||
c.set(x, y.saturating_sub(1), red);
|
||||
c.set(x + 1, y.saturating_sub(1), red);
|
||||
@@ -35,16 +35,16 @@ fn draw_dot(c: &mut Canvas, x: usize, y: usize) {
|
||||
c.set(x + 1, y + 1, red);
|
||||
}
|
||||
fn main() -> Result<()> {
|
||||
let position = point(0., 1., 0.);
|
||||
let velocity = vector(1., 1.8, 0.).normalize() * 11.25;
|
||||
let position = Tuple::point(0., 1., 0.);
|
||||
let velocity = Tuple::vector(1., 1.8, 0.).normalize() * 11.25;
|
||||
let mut p = Projectile { position, velocity };
|
||||
let gravity = vector(0., -0.1, 0.);
|
||||
let wind = vector(-0.01, 0., 0.);
|
||||
let gravity = Tuple::vector(0., -0.1, 0.);
|
||||
let wind = Tuple::vector(-0.01, 0., 0.);
|
||||
let e = Environment { gravity, wind };
|
||||
|
||||
let w = 800;
|
||||
let h = 600;
|
||||
let mut c = canvas(w, h);
|
||||
let mut c = Canvas::new(w, h);
|
||||
let mut i = 0;
|
||||
let w = w as f32;
|
||||
let h = h as f32;
|
||||
|
||||
Reference in New Issue
Block a user