From b0108e6e0b3918f1155291aa8ee0d49e9a92b8d3 Mon Sep 17 00:00:00 2001 From: "sashakoshka@tebibyte.media" Date: Wed, 26 Jun 2024 10:40:22 -0400 Subject: [PATCH] Added a function to convert any color to color.RGBA --- image/color/color.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/image/color/color.go b/image/color/color.go index b24632b..d763713 100644 --- a/image/color/color.go +++ b/image/color/color.go @@ -7,3 +7,14 @@ func Transparent (c color.Color) bool { _, _, _, a := c.RGBA() return a != 0xFFFF } + +// ToRGBA converts any color to a color.RGBA value. +func ToRGBA (c color.Color) color.RGBA { + r, g, b, a := c.RGBA() + return color.RGBA { + uint8(r >> 8), + uint8(g >> 8), + uint8(b >> 8), + uint8(a >> 8), + } +}