colorm

package
v2.8.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 6 Imported by: 39

Documentation

Index

Constants

Dim is a dimension of a ColorM.

Variables

This section is empty.

Functions

func DrawImage

func DrawImage(dst, src *ebiten.Image, colorM ColorM, op *DrawImageOptions)

DrawImage draws src onto dst.

DrawImage is basically the same as ebiten.DrawImage, but with a color matrix.

func DrawTriangles

func DrawTriangles(dst *ebiten.Image, vertices []ebiten.Vertex, indices []uint16, img *ebiten.Image, colorM ColorM, op *DrawTrianglesOptions)

DrawTriangles draws triangles onto dst.

DrawTriangles is basically the same as ebiten.DrawTriangles, but with a color matrix.

Types

type ColorM

type ColorM struct {
	// contains filtered or unexported fields
}

ColorM represents a matrix to transform coloring when rendering an image.

ColorM is applied to the straight alpha color while an Image's pixels' format is alpha premultiplied. Before applying a matrix, a color is un-multiplied, and after applying the matrix, the color is multiplied again.

The initial value is identity.

func (*ColorM) Apply

func (c *ColorM) Apply(clr color.Color) color.Color

Apply pre-multiplies a vector (r, g, b, a, 1) by the matrix where r, g, b, and a are clr's values in straight-alpha format. In other words, Apply calculates ColorM * (r, g, b, a, 1)^T.

func (*ColorM) ChangeHSV

func (c *ColorM) ChangeHSV(hueTheta float64, saturationScale float64, valueScale float64)

ChangeHSV changes HSV (Hue-Saturation-Value) values. hueTheta is a radian value to rotate hue. saturationScale is a value to scale saturation. valueScale is a value to scale value (a.k.a. brightness).

This conversion uses RGB to/from YCrCb conversion.

func (*ColorM) Concat

func (c *ColorM) Concat(other ColorM)

Concat multiplies a color matrix with the other color matrix. This is same as multiplying the matrix other and the matrix c in this order.

func (*ColorM) Element

func (c *ColorM) Element(i, j int) float64

Element returns a value of a matrix at (i, j).

func (*ColorM) Invert

func (c *ColorM) Invert()

Invert inverts the matrix. If c is not invertible, Invert panics.

func (*ColorM) IsInvertible

func (c *ColorM) IsInvertible() bool

IsInvertible returns a boolean value indicating whether the matrix c is invertible or not.

func (*ColorM) ReadElements

func (c *ColorM) ReadElements(body []float32, translation []float32)

ReadElements reads the body part and the translation part to the given float32 slices.

len(body) must be 16 and len(translation) must be 4. Otherwise, ReadElements panics.

func (*ColorM) Reset

func (c *ColorM) Reset()

Reset resets the ColorM as identity.

func (*ColorM) RotateHue

func (c *ColorM) RotateHue(theta float64)

RotateHue rotates the hue. theta represents rotating angle in radian.

func (*ColorM) Scale

func (c *ColorM) Scale(r, g, b, a float64)

Scale scales the matrix by (r, g, b, a).

func (*ColorM) ScaleWithColor

func (c *ColorM) ScaleWithColor(clr color.Color)

ScaleWithColor scales the matrix by clr.

func (*ColorM) SetElement

func (c *ColorM) SetElement(i, j int, element float64)

SetElement sets an element at (i, j).

func (*ColorM) String

func (c *ColorM) String() string

String returns a string representation of ColorM.

func (*ColorM) Translate

func (c *ColorM) Translate(r, g, b, a float64)

Translate translates the matrix by (r, g, b, a).

type DrawImageOptions

type DrawImageOptions struct {
	// GeoM is a geometry matrix to draw.
	// The default (zero) value is identity, which draws the image at (0, 0).
	GeoM ebiten.GeoM

	// Blend is a blending way of the source color and the destination color.
	// The default (zero) value is the regular alpha blending.
	Blend ebiten.Blend

	// Filter is a type of texture filter.
	// The default (zero) value is ebiten.FilterNearest.
	Filter ebiten.Filter
}

DrawImageOptions represents options for DrawImage.

type DrawTrianglesOptions

type DrawTrianglesOptions struct {
	// ColorScaleMode is the mode of color scales in vertices.
	// The default (zero) value is ebiten.ColorScaleModeStraightAlpha.
	ColorScaleMode ebiten.ColorScaleMode

	// Blend is a blending way of the source color and the destination color.
	// The default (zero) value is the regular alpha blending.
	Blend ebiten.Blend

	// Filter is a type of texture filter.
	// The default (zero) value is ebiten.FilterNearest.
	Filter ebiten.Filter

	// Address is a sampler address mode.
	// The default (zero) value is ebiten.AddressUnsafe.
	Address ebiten.Address

	// FillRule indicates the rule how an overlapped region is rendered.
	//
	// The rules NonZero and EvenOdd are useful when you want to render a complex polygon.
	// A complex polygon is a non-convex polygon like a concave polygon, a polygon with holes, or a self-intersecting polygon.
	// See examples/vector for actual usages.
	//
	// The default (zero) value is ebiten.FillAll.
	FillRule ebiten.FillRule

	// AntiAlias indicates whether the rendering uses anti-alias or not.
	// AntiAlias is useful especially when you pass vertices from the vector package.
	//
	// AntiAlias increases internal draw calls and might affect performance.
	// Use the build tag `ebitenginedebug` to check the number of draw calls if you care.
	//
	// The default (zero) value is false.
	AntiAlias bool
}

DrawTrianglesOptions represents options for DrawTriangles.

Jump to

Keyboard shortcuts

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