graphics

package module
v0.0.0-...-9050bac Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 14 Imported by: 11

README

ebitengine-graphics

Build Status PkgGoDev

Overview

A package implementing various graphics primitives like Sprite for Ebitengine.

It works the best in combination with gscene package, but can be used without it.

Graphical objects list:

  • Sprite
  • Line, DottedLine, Texture Line
  • Circle (supports dashed style)
  • Rect
  • Label
  • Container
  • Canvas
  • Easier shader-based drawing (ShaderObject)

Missing some graphical object? Tell us about it.

It also supports a basic camera and layers implementation.

Installation

go get github.com/quasilyte/ebitengine-graphics

Quick Start

The most useful type of this package is Sprite, but it's tricky to demonstrate its usage without assets. This is a quick start section, it's intended to be as slim as possible.

You can use this library without gscene:

package main

import (
	"github.com/hajimehoshi/ebiten/v2"
	graphics "github.com/quasilyte/ebitengine-graphics"
	"github.com/quasilyte/gmath"
)

func main() {
	ebiten.SetWindowSize(640, 480)
	if err := ebiten.RunGame(newExampleGame()); err != nil {
		panic(err)
	}
}

type exampleGame struct {
	pos           gmath.Vec
	initialized   bool
	objects       []drawable
}

type drawable interface {
	Draw(screen *ebiten.Image)
}

func newExampleGame() *exampleGame {
	return &exampleGame{
		pos:           gmath.Vec{X: 32, Y: 32},
	}
}

func (g *exampleGame) Layout(outsideWidth, outsideHeight int) (int, int) {
	return 640, 480
}

func (g *exampleGame) Draw(screen *ebiten.Image) {
	for _, o := range g.objects {
		o.Draw(screen)
	}
}

func (g *exampleGame) Update() error {
	if !g.initialized {
		g.Init()
		g.initialized = true
	}

	g.pos = g.pos.Add(gmath.Vec{X: 1, Y: 2})
	return nil
}

func (g *exampleGame) Init() {
	{
		from := gmath.Pos{Base: &g.pos}
		to := gmath.Pos{Offset: gmath.Vec{X: 128, Y: 64}}
		l := graphics.NewLine(from, to)
		l.SetWidth(2)
		l.SetColorScale(graphics.ColorScaleFromRGBA(200, 100, 100, 255))
		g.objects = append(g.objects, l)
	}

	{
		r := graphics.NewRect(32, 32)
		r.Pos.Base = &g.pos
		r.SetFillColorScale(graphics.RGB(0xAABB00))
		r.SetOutlineColorScale(graphics.RGB(0x0055ff))
		r.SetOutlineWidth(2)
		g.objects = append(g.objects, r)
	}
}

With gscene it's even easier (showing only relevant part):

func (c *exampleController) Init(scene *gscene.SimpleRootScene) {
	{
		from := gmath.Pos{Base: &g.pos}
		to := gmath.Pos{Offset: gmath.Vec{X: 128, Y: 64}}
		l := graphics.NewLine(from, to)
		l.SetWidth(2)
		l.SetColorScale(graphics.ColorScaleFromRGBA(200, 100, 100, 255))
		scene.AddGraphics(l)
	}

	{
		r := graphics.NewRect(32, 32)
		r.Pos.Base = &g.pos
		r.SetFillColorScale(graphics.RGB(0xAABB00))
		r.SetOutlineColorScale(graphics.RGB(0x0055ff))
		r.SetOutlineWidth(2)
		scene.AddGraphics(r)
	}
}

Note that we can add the graphical object directly to the scene. The scene will manage their Draw calls as well as their lifetimes (based on graphical objects being disposed or not).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileShaders

func CompileShaders()

CompileShaders prepares shaders bundled with this package. It should be called once if any of the shader-dependend objects are being used.

Objects that require shaders so far: * Circle * DottedLine

func FormatRGB

func FormatRGB(clr color.NRGBA) string

func FormatRGBA

func FormatRGBA(clr color.NRGBA) string

Types

type AlignHorizontal

type AlignHorizontal uint8
const (
	AlignHorizontalLeft AlignHorizontal = iota
	AlignHorizontalCenter
	AlignHorizontalRight
)

type AlignVertical

type AlignVertical uint8
const (
	AlignVerticalTop AlignVertical = iota
	AlignVerticalCenter
	AlignVerticalBottom
)

type Camera

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

Camera implements a 2D camera for the SceneDrawer.

It's pretty barebones, you might want to wrap it into your game's camera type and add functionality like lerping between A and B. Add Camera itself into the SceneDrawer and put it inside your own camera implementation. Then call appropriate things like [SetOffset] and [Pan] on the wrapped camera to implement something fancier.

Some terminology: * screen coordinates - min=(0,0) max=(windowWidth,windowHeight) * world coordinates - arbitrary values that spefify the object's location inside the game world

Let's assume there is a world coordinate {32, 32}; if the camera's offset is {0, 0}, then screen coordinate is {32, 32}, if the camera's offset is {32, 32}, then screen coordinate is {0, 0}.

Converting coordinates: * screen to world: screenPos.Add(camera.GetOffset()) * world to screen: worldPos.Sub(camera.GetOffset())

Pay attention to the docs, they should tell you which kind of a position is expected for an argument and/or method's return value.

func NewCamera

func NewCamera() *Camera

NewCamera creates a new camera for the SceneDrawer.

It covers the entire screen by default. Use [SetViewportRect] to change that.

The camera has no bounds by default, use [SetBounds] to set panning limits.

It's advised to only call this function after Ebitengine game has already started.

func (*Camera) GetBounds

func (c *Camera) GetBounds() gmath.Rect

func (*Camera) GetCenterOffset

func (c *Camera) GetCenterOffset() gmath.Vec

GetCenterOffset returns the camera current offset translated to the scaled viewport rect's center. To get the untranslated position, use [GetOffset].

The returned pos is in world coordinates.

func (*Camera) GetLayerMask

func (c *Camera) GetLayerMask() uint64

GetLayerMask returns the current camera's layer bitmask. See [SetLayerMask] doc comment to learn more about the bitmask.

func (*Camera) GetOffset

func (c *Camera) GetOffset() gmath.Vec

GetOffset returns the camera current offset. The pos is given for the top-left corner of the camera's scaled viewport rect. To get the center position, use [GetCenterOffset].

The returned pos is in world coordinates.

func (*Camera) GetScale

func (c *Camera) GetScale() float64

func (*Camera) GetScaledViewportRect

func (c *Camera) GetScaledViewportRect() gmath.Rect

GetScaledViewportRect returns the camera's rendering rectangle with scaling applied to it.

This rectangle is in screen coordinates, meaning it is unaffected by the camera pos.

func (*Camera) GetViewportRect

func (c *Camera) GetViewportRect() gmath.Rect

GetViewportRect returns the camera's rendering rectangle.

This rectangle is in screen coordinates, meaning it is unaffected by the camera pos.

func (*Camera) Pan

func (c *Camera) Pan(delta gmath.Vec) bool

Pan adds the specified camera position delta to the camera's current offset. It's a shorthand to c.SetOffset(c.GetOffset().Add(delta)). The same clamping rules apply as in [SetOffset].

The return value reports whether the position was actually updated.

func (*Camera) SetBounds

func (c *Camera) SetBounds(bounds gmath.Rect)

SetBounds sets the camera panning limits.

The provided rectangle should not be smaller than camera's world size (in the simplest case, bounds=worldSize). An exception from this rule is zero rect: a zero-value rectangle means "unbound" camera that can go anywhere.

func (*Camera) SetCenterOffset

func (c *Camera) SetCenterOffset(pos gmath.Vec) bool

SetCenterOffset centers the camera around given position. After the clamping rules apply, the pos may end up not being in the perfect center of the camera's scaled viewport rect.

The return value reports whether the position was actually updated.

The pos parameter should be in world coordinates.

func (*Camera) SetLayerMask

func (c *Camera) SetLayerMask(mask uint64)

SetLayerMask updates the camera's layer bitmask.

The nth bit of the mask controls whether nth layer should be rendered onto the camera. By default, the camera layermask is "all ones", meaning all layers are rendered.

This mask is useful when you want to draw some layers only to particular cameras. For the simplest kinds of games this feature is not needed and you may leave it as is.

This bitmask can affect up to first 64 layers, any other layer is always enabled.

func (*Camera) SetOffset

func (c *Camera) SetOffset(pos gmath.Vec) bool

SetOffset assigns a new offset to the camera. It will be clamped to fit the camera bounds.

The return value reports whether the position was actually updated.

The pos parameter should be in world coordinates.

func (*Camera) SetScale

func (c *Camera) SetScale(scale float64)

func (*Camera) SetViewportRect

func (c *Camera) SetViewportRect(rect gmath.Rect)

SetViewportRect changes the camera's viewport area to render to.

The rect is in screen coordinates.

func (*Camera) ToScreenPos

func (c *Camera) ToScreenPos(worldPos gmath.Vec) gmath.Vec

func (*Camera) ToWorldPos

func (c *Camera) ToWorldPos(screenPos gmath.Vec) gmath.Vec

type Canvas

type Canvas struct {
	Pos gmath.Pos

	Rotation *gmath.Rad
	// contains filtered or unexported fields
}

func NewCanvas

func NewCanvas() *Canvas

func (*Canvas) AddChild

func (c *Canvas) AddChild(o DisposableObject)

func (*Canvas) Dispose

func (c *Canvas) Dispose()

func (*Canvas) Draw

func (c *Canvas) Draw(dst *ebiten.Image)

func (*Canvas) DrawWithOptions

func (c *Canvas) DrawWithOptions(dst *ebiten.Image, opts DrawOptions)

func (*Canvas) IsDisposed

func (c *Canvas) IsDisposed() bool

func (*Canvas) IsOffscreen

func (c *Canvas) IsOffscreen() bool

func (*Canvas) IsVisible

func (c *Canvas) IsVisible() bool

func (*Canvas) SetDstImage

func (c *Canvas) SetDstImage(img *ebiten.Image)

func (*Canvas) SetOffscreen

func (c *Canvas) SetOffscreen(offscreen bool)

func (*Canvas) SetVisibility

func (c *Canvas) SetVisibility(visible bool)

type Circle

type Circle struct {
	Pos gmath.Pos

	Rotation *gmath.Rad
	// contains filtered or unexported fields
}

TODO: separate into Circle and DashedCircle.

func NewCircle

func NewCircle(r float64) *Circle

NewCircle returns a circle of the specified radius. Use SetRadius if you need to resize it afterwards.

By default, a circle has these properties: * Centered=true * Visible=true * The FillColorScale is {0, 0, 0, 0} (invisible) * FillOffset is 0 (no gaps) * The OutlineColorScale is {1, 1, 1, 1} * OutlineWidth is 1

The outline can have a dashed style.

You need to call CompileShaders before using circles.

func (*Circle) BoundsRect

func (c *Circle) BoundsRect() gmath.Rect

BoundsRect returns the properly positioned circle containing rectangle.

This is useful when trying to calculate whether this object is contained inside some area or not (like a camera view area).

func (*Circle) Dispose

func (c *Circle) Dispose()

Dispose marks this circle for deletion. After calling this method, IsDisposed will report true.

func (*Circle) Draw

func (c *Circle) Draw(dst *ebiten.Image)

Draw renders the circle onto the provided dst image.

This method is a shorthand to DrawWithOptions(dst, {}) which also implements the gscene.Graphics interface.

See DrawWithOptions for more info.

func (*Circle) DrawWithOptions

func (c *Circle) DrawWithOptions(dst *ebiten.Image, opts DrawOptions)

func (*Circle) GetFillColorScale

func (c *Circle) GetFillColorScale() ColorScale

GetFillColorScale is used to retrieve the current fill color scale value of the circle. Use SetFillColorScale to change it.

func (*Circle) GetFillOffset

func (c *Circle) GetFillOffset() float64

func (*Circle) GetOutlineColorScale

func (c *Circle) GetOutlineColorScale() ColorScale

GetOutlineColorScale is used to retrieve the current outline color scale value of the circle. Use SetOutlineColorScale to change it.

func (*Circle) GetOutlineDash

func (c *Circle) GetOutlineDash() (length, gap float64)

func (*Circle) GetOutlineWidth

func (c *Circle) GetOutlineWidth() float64

func (*Circle) GetRadius

func (c *Circle) GetRadius() float64

func (*Circle) IsCentered

func (c *Circle) IsCentered() bool

IsCentered reports whether Centered flag is set. Use SetCentered to change this flag value.

func (*Circle) IsDisposed

func (c *Circle) IsDisposed() bool

IsDisposed reports whether this circle is marked for deletion. IsDisposed returns true only after Disposed was called on this circle.

func (*Circle) IsVisible

func (c *Circle) IsVisible() bool

IsVisible reports whether this circle is visible. Use SetVisibility to change this flag value.

When circle is invisible (visible=false), it will not be rendered at all. This is an efficient way to temporarily hide a circle.

func (*Circle) SetCentered

func (c *Circle) SetCentered(centered bool)

SetCentered changes the Centered flag value. Use IsCentered to get the current flag value.

func (*Circle) SetFillColorScale

func (c *Circle) SetFillColorScale(cs ColorScale)

SetFillColorScale assigns a new fill ColorScale to this circle. Use GetFillColorScale to retrieve the current color scale.

func (*Circle) SetFillOffset

func (c *Circle) SetFillOffset(offset float64)

func (*Circle) SetOutlineColorScale

func (c *Circle) SetOutlineColorScale(cs ColorScale)

SetOutlineColorScale assigns a new outline ColorScale to this circle. Use GetOutlineColorScale to retrieve the current color scale.

func (*Circle) SetOutlineDash

func (c *Circle) SetOutlineDash(length, gap float64)

func (*Circle) SetOutlineWidth

func (c *Circle) SetOutlineWidth(w float64)

func (*Circle) SetRadius

func (c *Circle) SetRadius(r float64)

func (*Circle) SetVisibility

func (c *Circle) SetVisibility(visible bool)

SetVisibility changes the Visible flag value. It can be used to show or hide the circle. Use IsVisible to get the current flag value.

type ColorScale

type ColorScale struct {
	R float32
	G float32
	B float32
	A float32
}

ColorScale is like ebiten.ColorScale, but its values don't need to be premultiplied. In a sense, it's like color.NRGBA in comparison with color.RGBA.

For a normal color, we use {1, 1, 1, 1}, for a transparent color it's {0, 0, 0, 0}. To double the amount of red, you can use {2, 1, 1, 1} or {1, 0.5, 0.5, 1}.

Use ColorScaleFromRGBA and ColorScaleFromColor if you want to construct the color scale object easily.

func ColorScaleFromColor

func ColorScaleFromColor(c color.NRGBA) ColorScale

ColorScaleFromRGBA constructs a ColorScale using ColorScale.SetColor method.

func ColorScaleFromRGBA

func ColorScaleFromRGBA(r, g, b, a uint8) ColorScale

ColorScaleFromRGBA constructs a ColorScale using ColorScale.SetRGBA method.

func RGB

func RGB(rgb uint64) ColorScale

RGB returns a ColorScale created from the bits of rgb value. RGB(0xAABBCC) is identical to R=0xAA, G=0xBB, B=0xCC, A=0xFF.

Note: alpha value is fixed to 0xFF, if you need some other value, use RGBA() function instead.

Hint: use RGB(v).Color() to get a color.NRGBA object.

func RGBA

func RGBA(rgb uint64) ColorScale

RGBA returns a ColorScale created from the bits of rgba value. RGBA(0xAABBCCEE) is identical to R=0xAA, G=0xBB, B=0xCC, A=0xEE.

Hint: use RGBA(v).Color() to get a color.NRGBA object.

func (*ColorScale) AsVec3

func (c *ColorScale) AsVec3() []float32

AsVec3 returns a color scale as RGB slice (vec3 for shaders).

func (*ColorScale) AsVec4

func (c *ColorScale) AsVec4() []float32

AsVec4returns a color scale as RGBA slice (vec4 for shaders).

func (ColorScale) Color

func (c ColorScale) Color() color.NRGBA

Color returns the color.NRGBA representation of a color scale.

It will only work correctly for color scales those values are in [0, 1] range. If some color value overflows (or underflows) this range, the result of this operation is truncated garbage.

This function is mostly useful in combination with RGB() function to construct a color.NRGBA easily: RGB(0xAABBCCEE).Color().

func (ColorScale) Lerp

func (c ColorScale) Lerp(target ColorScale, t float32) ColorScale

func (ColorScale) Mul

func (c ColorScale) Mul(other ColorScale) ColorScale

func (ColorScale) RotateHue

func (c ColorScale) RotateHue(deg float32) ColorScale

RotateHue returns a color scale with its hue rotated. The argument specifies the number of degrees to rotate.

func (ColorScale) ScaleAlpha

func (c ColorScale) ScaleAlpha(x float32) ColorScale

ScaleAlpha returns the color scale with alpha multiplied by x. It doesn't affect R/G/B channels.

func (ColorScale) ScaleRGB

func (c ColorScale) ScaleRGB(x float32) ColorScale

ScaleRGB multiplies R, G and B color scale components by x. It doesn't affect the alpha channel.

func (*ColorScale) SetColor

func (c *ColorScale) SetColor(rgba color.NRGBA)

SetColor assigns the color.NRGBA equivalent to a color scale.

func (*ColorScale) SetRGBA

func (c *ColorScale) SetRGBA(r, g, b, a uint8)

SetRGBA is like SetColor, but accepts every color part separately.

func (ColorScale) String

func (c ColorScale) String() string

func (*ColorScale) ToEbitenColorScale

func (c *ColorScale) ToEbitenColorScale() ebiten.ColorScale

func (ColorScale) ToHSL

func (c ColorScale) ToHSL() (h, s, l float32)

type Container

type Container struct {
	Pos gmath.Pos

	Rotation *gmath.Rad
	// contains filtered or unexported fields
}

func NewContainer

func NewContainer() *Container

func (*Container) AddChild

func (c *Container) AddChild(o DisposableObject)

func (*Container) Dispose

func (c *Container) Dispose()

func (*Container) Draw

func (c *Container) Draw(dst *ebiten.Image)

func (*Container) DrawWithOptions

func (c *Container) DrawWithOptions(dst *ebiten.Image, opts DrawOptions)

func (*Container) IsDisposed

func (c *Container) IsDisposed() bool

func (*Container) IsVisible

func (c *Container) IsVisible() bool

IsVisible reports whether this container is visible. Use SetVisibility to change this flag value.

If container is invisible, none of its objects will be rendered during the Draw call.

func (*Container) SetVisibility

func (c *Container) SetVisibility(visible bool)

SetVisibility changes the Visible flag value. It can be used to show or hide the container. Use IsVisible to get the current flag value.

type DisposableObject

type DisposableObject interface {
	Object

	Dispose()
}

type DottedLine

type DottedLine struct {
	BeginPos gmath.Pos
	EndPos   gmath.Pos
	// contains filtered or unexported fields
}

DottedLine is a 2-point line graphical primitive drawn using small segments.

func NewDottedLine

func NewDottedLine(begin, end gmath.Pos) *DottedLine

NewDottedLine returns a line that is drawn from begin pos to end pos. BeginPos and EndPos fields can be changed directly.

By default, a line has these properties: * Visible=true * The ColorScale is {1, 1, 1, 1} * DotRadius=1 * DotSpacing=3

func (*DottedLine) BoundsRect

func (l *DottedLine) BoundsRect() gmath.Rect

BoundsRect returns a rectangle that fully contains the line.

This is useful when trying to calculate whether this object is contained inside some area or not (like a camera view area).

func (*DottedLine) Dispose

func (l *DottedLine) Dispose()

Dispose marks this line for deletion. After calling this method, IsDisposed will report true.

func (*DottedLine) Draw

func (l *DottedLine) Draw(dst *ebiten.Image)

func (*DottedLine) DrawWithOptions

func (l *DottedLine) DrawWithOptions(dst *ebiten.Image, opts DrawOptions)

func (*DottedLine) GetAlpha

func (l *DottedLine) GetAlpha() float32

GetAlpha is a shorthand for GetColorScale().A expression. It's mostly provided for a symmetry with SetAlpha.

func (*DottedLine) GetColorScale

func (l *DottedLine) GetColorScale() ColorScale

GetColorScale is used to retrieve the current color scale value of the line. Use SetColorScale to change it.

func (*DottedLine) GetDotRadius

func (l *DottedLine) GetDotRadius() float64

func (*DottedLine) GetDotSpacing

func (l *DottedLine) GetDotSpacing() float64

func (*DottedLine) IsDisposed

func (l *DottedLine) IsDisposed() bool

IsDisposed reports whether this line is marked for deletion. IsDisposed returns true only after Disposed was called on this line.

func (*DottedLine) IsVisible

func (l *DottedLine) IsVisible() bool

IsVisible reports whether this line is visible. Use SetVisibility to change this flag value.

When line is invisible (visible=false), it will not be rendered at all. This is an efficient way to temporarily hide a line.

func (*DottedLine) SetAlpha

func (l *DottedLine) SetAlpha(a float32)

SetAlpha is a convenient way to change the alpha value of the ColorScale.

func (*DottedLine) SetColorScale

func (l *DottedLine) SetColorScale(cs ColorScale)

SetColorScale assigns a new ColorScale to this line. Use GetColorScale to retrieve the current color scale.

func (*DottedLine) SetDotRadius

func (l *DottedLine) SetDotRadius(r float64)

func (*DottedLine) SetDotSpacing

func (l *DottedLine) SetDotSpacing(spacing float64)

func (*DottedLine) SetVisibility

func (l *DottedLine) SetVisibility(visible bool)

SetVisibility changes the Visible flag value. It can be used to show or hide the line. Use IsVisible to get the current flag value.

type DrawOptions

type DrawOptions struct {
	Offset gmath.Vec

	Rotation gmath.Rad

	// Blend is an optional blend mode override.
	// You usually want to use a predefined blend from Ebitengine and
	// assign it like DrawOptopns{Blend: &ebiten.BlendCopy}.
	// We're using a pointer here mostly to decrease the [DrawOptions]
	// object size as most of the time this field is going to be nil.
	Blend *ebiten.Blend
}

type GrowHorizontal

type GrowHorizontal uint8
const (
	GrowHorizontalRight GrowHorizontal = iota
	GrowHorizontalLeft
	GrowHorizontalBoth
	GrowHorizontalNone
)

type GrowVertical

type GrowVertical uint8
const (
	GrowVerticalDown GrowVertical = iota
	GrowVerticalUp
	GrowVerticalBoth
	GrowVerticalNone
)

type Label

type Label struct {
	Pos gmath.Pos
	// contains filtered or unexported fields
}

Label is a simple text rendering object.

It supports different kinds of grow/aling settings. The text color can be changed, but only for the whole text.

Label implements gscene Graphics interface.

func NewLabel

func NewLabel(ff text.Face) *Label

func (*Label) BoundsRect

func (l *Label) BoundsRect() gmath.Rect

func (*Label) Dispose

func (l *Label) Dispose()

func (*Label) Draw

func (l *Label) Draw(dst *ebiten.Image)

func (*Label) DrawWithOptions

func (l *Label) DrawWithOptions(dst *ebiten.Image, opts DrawOptions)

func (*Label) GetAlignHorizontal

func (l *Label) GetAlignHorizontal() AlignHorizontal

func (*Label) GetAlignVertical

func (l *Label) GetAlignVertical() AlignVertical

func (*Label) GetAlpha

func (l *Label) GetAlpha() float32

GetAlpha is a shorthand for GetColorScale().A expression. It's mostly provided for a symmetry with SetAlpha.

func (*Label) GetColorScale

func (l *Label) GetColorScale() ColorScale

GetColorScale is used to retrieve the current color scale value of the label's text. Use SetColorScale to change it.

func (*Label) GetGrowHorizontal

func (l *Label) GetGrowHorizontal() GrowHorizontal

func (*Label) GetGrowVertical

func (l *Label) GetGrowVertical() GrowVertical

func (*Label) GetSize

func (l *Label) GetSize() (w, h int)

func (*Label) IsDisposed

func (l *Label) IsDisposed() bool

func (*Label) IsVisible

func (l *Label) IsVisible() bool

func (*Label) SetAlignHorizontal

func (l *Label) SetAlignHorizontal(a AlignHorizontal)

func (*Label) SetAlignVertical

func (l *Label) SetAlignVertical(a AlignVertical)

func (*Label) SetAlpha

func (l *Label) SetAlpha(a float32)

SetAlpha is a convenient way to change the alpha value of the ColorScale.

func (*Label) SetColorScale

func (l *Label) SetColorScale(cs ColorScale)

SetColorScale assigns a new ColorScale to this label's text. Use GetColorScale to retrieve the current color scale.

func (*Label) SetGrowHorizontal

func (l *Label) SetGrowHorizontal(g GrowHorizontal)

func (*Label) SetGrowVertical

func (l *Label) SetGrowVertical(g GrowVertical)

func (*Label) SetShadow

func (l *Label) SetShadow(cs ColorScale)

SetShadow enables rendered text shadows.

The shadow support is experimental and is inefficient. Right now only a 1 pixel-tall, straight vertical shadow is supported.

Experimental: the API will change in the future.

func (*Label) SetSize

func (l *Label) SetSize(w, h int)

func (*Label) SetText

func (l *Label) SetText(s string)

func (*Label) SetVisibility

func (l *Label) SetVisibility(visible bool)

SetVisibility changes the Visible flag value. It can be used to show or hide the label. Use IsVisible to get the current flag value.

type Layer

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

Layer is a simple layer that renders objects in the order they were added.

The objects inside this layer are displayed with respect to the camera transformation.

It expects graphics to implement Object interface. If something implements only a simple gscene Graphics interface, use StaticLayer.

func NewLayer

func NewLayer() *Layer

func (*Layer) AddChild

func (l *Layer) AddChild(g gsceneGraphics)

func (*Layer) DrawWithOptions

func (l *Layer) DrawWithOptions(dst *ebiten.Image, opts DrawOptions)

func (*Layer) Update

func (l *Layer) Update(_ float64)

type Line

type Line struct {
	BeginPos gmath.Pos
	EndPos   gmath.Pos
	// contains filtered or unexported fields
}

Line is a simple 2-point line graphical primitive. Its color and width can be configured.

func NewLine

func NewLine(begin, end gmath.Pos) *Line

NewLine returns a line that is drawn from begin pos to end pos. BeginPos and EndPos fields can be changed directly.

By default, a line has these properties: * Visible=true * The ColorScale is {1, 1, 1, 1} * Width is 1

func (*Line) BoundsRect

func (l *Line) BoundsRect() gmath.Rect

BoundsRect returns a rectangle that fully contains the line.

This is useful when trying to calculate whether this object is contained inside some area or not (like a camera view area).

func (*Line) Dispose

func (l *Line) Dispose()

Dispose marks this line for deletion. After calling this method, IsDisposed will report true.

func (*Line) Draw

func (l *Line) Draw(dst *ebiten.Image)

Draw renders the line onto the provided dst image.

This method is a shorthand to DrawWithOptions(dst, {}) which also implements the gscene.Graphics interface.

See DrawWithOptions for more info.

func (*Line) DrawWithOptions

func (l *Line) DrawWithOptions(dst *ebiten.Image, opts DrawOptions)

DrawWithOptions renders the line onto the provided dst image while also using the extra provided offset and other options.

The offset is applied to both begin and end positions.

func (*Line) GetAlpha

func (l *Line) GetAlpha() float32

GetAlpha is a shorthand for GetColorScale().A expression. It's mostly provided for a symmetry with SetAlpha.

func (*Line) GetColorScale

func (l *Line) GetColorScale() ColorScale

GetColorScale is used to retrieve the current color scale value of the line. Use SetColorScale to change it.

func (*Line) GetWidth

func (l *Line) GetWidth() float64

GetWidth reports the current line width. Use SetWidth to change it.

func (*Line) IsDisposed

func (l *Line) IsDisposed() bool

IsDisposed reports whether this line is marked for deletion. IsDisposed returns true only after Disposed was called on this line.

func (*Line) IsVisible

func (l *Line) IsVisible() bool

IsVisible reports whether this line is visible. Use SetVisibility to change this flag value.

When line is invisible (visible=false), it will not be rendered at all. This is an efficient way to temporarily hide a line.

func (*Line) SetAlpha

func (l *Line) SetAlpha(a float32)

SetAlpha is a convenient way to change the alpha value of the ColorScale.

func (*Line) SetColorScale

func (l *Line) SetColorScale(cs ColorScale)

SetColorScale assigns a new ColorScale to this line. Use GetColorScale to retrieve the current color scale.

func (*Line) SetVisibility

func (l *Line) SetVisibility(visible bool)

SetVisibility changes the Visible flag value. It can be used to show or hide the line. Use IsVisible to get the current flag value.

func (*Line) SetWidth

func (l *Line) SetWidth(w float64)

SetWidth changes the line width. Use GetWidth to retrieve the current line width value.

type Object

type Object interface {
	DrawWithOptions(dst *ebiten.Image, o DrawOptions)
	// contains filtered or unexported methods
}

type Rect

type Rect struct {
	// Pos is a rect location binder.
	// See Pos documentation to learn how it works.
	//
	// When rendering an image, Pos.Resolve() will be used
	// to calculate the final position.
	Pos gmath.Pos
	// contains filtered or unexported fields
}

Rect is a rectangle graphical primitive.

Depending on the configuration, it's one of these:

  • Fill-only rectangle
  • Outline-only rectangle
  • Fill+outline rectangle

If you need a "texture rect", use a sprite instead.

func NewRect

func NewRect(width, height float64) *Rect

NewRect returns a rectangle of the specified size. Use SetSize if you need to resize it afterwards.

By default, a rect has these properties: * Centered=true * Visible=true * The FillColorScale is {1, 1, 1, 1} * The OutlineColorScale is {0, 0, 0, 0} (invisible) * OutlineWidth is 1 (but the default outline color is invisible)

func (*Rect) BoundsRect

func (rect *Rect) BoundsRect() gmath.Rect

BoundsRect returns the properly positioned rectangle.

This is useful when trying to calculate whether this object is contained inside some area or not (like a camera view area).

func (*Rect) Dispose

func (rect *Rect) Dispose()

Dispose marks this rect for deletion. After calling this method, IsDisposed will report true.

func (*Rect) Draw

func (rect *Rect) Draw(dst *ebiten.Image)

Draw renders the rect onto the provided dst image.

This method is a shorthand to DrawWithOptions(dst, {}) which also implements the gscene.Graphics interface.

See DrawWithOptions for more info.

func (*Rect) DrawWithOptions

func (rect *Rect) DrawWithOptions(dst *ebiten.Image, opts DrawOptions)

DrawWithOptions renders the rect onto the provided dst image while also using the extra provided offset.

func (*Rect) GetFillColorScale

func (rect *Rect) GetFillColorScale() ColorScale

GetFillColorScale is used to retrieve the current fill color scale value of the rect. Use SetFillColorScale to change it.

func (*Rect) GetHeight

func (rect *Rect) GetHeight() float64

func (*Rect) GetOutlineColorScale

func (rect *Rect) GetOutlineColorScale() ColorScale

GetOutlineColorScale is used to retrieve the current outline color scale value of the rect. Use SetOutlineColorScale to change it.

func (*Rect) GetOutlineWidth

func (rect *Rect) GetOutlineWidth() float64

GetOutlineWidth reports the current outline width. Use SetOutlineWidth to change it.

func (*Rect) GetWidth

func (rect *Rect) GetWidth() float64

func (*Rect) IsCentered

func (rect *Rect) IsCentered() bool

IsCentered reports whether Centered flag is set. Use SetCentered to change this flag value.

When rect is centered, its image origin will be {w/2, h/2} during rendering.

func (*Rect) IsDisposed

func (rect *Rect) IsDisposed() bool

IsDisposed reports whether this rect is marked for deletion. IsDisposed returns true only after Disposed was called on this rect.

func (*Rect) IsVisible

func (rect *Rect) IsVisible() bool

IsVisible reports whether this rect is visible. Use SetVisibility to change this flag value.

When rect is invisible (visible=false), it will not be rendered at all. This is an efficient way to temporarily hide a rect.

func (*Rect) SetCentered

func (rect *Rect) SetCentered(centered bool)

SetCentered changes the Centered flag value. Use IsCentered to get the current flag value.

func (*Rect) SetFillColorScale

func (rect *Rect) SetFillColorScale(cs ColorScale)

SetFillColorScale assigns a new fill ColorScale to this rect. Use GetFillColorScale to retrieve the current color scale.

func (*Rect) SetHeight

func (rect *Rect) SetHeight(h float64)

func (*Rect) SetOutlineColorScale

func (rect *Rect) SetOutlineColorScale(cs ColorScale)

SetOutlineColorScale assigns a new outline ColorScale to this rect. Use GetOutlineColorScale to retrieve the current color scale.

func (*Rect) SetOutlineWidth

func (rect *Rect) SetOutlineWidth(w float64)

SetOutlineWidth changes the rect outline width. Use GetOutlineWidth to retrieve the current outline width value.

func (*Rect) SetVisibility

func (rect *Rect) SetVisibility(visible bool)

SetVisibility changes the Visible flag value. It can be used to show or hide the rect. Use IsVisible to get the current flag value.

func (*Rect) SetWidth

func (rect *Rect) SetWidth(w float64)

type SceneDrawer

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

func NewSceneDrawer

func NewSceneDrawer(layers []SceneLayerDrawer, minScale float64) *SceneDrawer

NewSceneDrawer creates a configured [gscene.Drawer] for the scene.

It will have a default camera that always has its offset at (0, 0) and its rendered at a full display. This default camera is used if no other cameras are available. Use SceneDrawer.AddCamera to install custom cameras.

A minScale specifies the minimal zoom-out of the camera, e.g. a 0.5 for a double zoom out. This information is needed to prepare the appropriate buffer that could fit all resolutions. When zooming in instead, it doesn't matter as it decreases the visible area. Any values >=1 are essintially ignored. Keep in mind, providing a value like 0.1 means creating an x10 size off-screen image for the temporary buffer.

See SceneDrawer doc comments for more info.

It's advised to only call this function after Ebitengine game has already started.

func (*SceneDrawer) AddCamera

func (d *SceneDrawer) AddCamera(camera *Camera)

func (*SceneDrawer) AddGraphics

func (d *SceneDrawer) AddGraphics(o gsceneGraphics, layer int)

func (*SceneDrawer) Draw

func (d *SceneDrawer) Draw(dst *ebiten.Image)

func (*SceneDrawer) RemoveCamera

func (d *SceneDrawer) RemoveCamera(camera *Camera)

func (*SceneDrawer) Update

func (d *SceneDrawer) Update(delta float64)

type SceneLayerDrawer

type SceneLayerDrawer interface {
	Update(delta float64)

	DrawWithOptions(dst *ebiten.Image, opts DrawOptions)

	AddChild(o gsceneGraphics)
}

type Shader

type Shader struct {

	// Enabled reports whether this shader will be used during the rendering.
	Enabled bool

	Texture1 *ebiten.Image
	Texture2 *ebiten.Image
	Texture3 *ebiten.Image
	// contains filtered or unexported fields
}

Shader is an ebiten.Shader wrapper compatible with types provided by the graphics package.

Shader allocates its uniforms map lazily.

func NewShader

func NewShader(compiled *ebiten.Shader) *Shader

NewShader returns a shader wrapper. The returned shader has Enabled flag set to true.

Use Shader object fields to configure it.

func (*Shader) Clone

func (s *Shader) Clone() *Shader

Clone returns a cloned shader object. It's main purpose is to create a new shader handle that has the identical uniform values those can be modified independently.

func (*Shader) GetValue

func (s *Shader) GetValue(key string) any

GetValue returns the current uniform value stored under the key.

func (*Shader) SetFloatValue

func (s *Shader) SetFloatValue(key string, v float32)

SetFloatValue assigns float Kage uniform variable.

func (*Shader) SetIntValue

func (s *Shader) SetIntValue(key string, v int32)

SetIntValue assigns int Kage uniform variable. Since Kage uniforms are 32-bits, we use int32 here to avoid overflows.

func (*Shader) SetVec2Value

func (s *Shader) SetVec2Value(key string, v []float32)

SetVec2Value assigns vec2 Kage uniform variable. v must be a 2-element slice, otherwise this method will panic.

func (*Shader) SetVec3Value

func (s *Shader) SetVec3Value(key string, v []float32)

SetVec3Value assigns vec3 Kage uniform variable. v must be a 3-element slice, otherwise this method will panic.

func (*Shader) SetVec4Value

func (s *Shader) SetVec4Value(key string, v []float32)

SetVec4Value assigns vec4 Kage uniform variable. v must be a 4-element slice, otherwise this method will panic.

type ShaderObject

type ShaderObject struct {
	Shader *Shader

	Pos gmath.Pos
	// contains filtered or unexported fields
}

ShaderObject implements shader-based rendering.

Instead of using a dummy sprite/image to draw something with a shader, a ShaderObject should be used instead.

The ShaderObject creates a quad shape out of vertices based on the provided position and sizes (w, h). The associated shader is then executed over that quad and the result of that rendering is drawn right into the Draw dst image.

ShaderObject implements gscene Graphics interface.

func NewShaderObject

func NewShaderObject() *ShaderObject

func (*ShaderObject) Dispose

func (o *ShaderObject) Dispose()

func (*ShaderObject) Draw

func (o *ShaderObject) Draw(dst *ebiten.Image)

func (*ShaderObject) DrawWithOptions

func (o *ShaderObject) DrawWithOptions(dst *ebiten.Image, opts DrawOptions)

func (*ShaderObject) GetHeight

func (o *ShaderObject) GetHeight() int

func (*ShaderObject) GetWidth

func (o *ShaderObject) GetWidth() int

func (*ShaderObject) IsDisposed

func (o *ShaderObject) IsDisposed() bool

func (*ShaderObject) IsVisible

func (o *ShaderObject) IsVisible() bool

func (*ShaderObject) SetHeight

func (o *ShaderObject) SetHeight(h int)

func (*ShaderObject) SetVisibility

func (o *ShaderObject) SetVisibility(visible bool)

func (*ShaderObject) SetWidth

func (o *ShaderObject) SetWidth(w int)

type Sprite

type Sprite struct {

	// Pos is a sprite location binder.
	// See Pos documentation to learn how it works.
	//
	// When rendering an image, Pos.Resolve() will be used
	// to calculate the final position.
	Pos gmath.Pos

	// Rotation is a sprite rotation binder.
	// It's expected that sprite's rotation depends on
	// some other object rotation, hence the pointer.
	Rotation *gmath.Rad

	PivotOffset gmath.Vec

	// Shader is an shader that will be used during rendering of the image.
	// Use NewShader to initialize this field.
	//
	// If nil, no shaders will be used.
	Shader *Shader
	// contains filtered or unexported fields
}

Sprite is a feature-rich ebiten.Image wrapper.

Sprites make many operations over the image easier. It also tries to avoid some performance pitfalls related to some edge cases of Ebitengine.

Sprite implements gscene Graphics interface.

func NewSprite

func NewSprite() *Sprite

NewSprite returns an empty sprite. Use SetImage method to assign a texture to it.

By default, a sprite has these properties: * Centered=true * Visible=true * ScaleX and ScaleY are 1 * The ColorScale is {1, 1, 1, 1}

func (*Sprite) BoundsRect

func (s *Sprite) BoundsRect() gmath.Rect

BoundsRect returns the properly positioned image containing rectangle.

This is useful when trying to calculate whether this sprite is contained inside some area or not (like a camera view area).

The bounding rectangle can't be used for collisions since it treats the frame size as an object size.

func (*Sprite) Dispose

func (s *Sprite) Dispose()

Dispose marks this sprite for deletion. After calling this method, IsDisposed will report true.

Note that it's up to the scene to actually detach this sprite. This method only sets a flag but doesn't delete anything.

func (*Sprite) Draw

func (s *Sprite) Draw(dst *ebiten.Image)

Draw renders the associated image onto the provided dst image.

This method is a shorthand to DrawWithOptions(dst, {}) which also implements the gscene.Graphics interface.

See DrawWithOptions for more info.

func (*Sprite) DrawWithOptions

func (s *Sprite) DrawWithOptions(dst *ebiten.Image, opts DrawOptions)

DrawWithOptions renders the associated image onto the provided dst image while also using the extra provided offset.

func (*Sprite) GetAlpha

func (s *Sprite) GetAlpha() float32

GetAlpha is a shorthand for GetColorScale().A expression. It's mostly provided for a symmetry with SetAlpha.

func (*Sprite) GetColorScale

func (s *Sprite) GetColorScale() ColorScale

GetColorScale is used to retrieve the current color scale value of the sprite. Use SetColorScale to change it.

func (*Sprite) GetFrameHeight

func (s *Sprite) GetFrameHeight() int

GetFrameHeight returns the current frame height. Use SetFrameHeight to change it.

func (*Sprite) GetFrameOffsetX

func (s *Sprite) GetFrameOffsetX() int

GetFrameOffsetX returns the currently configured frame offset X. Use SetFrameOffsetX to change it.

func (*Sprite) GetFrameOffsetY

func (s *Sprite) GetFrameOffsetY() int

GetFrameOffsetY returns the currently configured frame offset Y. Use SetFrameOffsetY to change it.

func (*Sprite) GetFrameWidth

func (s *Sprite) GetFrameWidth() int

GetFrameWidth returns the current frame width. Use SetFrameWidth to change it.

func (*Sprite) GetImage

func (s *Sprite) GetImage() *ebiten.Image

GetImage returns the sprite's current texture image.

func (*Sprite) GetScaleX

func (s *Sprite) GetScaleX() float64

GetScaleX returns the sprite horizontal (X-axis) scaling factor. Use SetScaleX to change it.

func (*Sprite) GetScaleY

func (s *Sprite) GetScaleY() float64

GetScaleY returns the sprite vertical (Y-axis) scaling factor. Use SetScaleY to change it.

func (*Sprite) ImageHeight

func (s *Sprite) ImageHeight() int

ImageHeight returns the bound image height. The image size (width/height) can't be changed, unless a new image is assigned to the sprite.

func (*Sprite) ImageWidth

func (s *Sprite) ImageWidth() int

ImageWidth returns the bound image width. The image size (width/height) can't be changed, unless a new image is assigned to the sprite.

func (*Sprite) IsCentered

func (s *Sprite) IsCentered() bool

IsCentered reports whether Centered flag is set. Use SetCentered to change this flag value.

When sprite is centered, its image origin will be {w/2, h/2} during rendering. It also makes the sprite properly rotate around that origin point.

func (*Sprite) IsDisposed

func (s *Sprite) IsDisposed() bool

IsDisposed reports whether this sprite is marked for deletion. IsDisposed returns true only after Disposed was called on this sprite.

func (*Sprite) IsHorizontallyFlipped

func (s *Sprite) IsHorizontallyFlipped() bool

IsHorizontallyFlipped reports whether HorizontalFlip flag is set. Use SetHorizontalFlip to change this flag value.

When sprite is horizontally flipped, it's image will be mirrored horizontally.

func (*Sprite) IsVerticallyFlipped

func (s *Sprite) IsVerticallyFlipped() bool

IsVerticallyFlipped reports whether VerticalFlip flag is set. Use SetVerticalFlip to change this flag value.

When sprite is vertically flipped, it's image will be mirrored vertically.

func (*Sprite) IsVisible

func (s *Sprite) IsVisible() bool

IsVisible reports whether this sprite is visible. Use SetVisibility to change this flag value.

When sprite is invisible (visible=false), its image will not be rendered at all. This is an efficient way to temporarily hide a sprite.

func (*Sprite) SetAlpha

func (s *Sprite) SetAlpha(a float32)

SetAlpha is a convenient way to change the alpha value of the ColorScale.

func (*Sprite) SetCentered

func (s *Sprite) SetCentered(centered bool)

SetCentered changes the Centered flag value. Use IsCentered to get the current flag value.

func (*Sprite) SetColorScale

func (s *Sprite) SetColorScale(cs ColorScale)

SetColorScale assigns a new ColorScale to this sprite. Use GetColorScale to retrieve the current color scale.

func (*Sprite) SetFrameHeight

func (s *Sprite) SetFrameHeight(h int)

SetFrameHeight assigns new frame height. Use GetFrameHeight to retrieve the current value.

The frame sizes are useful when working with an underlying image that contains several logical images ("frames"). A frame size defines an image rectangle sizes to be used. A frame offset defines the rectangle Min value.

func (*Sprite) SetFrameOffsetX

func (s *Sprite) SetFrameOffsetX(x int)

SetFrameOffsetX assigns new frame X offset. Use GetFrameOffsetX to retrieve the current offset values.

The frame offsets are useful when working with an underlying image that contains several logical images ("frames"). A frame offset defines the rectangle Min value. A frame size defines an image rectangle sizes to be used.

func (*Sprite) SetFrameOffsetY

func (s *Sprite) SetFrameOffsetY(y int)

SetFrameOffsetY assigns new frame Y offset. Use GetFrameOffsetY to retrieve the current offset values.

The frame offsets are useful when working with an underlying image that contains several logical images ("frames"). A frame offset defines the rectangle Min value. A frame size defines an image rectangle sizes to be used.

func (*Sprite) SetFrameWidth

func (s *Sprite) SetFrameWidth(w int)

SetFrameWidth assigns new frame width. Use GetFrameWidth to retrieve the current value.

The frame sizes are useful when working with an underlying image that contains several logical images ("frames"). A frame size defines an image rectangle sizes to be used. A frame offset defines the rectangle Min value.

func (*Sprite) SetHorizontalFlip

func (s *Sprite) SetHorizontalFlip(hflip bool)

SetHorizontalFlip changes the HorizontalFlip flag value. Use IsHorizontallyFlipped to get the current flag value.

func (*Sprite) SetImage

func (s *Sprite) SetImage(img *ebiten.Image)

SetImage changes the image associated with a sprite.

Assigning an image sets the frame offsets to {0, 0}. The default frame width/height are image sizes.

func (*Sprite) SetScaleX

func (s *Sprite) SetScaleX(scale float64)

SetScaleX assigns new sprite horizontal (X-axis) scaling factor. Use GetScaleX to retrieve the current value.

func (*Sprite) SetScaleY

func (s *Sprite) SetScaleY(scale float64)

SetScaleY assigns new sprite vertical (Y-axis) scaling factor. Use GetScaleY to retrieve the current value.

func (*Sprite) SetVerticalFlip

func (s *Sprite) SetVerticalFlip(vflip bool)

SetVerticalFlip changes the VerticalFlip flag value. Use IsVerticallyFlipped to get the current flag value.

func (*Sprite) SetVisibility

func (s *Sprite) SetVisibility(visible bool)

SetVisibility changes the Visible flag value. It can be used to show or hide the sprite. Use IsVisible to get the current flag value.

type StaticLayer

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

StaticLayer is like Layer, but objects are rendered in a camera-independent way. It renders the objects in the order they were added to the layer.

The objects inside this layer ignore the camera transformation, this is why having just Draw() method on objects is enough.

This layer is well-suited for HUDs and overlays.

func NewStaticLayer

func NewStaticLayer() *StaticLayer

func (*StaticLayer) AddChild

func (l *StaticLayer) AddChild(g gsceneGraphics)

func (*StaticLayer) DrawWithOptions

func (l *StaticLayer) DrawWithOptions(dst *ebiten.Image, _ DrawOptions)

func (*StaticLayer) Update

func (l *StaticLayer) Update(_ float64)

type TextureLine

type TextureLine struct {
	BeginPos gmath.Pos
	EndPos   gmath.Pos

	// Shader is an shader that will be used during rendering of the line.
	// Use NewShader to initialize this field.
	//
	// If nil, no shaders will be used.
	Shader *Shader
	// contains filtered or unexported fields
}

func NewTextureLine

func NewTextureLine(begin, end gmath.Pos) *TextureLine

func (*TextureLine) BoundsRect

func (l *TextureLine) BoundsRect() gmath.Rect

func (*TextureLine) Dispose

func (l *TextureLine) Dispose()

func (*TextureLine) Draw

func (l *TextureLine) Draw(dst *ebiten.Image)

Draw renders the texture line onto the provided dst image.

This method is a shorthand to DrawWithOptions(dst, {}) which also implements the gscene.Graphics interface.

See DrawWithOptions for more info.

func (*TextureLine) DrawWithOptions

func (l *TextureLine) DrawWithOptions(dst *ebiten.Image, opts DrawOptions)

DrawWithOptions renders the texture line onto the provided dst image while also using the extra provided offset and other options.

The offset is applied to both begin and end positions.

func (*TextureLine) GetAlpha

func (l *TextureLine) GetAlpha() float32

GetAlpha is a shorthand for GetColorScale().A expression. It's mostly provided for a symmetry with SetAlpha.

func (*TextureLine) GetColorScale

func (l *TextureLine) GetColorScale() ColorScale

GetColorScale is used to retrieve the current color scale value of texture line. Use SetColorScale to change it.

func (*TextureLine) GetTexture

func (l *TextureLine) GetTexture() *ebiten.Image

func (*TextureLine) IsDisposed

func (l *TextureLine) IsDisposed() bool

func (*TextureLine) IsVisible

func (l *TextureLine) IsVisible() bool

IsVisible reports whether this texture line is visible. Use SetVisibility to change this flag value.

When texture line is invisible (visible=false), it will not be rendered at all. This is an efficient way to temporarily hide a texture line.

func (*TextureLine) SetAlpha

func (l *TextureLine) SetAlpha(a float32)

SetAlpha is a convenient way to change the alpha value of the ColorScale.

func (*TextureLine) SetColorScale

func (l *TextureLine) SetColorScale(cs ColorScale)

SetColorScale assigns a new ColorScale to this texture line. Use GetColorScale to retrieve the current color scale.

func (*TextureLine) SetTexture

func (l *TextureLine) SetTexture(texture *ebiten.Image)

SetTexture assigns the repeatable line texture.

This texture should loop well if the line's length can be higher than the texture's width.

func (*TextureLine) SetVisibility

func (l *TextureLine) SetVisibility(visible bool)

SetVisibility changes the Visible flag value. It can be used to show or hide the texture line. Use IsVisible to get the current flag value.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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