limage

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: ISC Imports: 5 Imported by: 0

README

limage

-- import "github.com/MJKWoolnough/limage"

Package limage introduces structures to read and build layered images

Usage

type Composite
type Composite uint32

Composite determines how two layers are composed together

const (
	CompositeNormal          Composite = 0
	CompositeDissolve        Composite = 1
	CompositeBehind          Composite = 2
	CompositeMultiply        Composite = 3
	CompositeScreen          Composite = 4
	CompositeOverlay         Composite = 5
	CompositeDifference      Composite = 6
	CompositeAddition        Composite = 7
	CompositeSubtract        Composite = 8
	CompositeDarkenOnly      Composite = 9
	CompositeLightenOnly     Composite = 10
	CompositeHue             Composite = 11
	CompositeSaturation      Composite = 12
	CompositeColor           Composite = 13
	CompositeValue           Composite = 14
	CompositeDivide          Composite = 15
	CompositeDodge           Composite = 16
	CompositeBurn            Composite = 17
	CompositeHardLight       Composite = 18
	CompositeSoftLight       Composite = 19
	CompositeGrainExtract    Composite = 20
	CompositeGrainMerge      Composite = 21
	CompositeLuminosity      Composite = 22
	CompositePlus            Composite = 23
	CompositeDestinationIn   Composite = 24
	CompositeDestinationOut  Composite = 25
	CompositeSourceAtop      Composite = 26
	CompositeDestinationAtop Composite = 27
)

Composite constants

func (Composite) Composite
func (c Composite) Composite(b, t color.Color) color.Color

Composite performs the composition of two layers

func (Composite) String
func (c Composite) String() string

String returns the name of the composition

type GrayAlpha
type GrayAlpha struct {
	Pix    []lcolor.GrayAlpha
	Stride int
	Rect   image.Rectangle
}

GrayAlpha is an image of GrayAlpha pixels

func NewGrayAlpha
func NewGrayAlpha(r image.Rectangle) *GrayAlpha

NewGrayAlpha create a new GrayAlpha image with the given bounds

func (*GrayAlpha) At
func (g *GrayAlpha) At(x, y int) color.Color

At returns the color for the pixel at the specified coords

func (*GrayAlpha) Bounds
func (g *GrayAlpha) Bounds() image.Rectangle

Bounds returns the limits of the image

func (*GrayAlpha) ColorModel
func (g *GrayAlpha) ColorModel() color.Model

ColorModel returns a color model to transform arbitrary colours into a GrayAlpha color

func (*GrayAlpha) GrayAlphaAt
func (g *GrayAlpha) GrayAlphaAt(x, y int) lcolor.GrayAlpha

GrayAlphaAt returns a GrayAlpha colr for the specified coords

func (*GrayAlpha) Opaque
func (g *GrayAlpha) Opaque() bool

Opaque returns true if all pixels have full alpha

func (*GrayAlpha) PixOffset
func (g *GrayAlpha) PixOffset(x, y int) int

PixOffset returns the index of the element of Pix corresponding to the given coords

func (*GrayAlpha) Set
func (g *GrayAlpha) Set(x, y int, c color.Color)

Set converts the given colour to a GrayAlpha colour and sets it at the given coords

func (*GrayAlpha) SetGrayAlpha
func (g *GrayAlpha) SetGrayAlpha(x, y int, ga lcolor.GrayAlpha)

SetGrayAlpha sets the colour at the given coords

func (*GrayAlpha) SubImage
func (g *GrayAlpha) SubImage(r image.Rectangle) image.Image

SubImage retuns the Image viewable through the given bounds

type Image
type Image []Layer

Image represents a collection of layers

func (Image) At
func (g Image) At(x, y int) color.Color

At returns the colour at the specified coords

func (Image) Bounds
func (g Image) Bounds() image.Rectangle

Bounds returns the limits for the dimensions of the group

func (Image) ColorModel
func (g Image) ColorModel() color.Model

ColorModel represents the color model of the group. It uses the first layer to determine the color model

func (Image) SubImage
func (g Image) 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

type Layer
type Layer struct {
	Name         string
	LayerBounds  image.Rectangle // Bounds within the layer group
	Mode         Composite
	Invisible    bool
	Transparency uint8
	image.Image
}

Layer represents a single layer of a multilayered image

func (Layer) At
func (l Layer) At(x, y int) color.Color

At returns the colour at the specified coords

func (Layer) Bounds
func (l Layer) Bounds() image.Rectangle

Bounds returns the limits for the dimensions of the layer

func (Layer) SubImage
func (l Layer) 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

type MaskedImage
type MaskedImage struct {
	image.Image
	Mask *image.Gray
}

MaskedImage represents an image that has a to-be-applied mask

func (MaskedImage) At
func (m MaskedImage) At(x, y int) color.Color

At returns the colour at the specified coords after masking

type PalettedAlpha
type PalettedAlpha struct {
	Pix     []lcolor.IndexedAlpha
	Stride  int
	Rect    image.Rectangle
	Palette lcolor.AlphaPalette
}

PalettedAlpha represents a paletted image with an alpha channel

func NewPalettedAlpha
func NewPalettedAlpha(r image.Rectangle, p lcolor.AlphaPalette) *PalettedAlpha

NewPalettedAlpha creates a new image that uses a palette with an alpha channel

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

At returns the color of the pixel at the given coords

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

Bounds returns the limits of the image

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

ColorModel a color model to tranform arbitrary colors to one in the palette

func (*PalettedAlpha) IndexAlphaAt
func (p *PalettedAlpha) IndexAlphaAt(x, y int) lcolor.IndexedAlpha

IndexAlphaAt returns the palette index and Alpha component of the given coords

func (*PalettedAlpha) Opaque
func (p *PalettedAlpha) Opaque() bool

Opaque returns true if the image is completely opaque

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

PixOffset returns the index of the Pix array corresponding to the given coords

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

Set converts the given colour to the closest in the palette and sets it at the given coords

func (*PalettedAlpha) SetIndexAlpha
func (p *PalettedAlpha) SetIndexAlpha(x, y int, ia lcolor.IndexedAlpha)

SetIndexAlpha directly set the index and alpha channels to the given coords

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

SubImage retuns the Image viewable through the given bounds

type RGB
type RGB struct {
	Pix    []lcolor.RGB
	Stride int
	Rect   image.Rectangle
}

RGB is an image of RGB colours

func NewRGB
func NewRGB(r image.Rectangle) *RGB

NewRGB create a new RGB image with the given bounds

func (*RGB) At
func (r *RGB) At(x, y int) color.Color

At returns the colour at the given coords

func (*RGB) Bounds
func (r *RGB) Bounds() image.Rectangle

Bounds returns the limits of the image

func (*RGB) ColorModel
func (r *RGB) ColorModel() color.Model

ColorModel returns a colour model that converts arbitrary colours to the RGB space

func (*RGB) Opaque
func (r *RGB) Opaque() bool

Opaque just returns true as the alpha channel is fixed.

func (*RGB) PixOffset
func (r *RGB) PixOffset(x, y int) int

PixOffset returns the index of the Pix array correspinding to the given coords

func (*RGB) RGBAt
func (r *RGB) RGBAt(x, y int) lcolor.RGB

RGBAt returns the exact RGB colour at the given coords

func (*RGB) Set
func (r *RGB) Set(x, y int, c color.Color)

Set converts the given colour to the RGB space and sets it at the given coords

func (*RGB) SetRGB
func (r *RGB) SetRGB(x, y int, rgb lcolor.RGB)

SetRGB directly set an RGB colour to the given coords

func (*RGB) SubImage
func (r *RGB) SubImage(rt image.Rectangle) image.Image

SubImage retuns the Image viewable through the given bounds

type Text
type Text struct {
	image.Image
	TextData
}

Text represents a text layer

type TextData
type TextData []TextDatum

TextData represents the stylised text

func (TextData) String
func (t TextData) String() string

String returns a flattened string

type TextDatum
type TextDatum struct {
	ForeColor, BackColor                   color.Color
	Size, LetterSpacing, Rise              uint32
	Bold, Italic, Underline, Strikethrough bool
	Font, Data                             string
}

TextDatum is a collection of styling for a single piece of text

Documentation

Overview

Package limage introduces structures to read and build layered images

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Composite

type Composite uint32

Composite determines how two layers are composed together

const (
	CompositeNormal Composite = iota
	CompositeDissolve
	CompositeBehind
	CompositeMultiply
	CompositeScreen
	CompositeOverlay
	CompositeDifference
	CompositeAddition
	CompositeSubtract
	CompositeDarkenOnly
	CompositeLightenOnly
	CompositeHue
	CompositeSaturation
	CompositeColor
	CompositeValue
	CompositeDivide
	CompositeDodge
	CompositeBurn
	CompositeHardLight
	CompositeSoftLight
	CompositeGrainExtract
	CompositeGrainMerge
	CompositeLuminosity
	CompositePlus
	CompositeDestinationIn
	CompositeDestinationOut
	CompositeSourceAtop
	CompositeDestinationAtop
	CompositeColorErase
	CompositeChroma
	CompositeLightness
	CompositeVividLight
	CompositePinLight
	CompositeLinearLight
	CompositeHardMix
	CompositeExclusion
	CompositeLinearBurn
	CompositeLuminance
	CompositeErase
	CompositeMerge
	CompositeSplit
	CompositePassThrough
)

Composite constants

func (Composite) Composite

func (c Composite) Composite(b, t color.Color) color.Color

Composite performs the composition of two layers

func (Composite) String

func (c Composite) String() string

String returns the name of the composition

type GrayAlpha

type GrayAlpha struct {
	Pix    []lcolor.GrayAlpha
	Stride int
	Rect   image.Rectangle
}

GrayAlpha is an image of GrayAlpha pixels

func NewGrayAlpha

func NewGrayAlpha(r image.Rectangle) *GrayAlpha

NewGrayAlpha create a new GrayAlpha image with the given bounds

func (*GrayAlpha) At

func (g *GrayAlpha) At(x, y int) color.Color

At returns the color for the pixel at the specified coords

func (*GrayAlpha) Bounds

func (g *GrayAlpha) Bounds() image.Rectangle

Bounds returns the limits of the image

func (*GrayAlpha) ColorModel

func (g *GrayAlpha) ColorModel() color.Model

ColorModel returns a color model to transform arbitrary colours into a GrayAlpha color

func (*GrayAlpha) GrayAlphaAt

func (g *GrayAlpha) GrayAlphaAt(x, y int) lcolor.GrayAlpha

GrayAlphaAt returns a GrayAlpha colr for the specified coords

func (*GrayAlpha) Opaque

func (g *GrayAlpha) Opaque() bool

Opaque returns true if all pixels have full alpha

func (*GrayAlpha) PixOffset

func (g *GrayAlpha) PixOffset(x, y int) int

PixOffset returns the index of the element of Pix corresponding to the given coords

func (*GrayAlpha) Set

func (g *GrayAlpha) Set(x, y int, c color.Color)

Set converts the given colour to a GrayAlpha colour and sets it at the given coords

func (*GrayAlpha) SetGrayAlpha

func (g *GrayAlpha) SetGrayAlpha(x, y int, ga lcolor.GrayAlpha)

SetGrayAlpha sets the colour at the given coords

func (*GrayAlpha) SubImage

func (g *GrayAlpha) SubImage(r image.Rectangle) image.Image

SubImage retuns the Image viewable through the given bounds

type Image

type Image []Layer

Image represents a collection of layers

func (Image) At

func (g Image) At(x, y int) color.Color

At returns the colour at the specified coords

func (Image) Bounds

func (g Image) Bounds() image.Rectangle

Bounds returns the limits for the dimensions of the group

func (Image) ColorModel

func (g Image) ColorModel() color.Model

ColorModel represents the color model of the group. It uses the first layer to determine the color model

func (Image) SubImage

func (g Image) 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

type Layer

type Layer struct {
	Name         string
	LayerBounds  image.Rectangle // Bounds within the layer group
	Mode         Composite
	Invisible    bool
	Transparency uint8
	image.Image
}

Layer represents a single layer of a multilayered image

func (Layer) At

func (l Layer) At(x, y int) color.Color

At returns the colour at the specified coords

func (Layer) Bounds

func (l Layer) Bounds() image.Rectangle

Bounds returns the limits for the dimensions of the layer

func (Layer) SubImage

func (l Layer) 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

func (Layer) SubImageLayer

func (l Layer) SubImageLayer(r image.Rectangle) Layer

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

type MaskedImage

type MaskedImage struct {
	image.Image
	Mask *image.Gray
}

MaskedImage represents an image that has a to-be-applied mask

func (MaskedImage) At

func (m MaskedImage) At(x, y int) color.Color

At returns the colour at the specified coords after masking

type PalettedAlpha

type PalettedAlpha struct {
	Pix     []lcolor.IndexedAlpha
	Stride  int
	Rect    image.Rectangle
	Palette lcolor.AlphaPalette
}

PalettedAlpha represents a paletted image with an alpha channel

func NewPalettedAlpha

func NewPalettedAlpha(r image.Rectangle, p lcolor.AlphaPalette) *PalettedAlpha

NewPalettedAlpha creates a new image that uses a palette with an alpha channel

func (*PalettedAlpha) At

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

At returns the color of the pixel at the given coords

func (*PalettedAlpha) Bounds

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

Bounds returns the limits of the image

func (*PalettedAlpha) ColorModel

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

ColorModel a color model to tranform arbitrary colors to one in the palette

func (*PalettedAlpha) IndexAlphaAt

func (p *PalettedAlpha) IndexAlphaAt(x, y int) lcolor.IndexedAlpha

IndexAlphaAt returns the palette index and Alpha component of the given coords

func (*PalettedAlpha) Opaque

func (p *PalettedAlpha) Opaque() bool

Opaque returns true if the image is completely opaque

func (*PalettedAlpha) PixOffset

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

PixOffset returns the index of the Pix array corresponding to the given coords

func (*PalettedAlpha) Set

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

Set converts the given colour to the closest in the palette and sets it at the given coords

func (*PalettedAlpha) SetIndexAlpha

func (p *PalettedAlpha) SetIndexAlpha(x, y int, ia lcolor.IndexedAlpha)

SetIndexAlpha directly set the index and alpha channels to the given coords

func (*PalettedAlpha) SubImage

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

SubImage retuns the Image viewable through the given bounds

type RGB

type RGB struct {
	Pix    []lcolor.RGB
	Stride int
	Rect   image.Rectangle
}

RGB is an image of RGB colours

func NewRGB

func NewRGB(r image.Rectangle) *RGB

NewRGB create a new RGB image with the given bounds

func (*RGB) At

func (r *RGB) At(x, y int) color.Color

At returns the colour at the given coords

func (*RGB) Bounds

func (r *RGB) Bounds() image.Rectangle

Bounds returns the limits of the image

func (*RGB) ColorModel

func (r *RGB) ColorModel() color.Model

ColorModel returns a colour model that converts arbitrary colours to the RGB space

func (*RGB) Opaque

func (r *RGB) Opaque() bool

Opaque just returns true as the alpha channel is fixed.

func (*RGB) PixOffset

func (r *RGB) PixOffset(x, y int) int

PixOffset returns the index of the Pix array correspinding to the given coords

func (*RGB) RGBAt

func (r *RGB) RGBAt(x, y int) lcolor.RGB

RGBAt returns the exact RGB colour at the given coords

func (*RGB) Set

func (r *RGB) Set(x, y int, c color.Color)

Set converts the given colour to the RGB space and sets it at the given coords

func (*RGB) SetRGB

func (r *RGB) SetRGB(x, y int, rgb lcolor.RGB)

SetRGB directly set an RGB colour to the given coords

func (*RGB) SubImage

func (r *RGB) SubImage(rt image.Rectangle) image.Image

SubImage retuns the Image viewable through the given bounds

type Text

type Text struct {
	image.Image
	TextData
}

Text represents a text layer

type TextData

type TextData []TextDatum

TextData represents the stylised text

func (TextData) String

func (t TextData) String() string

String returns a flattened string

type TextDatum

type TextDatum struct {
	ForeColor, BackColor                   color.Color
	Size, LetterSpacing, Rise              uint32
	Bold, Italic, Underline, Strikethrough bool
	Font, Data                             string
}

TextDatum is a collection of styling for a single piece of text

Directories

Path Synopsis
Package xcf implements an image encoder and decoder for GIMPs XCF format
Package xcf implements an image encoder and decoder for GIMPs XCF format

Jump to

Keyboard shortcuts

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