Struct create_vox::Voxobject[][src]

pub struct Voxobject { /* fields omitted */ }

Holds all the information needed to create a vox file.

Implementations

impl Voxobject[src]

pub fn new(size_x: u16, size_y: u16, size_z: u16) -> Voxobject[src]

Creates a new voxobject with the given size. Size needs to be between 1-255 on all axis.

Example

use create_vox::Voxobject;

let mut my_vox = Voxobject::new(100,150,100);

pub fn add_gradient(
    &mut self,
    index1: u8,
    index2: u8,
    color1: Color,
    color2: Color
)
[src]

Adds a gradient between the 2 indexes in the palette with the 2 colors.

Example

use create_vox::{Voxobject, Color};

let mut my_vox = Voxobject::new(10,10,10);
let color1 = Color::new(255,255,0,255);
let color2 = Color::new(0,255,255,255);
my_vox.add_gradient(1,100,color1,color2);

pub fn add_voxel(&mut self, new_voxel: Voxel) -> Result<(), &str>[src]

Adds one voxel to the voxobject.

Example

use create_vox::{Voxobject, Voxel};

let mut my_vox = Voxobject::new(20,20,20);
let voxel = Voxel::new(0,0,0,100);
my_vox.add_voxel(voxel).unwrap();

pub fn add_voxel_at_pos(
    &mut self,
    x: u8,
    y: u8,
    z: u8,
    voxel_index: u8
) -> Result<(), &str>
[src]

Adds a voxel at the position specified.

Example

use create_vox::Voxobject;

let mut my_vox = Voxobject::new(10,10,10);
my_vox.add_voxel_at_pos(3,7,3,1).unwrap();

pub fn clear_voxels(&mut self)[src]

Deletes all voxels in the Voxobject

Example

use create_vox::Voxobject;

let mut my_vox = Voxobject::new(10,10,10);
my_vox.add_voxel_at_pos(3,7,3,1).unwrap();
my_vox.add_voxel_at_pos(3,6,3,2).unwrap();
my_vox.add_voxel_at_pos(3,5,3,3).unwrap();
my_vox.clear_voxels();

pub fn reset_palette(&mut self)[src]

Resets all indexes in the pallete to the default color

Example

use create_vox::Voxobject;

let mut my_vox = Voxobject::new(10,10,10);
my_vox.set_all_palette_color(255, 100, 0, 255);
my_vox.reset_palette();

pub fn num_of_voxels(&self) -> i32[src]

Number of voxes in the Voxobject

Example

use create_vox::Voxobject;

let mut my_vox = Voxobject::new(10,10,10);
my_vox.add_voxel_at_pos(3,7,3,1).unwrap();
my_vox.add_voxel_at_pos(3,6,3,2).unwrap();
my_vox.add_voxel_at_pos(3,5,3,3).unwrap();
assert_eq!(3, my_vox.num_of_voxels())

pub fn set_size(&mut self, x: u16, y: u16, z: u16)[src]

Sets the size of a Voxobject

Example

use create_vox::Voxobject;

let mut my_vox = Voxobject::new(10,10,10);
my_vox.set_size(5,5,5);

pub fn auto_size(&mut self)[src]

Changes the size of the voxobject to fit the voxels

Example

use create_vox::Voxobject;

let mut my_vox = Voxobject::new(100,100,100);
my_vox.add_voxel_at_pos(1,23,2,3);
my_vox.add_cube(40,40,55,60,44,60,1);
my_vox.auto_size();

pub fn set_palette_color(&mut self, index: u8, r: u8, g: u8, b: u8, a: u8)[src]

Sets the color of a specific index on the palette

Examples

use create_vox::Voxobject;

let mut my_vox = Voxobject::new(10,10,10);
my_vox.set_palette_color(1,255,0,0,255);

pub fn set_all_palette_color(&mut self, r: u8, g: u8, b: u8, a: u8)[src]

Sets color for all indexes on the palette

Example

use create_vox::Voxobject;

let mut my_vox = Voxobject::new(10,10,10);
my_vox.set_all_palette_color(0,255,0,255);

pub fn add_cube(
    &mut self,
    startx: u8,
    starty: u8,
    startz: u8,
    endx: u8,
    endy: u8,
    endz: u8,
    colorindex: u8
) -> Result<(), &str>
[src]

Adds a cube of voxels in the voxobject.

Example

use create_vox::Voxobject;
let mut my_vox = Voxobject::new(100,100,100);
my_vox.add_cube(25,25,25,75,75,75,1).unwrap();

pub fn save_as_file(&mut self, name: &str)[src]

Creates a file and saves the voxobject to it.

Example

use create_vox::{Voxobject, Voxel};

let mut my_vox = Voxobject::new(10,10,10);
my_vox.set_all_palette_color(255,0,0,255);
my_vox.add_voxel(Voxel::new(0,0,0,1)).unwrap();
my_vox.save_as_file("my_vox.vox");

Trait Implementations

impl Add<Voxel> for Voxobject[src]

type Output = Voxobject

The resulting type after applying the + operator.

impl Add<Voxobject> for Voxobject[src]

type Output = Voxobject

The resulting type after applying the + operator.

impl AddAssign<Voxel> for Voxobject[src]

impl AddAssign<Voxobject> for Voxobject[src]

impl Clone for Voxobject[src]

impl PartialEq<Voxobject> for Voxobject[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.