Skip to content

Commit

Permalink
[#46] Improve EyewearConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Nov 1, 2023
1 parent 87a93c6 commit afaa145
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions rpg_tools_rendering/src/rendering/config/equipment/eyewear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use rpg_tools_core::model::equipment::appearance::eyewear::FrameType;
pub struct EyewearConfig {
pub bridge_factor: f32,
pub radius_factor: f32,
pub radius_y_factor: f32,
pub thickness_horn: f32,
pub thickness_rimmed: f32,
pub thickness_wire: f32,
Expand All @@ -15,6 +16,10 @@ impl EyewearConfig {
(eye_radius as f32 * self.radius_factor) as u32
}

pub fn get_radius_y(&self, radius_x: u32) -> u32 {
(radius_x as f32 * self.radius_y_factor) as u32
}

pub fn get_bridge_height(&self, width: u32, frame_type: FrameType) -> u32 {
let thickness = match frame_type {
FrameType::Rimless => self.thickness_wire,
Expand Down
1 change: 1 addition & 0 deletions rpg_tools_rendering/src/rendering/config/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ pub fn create_config() -> RenderConfig {
eyewear: EyewearConfig {
bridge_factor: 0.1,
radius_factor: 1.4,
radius_y_factor: 0.8,
thickness_horn: 5.0,
thickness_rimmed: 3.0,
thickness_wire: 1.0,
Expand Down
2 changes: 1 addition & 1 deletion rpg_tools_rendering/src/rendering/equipment/eyewear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn render_lens(
style,
config.eyewear.get_frame_thickness(style.frame_type),
);
let radius_y = (radius as f32 * 0.8) as u32;
let radius_y = config.eyewear.get_radius_y(radius);

match style.lens_shape {
LensShape::Circle => renderer.render_circle(center, radius, &options),
Expand Down

0 comments on commit afaa145

Please sign in to comment.