Struct CameraConfig

Source
pub struct CameraConfig { /* private fields */ }
Expand description

Camera configuration struct implementing the builder pattern.

Implementations§

Source§

impl CameraConfig

Source

pub fn new(radius: Float, alpha: Float, beta: Float) -> Self

Creates a new CameraConfig.

§Arguments
  • r is the distance from the camera to the origin.
  • alfa is camera’s angle along the xy plane.
  • beta is camera’s angle along z axis.
Source

pub fn default() -> Self

Creates a new CameraConfig using default values.

Examples found in repository?
examples/texture_from_file.rs (line 10)
3fn main() {
4    // use config builder to create a new globe struct
5    let globe = GlobeConfig::new()
6        // specify path to the texture file
7        .with_texture_at("textures/earth.txt", None)
8        // for built-in textures try using a template
9        //.use_template(GlobeTemplate::Earth)
10        .with_camera(CameraConfig::default())
11        .build();
12
13    // create a new canvas
14    let mut canvas = Canvas::new(250, 250, None);
15
16    // render the globe onto the canvas
17    globe.render_on(&mut canvas);
18
19    // print out the canvas
20    let (size_x, size_y) = canvas.get_size();
21    for i in 0..size_y / 8 {
22        for j in 0..size_x / 4 {
23            print!("{}", canvas.matrix[i][j]);
24        }
25        println!();
26    }
27}
Source

pub fn build(&self) -> Camera

Builds a camera from the collected config information.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.