hsvimage

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

README

hsvimage and hsvcolor

Go Report Card GoDoc

The Go programming language's standard library provides support for manipulating graphical images represented using RGB, CMYK, YCbCr, and grayscale color models and variations such as 8- vs. 16-bit channels, premultiplied alpha vs. non-premultiplied alpha vs. no alpha, and paletted color. hsvimage augments the Go standard library with support for the HSV color model.

Usage

hsvimage provides an hsvimage.NHSVA image type (Non-alpha-premultiplied Hue, Saturation, and Value with Alpha) that implements the image.Image interface. The underlying NHSVA color model and NHSVA data type are provided by hsvimage/hsvcolor. hsvimage and hsvimage/hsvcolor can be imported in the usual manner:

import (
	"github.com/spakin/hsvimage"
	"github.com/spakin/hsvimage/hsvcolor"
)

Author

Scott Pakin, scott+hsv@pakin.org

Documentation

Overview

Package hsvimage implements the image.Image interface with HSV + alpha images. The code was largely adapted from code in the Go standard library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NHSVA

type NHSVA struct {
	// Pix holds the image's pixels, in H, S, V, A order. The pixel at
	// (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4].
	Pix []uint8
	// Stride is the Pix stride (in bytes) between vertically adjacent pixels.
	Stride int
	// Rect is the image's bounds.
	Rect image.Rectangle
}

NHSVA is an in-memory image whose At method returns hsvcolor.NHSVA values.

func NewNHSVA

func NewNHSVA(r image.Rectangle) *NHSVA

NewNHSVA returns a new NHSVA image with the given bounds.

func (*NHSVA) At

func (p *NHSVA) At(x, y int) color.Color

At returns the color at the given image coordinates.

func (*NHSVA) Bounds

func (p *NHSVA) Bounds() image.Rectangle

Bounds returns the image's bounding rectangle.

func (*NHSVA) ColorModel

func (p *NHSVA) ColorModel() color.Model

ColorModel states that an NHSVA image uses the hsvcolor.NHSVA color model.

func (*NHSVA) NHSVAAt

func (p *NHSVA) NHSVAAt(x, y int) hsvcolor.NHSVA

NHSVAAt returns the color at the given image coordinates as specifically an hsvcolor.NHSVA color.

func (*NHSVA) Opaque

func (p *NHSVA) Opaque() bool

Opaque scans the entire image and reports whether it is fully opaque.

func (*NHSVA) PixOffset

func (p *NHSVA) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*NHSVA) Set

func (p *NHSVA) Set(x, y int, c color.Color)

Set assigns an arbitrary color to a given coordinate.

func (*NHSVA) SetNHSVA

func (p *NHSVA) SetNHSVA(x, y int, c hsvcolor.NHSVA)

SetNHSVA assigns an NHSVA color to a given coordinate.

func (*NHSVA) SubImage

func (p *NHSVA) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

Directories

Path Synopsis
Package hsvcolor provides HSV color models.
Package hsvcolor provides HSV color models.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL