Struct truster::camera::Camera[][src]

pub struct Camera { /* fields omitted */ }
Expand description

Represents a camera which can be used together with an instance of crate::world::World to render a scene.

Implementations

Returns a new Camera corresponding to cfg.

Returns a ray for the pixel at the given coordinates.

Examples

Constructing a ray through the center of the canvas

use std::f64::consts::PI;
use truster::ray::Ray;
use truster::tuple::Tuple;

let camera = Camera::new(Config {
    hsize: 201,
    vsize: 101,
    fov: PI / 2.0,
    ..Config::default()
});
let ray = camera.ray_for_pixel(100, 50);
// ray == Ray::new(Tuple::point(0.0, 0.0, 0.0), Tuple::vector(0.0, 0.0, -1.0))); // approximately

Renders the world to a canvas as seen from self and returns it.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.