MCPcopy
hub / github.com/Textualize/rich / blend_rgb

Function blend_rgb

rich/color.py:580–591  ·  view source on GitHub ↗

Blend one RGB color in to another.

(
    color1: ColorTriplet, color2: ColorTriplet, cross_fade: float = 0.5
)

Source from the content-addressed store, hash-verified

578
579
580def blend_rgb(
581 color1: ColorTriplet, color2: ColorTriplet, cross_fade: float = 0.5
582) -> ColorTriplet:
583 """Blend one RGB color in to another."""
584 r1, g1, b1 = color1
585 r2, g2, b2 = color2
586 new_color = ColorTriplet(
587 int(r1 + (r2 - r1) * cross_fade),
588 int(g1 + (g2 - g1) * cross_fade),
589 int(b1 + (b2 - b1) * cross_fade),
590 )
591 return new_color
592
593
594if __name__ == "__main__": # pragma: no cover

Callers 5

test_blend_rgbFunction · 0.90
get_html_styleMethod · 0.85
_get_pulse_segmentsMethod · 0.85
get_svg_styleMethod · 0.85

Calls 1

ColorTripletClass · 0.85

Tested by 1

test_blend_rgbFunction · 0.72