MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / blend_colors

Function blend_colors

crates/opencode-tui/src/components/logo.rs:21–31  ·  view source on GitHub ↗
(fg: Color, bg: Color)

Source from the content-addressed store, hash-verified

19const SHADOW_TINT_FACTOR: f32 = 0.25;
20
21fn blend_colors(fg: Color, bg: Color) -> Color {
22 match (fg, bg) {
23 (Color::Rgb(r1, g1, b1), Color::Rgb(r2, g2, b2)) => {
24 let r = ((1.0 - SHADOW_TINT_FACTOR) * r2 as f32 + SHADOW_TINT_FACTOR * r1 as f32) as u8;
25 let g = ((1.0 - SHADOW_TINT_FACTOR) * g2 as f32 + SHADOW_TINT_FACTOR * g1 as f32) as u8;
26 let b = ((1.0 - SHADOW_TINT_FACTOR) * b2 as f32 + SHADOW_TINT_FACTOR * b1 as f32) as u8;
27 Color::Rgb(r, g, b)
28 }
29 _ => bg,
30 }
31}
32
33/// Parse a single logo line, replacing marker characters with styled shadow spans.
34/// `bold` controls whether non-marker characters get the BOLD modifier (used for the right half).

Callers 1

parse_logo_lineFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected