pimage

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GaussianBlur

func GaussianBlur(src image.Image, sigma float64) *image.RGBA

GaussianBlur returns a smoothly blurred version of the image using a Gaussian function. Sigma is the standard deviation of the Gaussian function, and a kernel of radius = 4 * Sigma is used.

func GaussianBlurKernel1D

func GaussianBlurKernel1D(sigma float64) *convolution.Kernel

GaussianBlurKernel1D returns a 1D Gaussian kernel. Sigma is the standard deviation, and the radius of the kernel is 4 * sigma.

Types

type Cmds

type Cmds int32 //enums:enum

Cmds are possible commands to perform for Params.

const (
	// Draw Source image using draw.Draw equivalent function,
	// without any transformation. If Mask is non-nil it is used.
	Draw Cmds = iota

	// Draw Source image with transform. If Mask is non-nil, it is used.
	Transform

	// blurs the Rect region with the given blur radius.
	// The blur radius passed to this function is the actual Gaussian
	// standard deviation (σ).
	Blur

	// Sets pixel from Source image at Pos
	SetPixel
)
const CmdsN Cmds = 4

CmdsN is the highest valid value for type Cmds, plus one.

func CmdsValues

func CmdsValues() []Cmds

CmdsValues returns all possible values for the type Cmds.

func (Cmds) Desc

func (i Cmds) Desc() string

Desc returns the description of the Cmds value.

func (Cmds) Int64

func (i Cmds) Int64() int64

Int64 returns the Cmds value as an int64.

func (Cmds) MarshalText

func (i Cmds) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Cmds) SetInt64

func (i *Cmds) SetInt64(in int64)

SetInt64 sets the Cmds value from an int64.

func (*Cmds) SetString

func (i *Cmds) SetString(s string) error

SetString sets the Cmds value from its string representation, and returns an error if the string is invalid.

func (Cmds) String

func (i Cmds) String() string

String returns the string representation of this Cmds value.

func (*Cmds) UnmarshalText

func (i *Cmds) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (Cmds) Values

func (i Cmds) Values() []enums.Enum

Values returns all possible values for the type Cmds.

type Params

type Params struct {
	// Command to perform.
	Cmd Cmds

	// Rect is the rectangle to draw into. This is the bounds for Transform source.
	// If empty, the entire destination image Bounds() are used.
	Rect image.Rectangle

	// SourcePos is the position for the source image in Draw,
	// and the location for SetPixel.
	SourcePos image.Point

	// Draw operation: Src or Over
	Op draw.Op

	// Source to draw.
	Source image.Image

	// Mask, used if non-nil.
	Mask image.Image

	// MaskPos is the position for the mask
	MaskPos image.Point

	// Transform for image transform.
	Transform math32.Matrix2

	// BlurRadius is the Gaussian standard deviation for Blur function
	BlurRadius float32
}

Params for image operations. This is a Render Item.

func NewBlur

func NewBlur(rect image.Rectangle, blurRadius float32) *Params

NewBlur returns a new Blur operation with given parameters. Does nothing if rect is empty.

func NewClear

func NewClear(src image.Image, sp image.Point, op draw.Op) *Params

NewClear returns a new Clear that renders entire image with given source image.

func NewDraw

func NewDraw(rect image.Rectangle, src image.Image, sp image.Point, op draw.Op) *Params

NewDraw returns a new Draw operation with given parameters. Does nothing if rect is empty.

func NewDrawMask

func NewDrawMask(rect image.Rectangle, src image.Image, sp image.Point, op draw.Op, mask image.Image, mp image.Point) *Params

NewDrawMask returns a new DrawMask operation with given parameters. Does nothing if rect is empty.

func NewSetPixel

func NewSetPixel(at image.Point, clr image.Image) *Params

NewSetPixel returns a new SetPixel operation with given parameters.

func NewTransform

func NewTransform(m math32.Matrix2, rect image.Rectangle, src image.Image, op draw.Op) *Params

NewTransform returns a new Transform operation with given parameters. Does nothing if rect is empty.

func NewTransformMask

func NewTransformMask(m math32.Matrix2, rect image.Rectangle, src image.Image, op draw.Op, mask image.Image, mp image.Point) *Params

NewTransformMask returns a new Transform Mask operation with given parameters. Does nothing if rect is empty.

func (*Params) IsRenderItem

func (pr *Params) IsRenderItem()

func (*Params) Render

func (pr *Params) Render(dest *image.RGBA)

Render performs the image operation on given destination image.

Jump to

Keyboard shortcuts

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