Skip to content

Commit

Permalink
[#42] Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Sep 22, 2023
1 parent 2a923c4 commit f31f733
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
59 changes: 59 additions & 0 deletions rpg_tools_rendering/examples/footwear.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
extern crate rpg_tools_core;
extern crate rpg_tools_rendering;

use crate::utils::render::render_2_sets;
use rpg_tools_core::model::character::appearance::body::{Body, BodyShape};
use rpg_tools_core::model::character::appearance::Appearance;
use rpg_tools_core::model::color::Color;
use rpg_tools_core::model::equipment::appearance::footwear::{Footwear, FootwearStyle, Sole};
use rpg_tools_core::model::equipment::appearance::Clothing;
use rpg_tools_core::model::length::Length;
use rpg_tools_core::model::width::Width;

pub mod utils;

fn main() {
let mut options = Vec::new();

for style in FootwearStyle::get_all() {
for width in Width::get_all() {
options.push(create(style, width));
}
}

render_2_sets(
"footwear.svg",
options,
BodyShape::get_all(),
create_appearance,
true,
);
}

fn create(style: FootwearStyle, width: Width) -> Footwear {
Footwear {
color: Color::SaddleBrown,
style,
sole: Sole {
color: Color::Gray,
width,
},
}
}

fn create_appearance(height: Length, footwear: &Footwear, shape: &BodyShape) -> Appearance {
Appearance::humanoid(
Body {
shape: *shape,
width: Default::default(),
skin: Default::default(),
clothing: Clothing::Simple {
footwear: *footwear,
pants: Default::default(),
shirt: Default::default(),
},
},
Default::default(),
height,
)
}
4 changes: 1 addition & 3 deletions rpg_tools_rendering/examples/hair_long.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ extern crate rpg_tools_rendering;

use crate::utils::appearance::create_humanoid_with_hair;
use crate::utils::render::render_2_sets;
use rpg_tools_core::model::character::appearance::hair::hairline::{Hairline, HairlineStyle};
use rpg_tools_core::model::character::appearance::hair::long::LongHairStyle;
use rpg_tools_core::model::character::appearance::hair::Hair;
use rpg_tools_core::model::character::appearance::head::HeadShape;
use rpg_tools_core::model::color::Color;
use rpg_tools_core::model::length::Length;
use rpg_tools_core::model::size::Size;

pub mod utils;

Expand All @@ -34,7 +32,7 @@ fn main() {
fn create_long(style: LongHairStyle, length: f32) -> Hair {
Hair::Long {
style,
hairline: Hairline::new(HairlineStyle::Straight, Size::Medium),
hairline: Default::default(),
length: Length::from_metre(length),
color: Color::SaddleBrown,
}
Expand Down
1 change: 1 addition & 0 deletions rpg_tools_rendering/examples/pants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ fn create_appearance(height: Length, pants: &Pants, shape: &BodyShape) -> Appear
width: Default::default(),
skin: Default::default(),
clothing: Clothing::Simple {
footwear: Default::default(),
pants: *pants,
shirt: Default::default(),
},
Expand Down
1 change: 1 addition & 0 deletions rpg_tools_rendering/examples/shirts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ fn create_appearance(height: Length, shirt: &Shirt, shape: &BodyShape) -> Appear
width: Default::default(),
skin: Default::default(),
clothing: Clothing::Simple {
footwear: Default::default(),
pants: Default::default(),
shirt: *shirt,
},
Expand Down
7 changes: 6 additions & 1 deletion rpg_tools_rendering/src/rendering/equipment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ pub fn render_clothing(
body: &Body,
from_front: bool,
) {
if let Clothing::Simple { pants, shirt } = &body.clothing {
if let Clothing::Simple {
footwear,
pants,
shirt,
} = &body.clothing
{
render_shirt(renderer, config, aabb, body, shirt, from_front);
render_pants(renderer, config, aabb, body, pants);
}
Expand Down

0 comments on commit f31f733

Please sign in to comment.