Skip to content

Commit

Permalink
[#42] Start sole rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Sep 23, 2023
1 parent 91ba9dd commit bb62799
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 29 deletions.
10 changes: 1 addition & 9 deletions rpg_tools_core/src/model/equipment/appearance/footwear.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::model::color::Color;
use crate::model::width::Width;
use macro_convert::Convert;
use macro_ui::ui;
use serde::{Deserialize, Serialize};
Expand All @@ -9,7 +8,7 @@ use serde::{Deserialize, Serialize};
pub struct Footwear {
pub color: Color,
pub style: FootwearStyle,
pub sole: Sole,
pub sole: Color,
}

/// What style of [`footwear`](Footwear)?
Expand All @@ -22,10 +21,3 @@ pub enum FootwearStyle {
Shoe,
Slippers,
}

/// The sole of [`footwear`](Footwear).
#[derive(ui, Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Sole {
pub color: Color,
pub width: Width,
}
16 changes: 5 additions & 11 deletions rpg_tools_rendering/examples/footwear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,33 @@ 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::footwear::{Footwear, FootwearStyle};
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));
}
options.push(create(style));
}

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

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

Expand Down
12 changes: 3 additions & 9 deletions rpg_tools_rendering/src/rendering/equipment/footwear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::renderer::Renderer;
use crate::rendering::config::RenderConfig;
use rpg_tools_core::model::character::appearance::body::Body;
use rpg_tools_core::model::equipment::appearance::footwear::Footwear;
use rpg_tools_core::model::width::Width;

pub fn render_footwear(
renderer: &mut dyn Renderer,
Expand Down Expand Up @@ -38,15 +37,10 @@ fn render_sole(
footwear: &Footwear,
center_x: f32,
) {
let options = config.get_options(footwear.sole.color);
let width = config.body.get_foot_radius_factor(body) * 2.0;
let options = config.get_options(footwear.sole);
let width = config.body.get_foot_radius_factor(body) * 2.0 * 1.05;
let y_start = config.body.y_foot;
let y_end = y_start
+ match footwear.sole.width {
Width::Thin => 0.02,
Width::Average => 0.04,
Width::Wide => 0.06,
};
let y_end = y_start + 0.02;
let mut builder = Polygon2dBuilder::new();

builder.add_horizontal_pair(aabb, width, center_x, y_start, true);
Expand Down

0 comments on commit bb62799

Please sign in to comment.