stash
This commit is contained in:
parent
4c851311aa
commit
4d513fb28d
20
src/main.rs
20
src/main.rs
|
@ -11,6 +11,26 @@ mod point;
|
|||
mod ray;
|
||||
|
||||
fn main() {
|
||||
gen_gradient_ppm();
|
||||
println!("==================================");
|
||||
ray_scene_render();
|
||||
}
|
||||
|
||||
|
||||
fn ray_scene_render() {
|
||||
let aspect_ratio = 16.0/9.0;
|
||||
let image_width = 400;
|
||||
// aleast 1px
|
||||
let image_height = ((image_width as f32 / aspect_ratio) as i32).max(1);
|
||||
|
||||
let viewport_height = 2.0;
|
||||
let viewport_width = viewport_height * (image_width as f32 / image_height as f32);
|
||||
|
||||
println!("set image({},{}), viewport({},{})", image_width, image_height, viewport_width, viewport_height)
|
||||
}
|
||||
|
||||
|
||||
fn gen_gradient_ppm() {
|
||||
let ppm_content = gen_gradient_ppm_p3(400, 225);
|
||||
|
||||
let v1 = Vec3::new(1.0, 1.0, 1.0);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
use std::{fmt::Display, ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}};
|
||||
use std::{fmt::Display, ops::{Add, AddAssign, Div, Mul, MulAssign, Sub}};
|
||||
use std::fmt;
|
||||
/*
|
||||
* [3]
|
||||
|
@ -35,11 +35,6 @@ impl Vec3 {
|
|||
z: self.x * other.y - self.y * other.x,
|
||||
}
|
||||
}
|
||||
|
||||
/// 向量长度
|
||||
fn magnitude(self) -> f32 {
|
||||
(self.x.powi(2) + self.y.powi(2) + self.z.powi(2)).sqrt()
|
||||
}
|
||||
}
|
||||
|
||||
impl Add for Vec3 {
|
||||
|
|
Loading…
Reference in New Issue