vxform

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: BSD-3-Clause Imports: 8 Imported by: 8

Documentation

Overview

Package vxform supports visual (image) transformations: translation, scaling, rotation.

Includes parameters for specifying random range to generate.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RotImage

func RotImage(img image.Image, rot float32) *image.RGBA

RotImage rotates image by given number of degrees

func ScaleImage

func ScaleImage(img image.Image, sc float32) *image.RGBA

ScaleImage scales image by given number of degrees retaining the current image size, and filling border with current border if scaling to a smaller size.

func TransImage

func TransImage(img image.Image, trX, trY float32) *image.RGBA

TransImage translates image in each axis by given proportion of image half-size i.e., 1 = move from center to edge

func XFormImage

func XFormImage(img image.Image, trX, trY, sc, rot float32) *image.RGBA

XFormImage transforms given image according to given parameters Transformations are performed as: rotation, scale, then translation. Scaling retain the current image size, filling border with current border if scaling to a smaller size.

Types

type Rand

type Rand struct {
	TransX minmax.F32 `desc:"min -- max range of X-axis (horizontal) translations to generate (as proportion of image size)"`
	TransY minmax.F32 `desc:"min -- max range of Y-axis (vertical) translations to generate (as proportion of image size)"`
	Scale  minmax.F32 `desc:"min -- max range of scales to generate"`
	Rot    minmax.F32 `desc:"min -- max range of rotations to generate (in degrees)"`
}

Rand specifies random transforms

func (*Rand) Gen

func (rx *Rand) Gen(xf *XForm)

Gen Generates new random transform values

type XForm

type XForm struct {
	TransX env.CurPrvF32 `` /* 128-byte string literal not displayed */
	TransY env.CurPrvF32 `` /* 128-byte string literal not displayed */
	Scale  env.CurPrvF32 `desc:"current, prv scale value"`
	Rot    env.CurPrvF32 `desc:"current, prv rotation value, in degrees"`
}

XForm represents current and previous visual transformation values and can apply current values to transform an image. Transformations are performed as: rotation, scale, then translation. Scaling crops to retain the current image size.

func (*XForm) Image

func (xf *XForm) Image(img image.Image) *image.RGBA

Image transforms given image according to current parameters

func (*XForm) Set

func (xf *XForm) Set(trX, trY, sc, rot float32)

Set updates current values

func (*XForm) String

func (xf *XForm) String() string

Jump to

Keyboard shortcuts

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