From e966fa71060a600aa393af55f6d6607a93960f4f Mon Sep 17 00:00:00 2001 From: zhaori96 Date: Wed, 31 Jul 2024 16:03:52 -0300 Subject: [PATCH] Add ColorScheme type and predefined color schemes for barcode rendering --- color_scheme.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 color_scheme.go diff --git a/color_scheme.go b/color_scheme.go new file mode 100644 index 0000000..e8ccc7a --- /dev/null +++ b/color_scheme.go @@ -0,0 +1,39 @@ +package barcode + +import "image/color" + +// ColorScheme defines a structure for color schemes used in barcode rendering. +// It includes the color model, background color, and foreground color. +type ColorScheme struct { + Model color.Model // Color model to be used (e.g., grayscale, RGB, RGBA) + Background color.Color // Color of the background + Foreground color.Color // Color of the foreground (e.g., bars in a barcode) +} + +// ColorScheme8 represents a color scheme with 8-bit grayscale colors. +var ColorScheme8 = ColorScheme{ + Model: color.GrayModel, + Background: color.Gray{Y: 255}, + Foreground: color.Gray{Y: 0}, +} + +// ColorScheme16 represents a color scheme with 16-bit grayscale colors. +var ColorScheme16 = ColorScheme{ + Model: color.Gray16Model, + Background: color.White, + Foreground: color.Black, +} + +// ColorScheme24 represents a color scheme with 24-bit RGB colors. +var ColorScheme24 = ColorScheme{ + Model: color.RGBAModel, + Background: color.RGBA{255, 255, 255, 255}, + Foreground: color.RGBA{0, 0, 0, 255}, +} + +// ColorScheme32 represents a color scheme with 32-bit RGBA colors, which is similar to ColorScheme24 but typically includes alpha for transparency. +var ColorScheme32 = ColorScheme{ + Model: color.RGBAModel, + Background: color.RGBA{255, 255, 255, 255}, + Foreground: color.RGBA{0, 0, 0, 255}, +}