imop

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

It is mainly used to debug the seam carving operation correctness with face detection and image mask enabled. When the GUI mode and the debugging option is activated it will show the image mask and the detected faces rectangles in a distinct color.

Package imop implements the Porter-Duff composition operations used for mixing a graphic element with its backdrop. Porter and Duff presented in their paper 12 different composition operation, but the core image/draw core package implements only the source-over-destination and source. This package implements all of the 12 composite operation together with some blending modes.

Index

Constants

View Source
const (
	Normal     = "normal"
	Darken     = "darken"
	Lighten    = "lighten"
	Multiply   = "multiply"
	Screen     = "screen"
	Overlay    = "overlay"
	SoftLight  = "soft_light"
	HardLight  = "hard_light"
	ColorDodge = "color_dodge"
	ColorBurn  = "color_burn"
	Difference = "difference"
	Exclusion  = "exclusion"

	// Non-separable blend modes
	Hue        = "hue"
	Saturation = "saturation"
	ColorMode  = "color"
	Luminosity = "luminosity"
)
View Source
const (
	Clear   = "clear"
	Copy    = "copy"
	Dst     = "dst"
	SrcOver = "src_over"
	DstOver = "dst_over"
	SrcIn   = "src_in"
	DstIn   = "dst_in"
	SrcOut  = "src_out"
	DstOut  = "dst_out"
	SrcAtop = "src_atop"
	DstAtop = "dst_atop"
	Xor     = "xor"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bitmap

type Bitmap struct {
	Img *image.NRGBA
}

Bitmap holds an image type as a placeholder for the Porter-Duff composition operations which can be used as a source or destination image.

func NewBitmap

func NewBitmap(rect image.Rectangle) *Bitmap

NewBitmap initializes a new Bitmap.

type Blend

type Blend struct {
	Current string
	Modes   []string
}

Blend struct contains the currently active blend mode and all the supported blend modes.

func NewBlend

func NewBlend() *Blend

NewBlend initializes a new Blend.

func (*Blend) AlphaCompose added in v1.4.6

func (bl *Blend) AlphaCompose(
	backdropAlpha,
	sourceAlpha,
	compositeAlpha,
	backdropColor,
	sourceColor,
	compositeColor float64,
) float64

Applies the alpha blending formula for a blend operation. See: https://www.w3.org/TR/compositing-1/#blending

func (*Blend) Get

func (bl *Blend) Get() string

Get returns the active blend mode.

func (*Blend) Lum added in v1.4.6

func (bl *Blend) Lum(rgb Color) float64

Lum gets the luminosity of a color.

func (*Blend) Sat added in v1.4.6

func (bl *Blend) Sat(rgb Color) float64

Sat gets the saturation of a color.

func (*Blend) Set

func (bl *Blend) Set(blendType string) error

Set activate one of the supported blend modes.

func (*Blend) SetLum added in v1.4.6

func (bl *Blend) SetLum(rgb Color, l float64) Color

SetLum set the luminosity on a color.

func (*Blend) SetSat added in v1.4.6

func (bl *Blend) SetSat(rgb Color, s float64) Color

type Color added in v1.4.6

type Color struct {
	R, G, B float64
}

Color represents the RGB channel of a specific color.

type Composite

type Composite struct {
	CurrentOp string
	Ops       []string
}

Composite struct contains the currently active composition operation and all the supported operations.

func InitOp

func InitOp() *Composite

InitOp initializes a new composition operation.

func (*Composite) Draw

func (op *Composite) Draw(bitmap *Bitmap, src, dst *image.NRGBA, bl *Blend)

Draw applies the currently active Ported-Duff composition operation formula, taking as parameter the source and the destination image and draws the result into the bitmap. If a blend mode is activated it will plug in the alpha blending formula also into the equation.

func (*Composite) Get added in v1.4.6

func (op *Composite) Get() string

Set changes the current composition operation.

func (*Composite) Set

func (op *Composite) Set(cop string) error

Set changes the current composition operation.

Jump to

Keyboard shortcuts

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