toy

package
v0.0.0-...-163d9d2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Render

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

func MakeToyRender

func MakeToyRender(width, height int) *Render

func (*Render) Bounds

func (tr *Render) Bounds() pixel.Rect

Bounds returns the rectangular bounds of the Canvas.

func (*Render) Color

func (tr *Render) Color(at pixel.Vec) pixel.RGBA

func (*Render) Draw

func (tr *Render) Draw(t pixel.Target, matrix pixel.Matrix)

Draw draws the content of the Canvas onto another Target, transformed by the given Matrix, just like if it was a Sprite containing the whole Canvas.

func (*Render) DrawColorMask

func (tr *Render) DrawColorMask(t pixel.Target, matrix pixel.Matrix, mask color.Color)

DrawColorMask draws the content of the Canvas onto another Target, transformed by the given Matrix and multiplied by the given mask, just like if it was a Sprite containing the whole Canvas.

If the color mask is nil, a fully opaque white mask will be used causing no effect.

func (*Render) Frame

func (tr *Render) Frame() *glhf.Frame

Frame returns the underlying OpenGL Frame of this Canvas.

func (*Render) Pixels

func (tr *Render) Pixels() []uint8

Pixels returns an alpha-premultiplied RGBA sequence of the content of the Canvas.

func (*Render) Render

func (tr *Render) Render()

func (*Render) ScreenShot

func (tr *Render) ScreenShot() image.Image

func (*Render) SetFragmentShaderPiece

func (tr *Render) SetFragmentShaderPiece(main string)

func (*Render) SetMovieMode

func (tr *Render) SetMovieMode(movieEnabled bool)

func (*Render) SetTextureData

func (tr *Render) SetTextureData(n int, img *image.NRGBA)

func (*Render) SetUniformValue

func (tr *Render) SetUniformValue(name string, value interface{}) error

func (*Render) StepMovieTime

func (tr *Render) StepMovieTime(seconds float32)

func (*Render) Texture

func (tr *Render) Texture() *glhf.Texture

Texture returns the underlying OpenGL Texture of this Canvas.

Implements GLPicture interface.

func (*Render) UpdateMouse

func (tr *Render) UpdateMouse(x, y float32, clicked bool)

type Texture

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

Texture is an OpenGL texture.

func NewTexture

func NewTexture(width, height int, smooth bool, pixels []uint8) *Texture

NewTexture creates a new texture with the specified width and height with some initial pixel values. The pixels must be a sequence of RGBA values (one byte per component).

func (*Texture) Begin

func (t *Texture) Begin()

Begin binds the Texture. This is necessary before using the Texture.

func (*Texture) End

func (t *Texture) End()

End unbinds the Texture and restores the previous one.

func (*Texture) Height

func (t *Texture) Height() int

Height returns the height of the Texture in pixels.

func (*Texture) ID

func (t *Texture) ID() uint32

ID returns the OpenGL ID of this Texture.

func (*Texture) Pixels

func (t *Texture) Pixels(x, y, w, h int) []uint8

Pixels returns the content of a sub-region of the Texture as an RGBA byte sequence.

func (*Texture) SetPixels

func (t *Texture) SetPixels(x, y, w, h int, pixels []uint8)

SetPixels sets the content of a sub-region of the Texture. Pixels must be an RGBA byte sequence.

func (*Texture) SetSmooth

func (t *Texture) SetSmooth(smooth bool)

SetSmooth sets whether the Texture should be drawn "smoothly" or "pixely".

It affects how the Texture is drawn when zoomed. Smooth interpolates between the neighbour pixels, while pixely always chooses the nearest pixel.

func (*Texture) Smooth

func (t *Texture) Smooth() bool

Smooth returns whether the Texture is set to be drawn "smooth" or "pixely".

func (*Texture) Width

func (t *Texture) Width() int

Width returns the width of the Texture in pixels.

Jump to

Keyboard shortcuts

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