Skip to content

Commit

Permalink
[#36] Fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Sep 11, 2023
1 parent 195b2ae commit 1060451
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 28 deletions.
10 changes: 10 additions & 0 deletions rpg_tools_core/src/model/character/appearance/skin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ impl Default for Skin {
}
}

impl Skin {
pub fn exotic(color: Color) -> Skin {
Self::ExoticSkin { color }
}

pub fn skin(color: SkinColor) -> Skin {
Self::Skin { color }
}
}

/// The skin color of a [`Character`](crate::model::character::Character).
#[derive(Convert, ui, Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum SkinColor {
Expand Down
6 changes: 4 additions & 2 deletions rpg_tools_rendering/examples/beards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn create_appearance(height: Length, beard: &Beard, face: &HeadShape) -> Appeara
},
hair: Hair::Short {
style: ShortHair::MiddlePart,
hairline: Hairline::Round(Medium),
hairline: Hairline::Round { size: Medium },
color: Color::SaddleBrown,
},
mouth: Mouth::Simple {
Expand All @@ -99,7 +99,9 @@ fn create_appearance(height: Length, beard: &Beard, face: &HeadShape) -> Appeara
teeth_color: TeethColor::White,
},
shape: *face,
skin: Skin::Skin(SkinColor::Light),
skin: Skin::Skin {
color: SkinColor::Light,
},
},
height,
)
Expand Down
6 changes: 3 additions & 3 deletions rpg_tools_rendering/examples/beards_full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn create_appearance(height: Length, beard: &Beard, face: &HeadShape) -> Appeara
Body {
shape: BodyShape::Rectangle,
width: Width::Average,
skin: Skin::Skin(SkinColor::Light),
skin: Skin::akin(SkinColor::Light),
},
Head {
ears: Ears::Normal {
Expand All @@ -74,7 +74,7 @@ fn create_appearance(height: Length, beard: &Beard, face: &HeadShape) -> Appeara
},
hair: Hair::Short {
style: ShortHair::MiddlePart,
hairline: Hairline::Round(Medium),
hairline: Hairline::Round { size: Medium },
color: Color::SaddleBrown,
},
mouth: Mouth::Simple {
Expand All @@ -84,7 +84,7 @@ fn create_appearance(height: Length, beard: &Beard, face: &HeadShape) -> Appeara
teeth_color: TeethColor::White,
},
shape: *face,
skin: Skin::Skin(SkinColor::Light),
skin: Skin::skin(SkinColor::Light),
},
height,
)
Expand Down
2 changes: 1 addition & 1 deletion rpg_tools_rendering/examples/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() {
}

fn create_appearance(height: Length, width: &Width, shape: &BodyShape) -> Appearance {
let skin = Skin::Skin(SkinColor::Light);
let skin = Skin::skin(SkinColor::Light);
Appearance::humanoid(
Body {
shape: *shape,
Expand Down
6 changes: 3 additions & 3 deletions rpg_tools_rendering/examples/ears.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ fn create_appearance(height: Length, ears: &Ears, face: &HeadShape) -> Appearanc
distance: Medium,
},
hair: Hair::Short {
style: ShortHair::SidePart(Left),
hairline: Hairline::Round(Medium),
style: ShortHair::SidePart { side: Left },
hairline: Hairline::Round { size: Medium },
color: Color::Yellow,
},
mouth: Mouth::Simple {
Expand All @@ -69,7 +69,7 @@ fn create_appearance(height: Length, ears: &Ears, face: &HeadShape) -> Appearanc
teeth_color: TeethColor::White,
},
shape: *face,
skin: Skin::Skin(SkinColor::Light),
skin: Skin::skin(SkinColor::Light),
},
height,
)
Expand Down
2 changes: 1 addition & 1 deletion rpg_tools_rendering/examples/eye_shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn create_appearance(height: Length, shape: &EyeShape, face: &HeadShape) -> Appe
hair: Hair::None,
mouth: Mouth::None,
shape: *face,
skin: Skin::Scales(Color::Red),
skin: Skin::exotic(Color::Red),
},
height,
)
Expand Down
4 changes: 2 additions & 2 deletions rpg_tools_rendering/examples/eyebrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn create_appearance(
},
hair: Hair::Short {
style: ShortHair::MiddlePart,
hairline: Hairline::Round(Medium),
hairline: Hairline::Round { size: Medium },
color: Color::SaddleBrown,
},
mouth: Mouth::Simple {
Expand All @@ -95,7 +95,7 @@ fn create_appearance(
teeth_color: TeethColor::White,
},
shape: HeadShape::Round,
skin: Skin::Skin(SkinColor::Light),
skin: Skin::akin(SkinColor::Light),
},
height,
)
Expand Down
2 changes: 1 addition & 1 deletion rpg_tools_rendering/examples/hair_bun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn create_bun(style: BunStyle, size: Size) -> Hair {
Hair::Bun {
style,
size,
hairline: Hairline::Straight(Size::Small),
hairline: Hairline::Straight { size: Size::Small },
color: Color::SaddleBrown,
}
}
2 changes: 1 addition & 1 deletion rpg_tools_rendering/examples/hair_long.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn main() {
fn create_long(style: LongHairStyle, length: f32) -> Hair {
Hair::Long {
style,
hairline: Hairline::Straight(Size::Medium),
hairline: Hairline::Straight { size: Size::Medium },
length: Length::from_metre(length),
color: Color::SaddleBrown,
}
Expand Down
2 changes: 1 addition & 1 deletion rpg_tools_rendering/examples/hair_ponytail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn create_ponytail(position: PonytailPosition, style: PonytailStyle) -> Hair {
position,
style,
length: Length::from_metre(1.0),
hairline: Hairline::Straight(Size::Medium),
hairline: Hairline::Straight { size: Size::Medium },
color: Color::SaddleBrown,
})
}
4 changes: 2 additions & 2 deletions rpg_tools_rendering/examples/mouth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn create_normal(width: Size, teeth: Size) -> Mouth {
Mouth::Simple {
beard: Beard::None,
width,
teeth: SpecialTeeth::LowerFangs(teeth),
teeth: SpecialTeeth::LowerFangs { size: teeth },
teeth_color: TeethColor::White,
}
}
Expand Down Expand Up @@ -81,7 +81,7 @@ fn create_appearance(height: Length, mouth: &Mouth, face: &HeadShape) -> Appeara
hair: Hair::None,
mouth: *mouth,
shape: *face,
skin: Skin::Scales(Color::Red),
skin: Skin::exotic(Color::Red),
},
height,
)
Expand Down
2 changes: 1 addition & 1 deletion rpg_tools_rendering/examples/pupil_shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn create_appearance(height: Length, pupil_shape: &PupilShape, eye_shape: &EyeSh
hair: Hair::None,
mouth: Mouth::None,
shape: HeadShape::Oval,
skin: Skin::Skin(SkinColor::Light),
skin: Skin::skin(SkinColor::Light),
},
height,
)
Expand Down
16 changes: 8 additions & 8 deletions rpg_tools_rendering/examples/teeth_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ pub mod utils;
fn main() {
let teeth_colors = vec![TeethColor::White, TeethColor::Yellow, TeethColor::Brown];
let skin = vec![
Skin::Skin(SkinColor::Fair),
Skin::Skin(SkinColor::Light),
Skin::Skin(SkinColor::Medium),
Skin::Skin(SkinColor::Tan),
Skin::Skin(SkinColor::Dark),
Skin::Skin(SkinColor::VeryDark),
Skin::ExoticSkin(Color::Green),
Skin::skin(SkinColor::Fair),
Skin::skin(SkinColor::Light),
Skin::skin(SkinColor::Medium),
Skin::skin(SkinColor::Tan),
Skin::skin(SkinColor::Dark),
Skin::skin(SkinColor::VeryDark),
Skin::exotic(Color::Green),
];

render_2_sets(
Expand Down Expand Up @@ -58,7 +58,7 @@ fn create_appearance(height: Length, skin: &Skin, color: &TeethColor) -> Appeara
mouth: Mouth::Simple {
beard: Beard::None,
width: Large,
teeth: SpecialTeeth::LowerFangs(Large),
teeth: SpecialTeeth::LowerFangs { size: Large },
teeth_color: *color,
},
shape: HeadShape::Oval,
Expand Down
8 changes: 6 additions & 2 deletions rpg_tools_rendering/examples/utils/appearance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ pub fn create_head_with_hair(height: Length, hair: &Hair, shape: &HeadShape) ->

pub fn create_humanoid_with_hair(height: Length, hair: &Hair, shape: &HeadShape) -> Appearance {
Appearance::humanoid(
Body::with_skin(Skin::Skin(SkinColor::Light)),
Body::with_skin(Skin::Skin {
color: SkinColor::Light,
}),
create_head(*shape, hair),
height,
)
Expand Down Expand Up @@ -50,6 +52,8 @@ fn create_head(shape: HeadShape, hair: &Hair) -> Head {
teeth_color: TeethColor::White,
},
shape,
skin: Skin::Skin(SkinColor::Light),
skin: Skin::Skin {
color: SkinColor::Light,
},
}
}

0 comments on commit 1060451

Please sign in to comment.