Skip to content

Commit b5e2180

Browse files
committed
feat(tahoe-icons): refresh Tahoe folder rendering
1 parent 30a5b52 commit b5e2180

21 files changed

Lines changed: 85 additions & 36 deletions

src/icon_conversion.rs

Lines changed: 85 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,17 @@ pub struct BezelInputs {
6161

6262
pub struct EngravingInputs {
6363
pub fill_color: RGBColor,
64+
pub fill_opacity: f32,
6465
pub top_bezel: BezelInputs,
6566
pub bottom_bezel: BezelInputs,
6667
}
6768

69+
struct MaskProfile {
70+
mask_dimensions: Dimensions,
71+
offset_y: i32,
72+
engraving: EngravingInputs,
73+
}
74+
6875
#[derive(Debug)]
6976
pub struct WorkingDir {
7077
working_dir: Temp,
@@ -237,6 +244,71 @@ impl IconResolution {
237244
}
238245
}
239246

247+
fn tahoe_mask_profile(resolution: &IconResolution) -> MaskProfile {
248+
let size = resolution.size();
249+
MaskProfile {
250+
mask_dimensions: Dimensions {
251+
width: size * 3 / 4,
252+
height: size / 2,
253+
},
254+
offset_y: resolution.offset_y() - (size as i32 / 160),
255+
engraving: EngravingInputs {
256+
fill_color: RGBColor::new(52, 104, 148),
257+
fill_opacity: 0.84,
258+
top_bezel: BezelInputs {
259+
color: RGBColor::new(48, 96, 136),
260+
blur: BlurDown {
261+
spread_px: 0,
262+
page_y: 1,
263+
},
264+
mask_operation: CompositingOperation::Dst_Out,
265+
opacity: 0.18,
266+
},
267+
bottom_bezel: BezelInputs {
268+
color: RGBColor::new(102, 138, 170),
269+
blur: resolution.bottom_bezel_blur_down(),
270+
mask_operation: CompositingOperation::Dst_In,
271+
opacity: 0.2,
272+
},
273+
},
274+
}
275+
}
276+
277+
fn big_sur_mask_profile(
278+
resolution: &IconResolution,
279+
color_scheme: ColorScheme,
280+
) -> MaskProfile {
281+
MaskProfile {
282+
mask_dimensions: Dimensions {
283+
width: resolution.size() * 3 / 4,
284+
height: resolution.size() / 2,
285+
},
286+
offset_y: resolution.offset_y(),
287+
engraving: EngravingInputs {
288+
fill_color: match color_scheme {
289+
ColorScheme::Light => RGBColor::new(8, 134, 206),
290+
ColorScheme::Dark => RGBColor::new(6, 111, 194),
291+
},
292+
fill_opacity: 0.5,
293+
top_bezel: BezelInputs {
294+
color: RGBColor::new(58, 152, 208),
295+
blur: BlurDown {
296+
spread_px: 0,
297+
page_y: 2,
298+
},
299+
mask_operation: CompositingOperation::Dst_In,
300+
opacity: 0.5,
301+
},
302+
bottom_bezel: BezelInputs {
303+
color: RGBColor::new(174, 225, 253),
304+
blur: resolution.bottom_bezel_blur_down(),
305+
mask_operation: CompositingOperation::Dst_Out,
306+
opacity: resolution.bottom_bezel_alpha(),
307+
},
308+
},
309+
}
310+
}
311+
240312
impl Display for IconResolution {
241313
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
242314
write!(
@@ -361,10 +433,9 @@ impl IconConversion {
361433
)?;
362434

363435
self.step("Setting fill opacity");
364-
let fill =
365-
self.simple_operation(&fill_colorized, "2.2_FILL", |args: &mut CommandArgs| {
366-
args.opacity(0.5);
367-
})?;
436+
let fill = self.simple_operation(&fill_colorized, "2.2_FILL", |args: &mut CommandArgs| {
437+
args.opacity(inputs.fill_opacity);
438+
})?;
368439

369440
self.step("Complementing mask for top bezel");
370441
let top_bezel_complement = self.simple_operation(
@@ -491,55 +562,33 @@ impl IconConversion {
491562
// println!("[Starting] {}", inputs.resolution);
492563
// }
493564

494-
let size = icon_inputs.resolution.size();
495-
let offset_y = icon_inputs.resolution.offset_y();
565+
let mask_profile = match icon_inputs.folder_style {
566+
FolderStyle::Tahoe => tahoe_mask_profile(&icon_inputs.resolution),
567+
FolderStyle::BigSur => {
568+
big_sur_mask_profile(&icon_inputs.resolution, icon_inputs.color_scheme)
569+
}
570+
};
496571

497572
self.step_unincremented("Sizing mask");
498573
let sized_mask_path = self
499574
.sized_mask(
500575
full_mask_path,
501576
&ScaledMaskInputs {
502-
icon_size: size,
503-
mask_dimensions: Dimensions {
504-
width: size * 3 / 4,
505-
height: size / 2,
506-
},
507-
offset_y,
577+
icon_size: icon_inputs.resolution.size(),
578+
mask_dimensions: mask_profile.mask_dimensions,
579+
offset_y: mask_profile.offset_y,
508580
},
509581
)
510582
.unwrap();
511583

512584
// TODO
513585
let template_icon = get_folder_icon(icon_inputs);
514586

515-
let fill_color = match (icon_inputs.folder_style, icon_inputs.color_scheme) {
516-
(FolderStyle::Tahoe, _) => RGBColor::new(74, 141, 172),
517-
(_, ColorScheme::Light) => RGBColor::new(8, 134, 206),
518-
(_, ColorScheme::Dark) => RGBColor::new(6, 111, 194),
519-
};
520-
521587
let engraved = self.engrave(
522588
&sized_mask_path,
523589
template_icon,
524590
output_path,
525-
&EngravingInputs {
526-
fill_color,
527-
top_bezel: BezelInputs {
528-
color: RGBColor::new(58, 152, 208),
529-
blur: BlurDown {
530-
spread_px: 0,
531-
page_y: 2,
532-
},
533-
mask_operation: CompositingOperation::Dst_In,
534-
opacity: 0.5,
535-
},
536-
bottom_bezel: BezelInputs {
537-
color: RGBColor::new(174, 225, 253),
538-
blur: icon_inputs.resolution.bottom_bezel_blur_down(),
539-
mask_operation: CompositingOperation::Dst_Out,
540-
opacity: icon_inputs.resolution.bottom_bezel_alpha(),
541-
},
542-
},
591+
&mask_profile.engraving,
543592
);
544593
if let Some(badge) = options.badge {
545594
self.badge_in_place(output_path, badge, &icon_inputs.resolution)?;
1.04 KB
Loading
1.17 KB
Loading
1.39 KB
Loading
1.22 KB
Loading
257 Bytes
Loading
1.6 KB
Loading
1.21 KB
Loading
1.14 KB
Loading
1.6 KB
Loading

0 commit comments

Comments
 (0)