From e8e52a74a7ce10de1df697912cf24daf54baf6a6 Mon Sep 17 00:00:00 2001 From: zhaori96 Date: Wed, 24 Jul 2024 10:08:05 -0300 Subject: [PATCH] add functions for color models and colors based on depth in utils package --- utils/depth.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 utils/depth.go diff --git a/utils/depth.go b/utils/depth.go new file mode 100644 index 0000000..0bb051b --- /dev/null +++ b/utils/depth.go @@ -0,0 +1,36 @@ +package utils + +import "image/color" + +func ColorModel(depth int) color.Model { + switch depth { + case 8: + return color.GrayModel + case 24, 32: + return color.RGBAModel + default: + return color.Gray16Model + } +} + +func WhiteColor(depth int) color.Color { + switch depth { + case 8: + return color.Gray{Y: 255} + case 24, 32: + return color.RGBA{255, 255, 255, 255} + default: + return color.White + } +} + +func BlackColor(depth int) color.Color { + switch depth { + case 8: + return color.Gray{Y: 0} + case 24, 32: + return color.RGBA{0, 0, 0, 255} + default: + return color.Black + } +}