...
Tawesoft Logo

Package xcolor

import "tawesoft.co.uk/go/ximage/xcolor"
Overview
Index

Overview ▾

Package xcolor implements Red, RedGreen, and RGB color models matching the core image/color interface.

Note that there are good reasons these color types aren't in the core image.color package. The native color types may have optimized fast-paths for many use cases.

This package is a tradeoff of these optimizations against lower memory usage. This package is intended to be used in computer graphics (e.g. OpenGL) where images are uploaded to the GPU in a specific format (such as GL_R, GL_RG, or GL_RGB) and we don't care about the performance of native Go image manipulation.

OpenGL® and the oval logo are trademarks or registered trademarks of Hewlett Packard Enterprise in the United States and/or other countries worldwide.

Package Information

License: BSD-3-Clause (see LICENSE.txt)

Stable: yes

For more information, documentation, source code, examples, support, links, etc. please see https://www.tawesoft.co.uk/go and https://www.tawesoft.co.uk/go/ximage/xcolor

Variables

var RGBModel color.Model = color.ModelFunc(rgbModel)
var RGModel color.Model = color.ModelFunc(func(c color.Color) color.Color {
    if _, ok := c.(color.RGBA); ok {
        return c
    }
    r, g, _, _ := c.RGBA()
    return RG{uint8(r >> 8), uint8(g >> 8)}
})
var RedModel color.Model = color.ModelFunc(redModel)

type RG

Red represents an 8-bit Red 8-bit Green color.

type RG struct {
    R uint8
    G uint8
}

func (RG) RGBA

func (c RG) RGBA() (r, g, b, a uint32)

type RGB

RGB represents an 8-bit Red 8-bit Green 8-bit Blue color.

type RGB struct {
    R uint8
    G uint8
    B uint8
}

func (RGB) RGBA

func (c RGB) RGBA() (r, g, b, a uint32)

type Red

Red represents an 8-bit red color.

type Red struct {
    R uint8
}

func (Red) RGBA

func (c Red) RGBA() (r, g, b, a uint32)