types

package
v0.0.0-...-2fe9ae2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColorBlack = Color{0, 0, 0, 1}

ColorBlack is opaque black.

View Source
var ColorTransparent = Color{0, 0, 0, 0}

ColorTransparent is fully transparent black.

View Source
var ColorWhite = Color{1, 1, 1, 1}

ColorWhite is the default tint (no color modification).

Functions

func Clamp01

func Clamp01(v float64) float64

Clamp01 clamps a value to [0, 1].

func ColorFieldPtrs

func ColorFieldPtrs(c *Color) (r, g, b, a *float64)

ColorFieldPtrs returns pointers to the individual color component fields. Used by tween code that needs to mutate color fields via pointer.

func Lerp

func Lerp(a, b, t float64) float64

Lerp linearly interpolates between a and b by t.

func Lerp32

func Lerp32(a, b, t float32) float32

Lerp32 linearly interpolates between a and b by t (float32).

func TweenEase

func TweenEase(cfg TweenConfig) ease.TweenFunc

TweenEase returns cfg.Ease if non-nil, otherwise ease.Linear.

Types

type BlendMode

type BlendMode uint8

BlendMode selects a compositing operation. Each maps to a specific ebiten.Blend value.

const (
	BlendNormal   BlendMode = iota // source-over (standard alpha blending)
	BlendAdd                       // additive / lighter
	BlendMultiply                  // multiply (source * destination; only darkens)
	BlendScreen                    // screen (1 - (1-src)*(1-dst); only brightens)
	BlendErase                     // destination-out (punch transparent holes)
	BlendMask                      // clip destination to source alpha
	BlendBelow                     // destination-over (draw behind existing content)
	BlendNone                      // opaque copy (skip blending)
)

func (BlendMode) EbitenBlend

func (b BlendMode) EbitenBlend() ebiten.Blend

EbitenBlend returns the ebiten.Blend value corresponding to this BlendMode.

type CacheTreeMode

type CacheTreeMode uint8

CacheTreeMode controls how a cached subtree invalidates.

const (
	// CacheTreeManual requires the user to call InvalidateCacheTree() when
	// the subtree changes. Zero overhead on setters. Best for large tilemaps.
	CacheTreeManual CacheTreeMode = iota + 1

	// CacheTreeAuto automatically invalidates when any setter is called on
	// the cached node or its descendants. Small overhead per setter call
	// (one pointer chase + bool write).
	CacheTreeAuto
)

type Color

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

Color represents an RGBA color with components in [0, 1]. Not premultiplied. Premultiplication occurs at render submission time.

Use RGB or RGBA to construct colors. RGB defaults alpha to 1 (fully opaque), eliminating the common mistake of forgetting alpha.

func ColorFromHSV

func ColorFromHSV(h, s, v float64) Color

ColorFromHSV creates a Color from HSV values, all in [0, 1]. Hue wraps (0 and 1 are both red), saturation 0 is grayscale, value 0 is black.

func ColorFromRGBA

func ColorFromRGBA(r, g, b, a uint8) Color

ColorFromRGBA creates a Color from 8-bit RGBA components (0–255). The returned Color is non-premultiplied with components in [0, 1].

func RGB

func RGB(r, g, b float64) Color

RGB creates an opaque Color from red, green, blue components in [0, 1]. Alpha is set to 1 (fully opaque).

func RGBA

func RGBA(r, g, b, a float64) Color

RGBA creates a Color from red, green, blue, alpha components in [0, 1].

func (Color) A

func (c Color) A() float64

A returns the alpha component in [0, 1].

func (Color) B

func (c Color) B() float64

B returns the blue component in [0, 1].

func (Color) G

func (c Color) G() float64

G returns the green component in [0, 1].

func (Color) R

func (c Color) R() float64

R returns the red component in [0, 1].

func (Color) RGBA

func (c Color) RGBA() (r, g, b, a uint32)

RGBA returns the alpha-premultiplied red, green, blue and alpha values scaled to [0, 0xFFFF]. This satisfies the image/color.Color interface.

func (Color) RGBA8

func (c Color) RGBA8() (r, g, b, a uint8)

RGBA8 returns the color as 8-bit RGBA components (0–255), premultiplied.

type EventType

type EventType uint8

EventType identifies a kind of interaction event.

const (
	EventPointerDown  EventType = iota // fires when a pointer button is pressed
	EventPointerUp                     // fires when a pointer button is released
	EventPointerMove                   // fires when the pointer moves (hover, no button)
	EventClick                         // fires on press then release over the same node
	EventDragStart                     // fires when movement exceeds the drag dead zone
	EventDrag                          // fires each frame while dragging
	EventDragEnd                       // fires when the pointer is released after dragging
	EventPinch                         // fires during a two-finger pinch/rotate gesture
	EventPointerEnter                  // fires when the pointer enters a node's bounds
	EventPointerLeave                  // fires when the pointer leaves a node's bounds
	EventBgClick                       // internal: background click (no node hit)
)

type HitShape

type HitShape interface {
	// Contains reports whether the local-space point (x, y) is inside the shape.
	Contains(x, y float64) bool
}

HitShape is implemented by custom hit-test shapes attached to a Node.

type KeyModifiers

type KeyModifiers uint8

KeyModifiers is a bitmask of keyboard modifier keys. Values can be combined with bitwise OR (e.g. ModShift | ModCtrl).

const (
	ModShift KeyModifiers = 1 << iota // Shift key
	ModCtrl                           // Control key
	ModAlt                            // Alt / Option key
	ModMeta                           // Meta / Command / Windows key
)

type MouseButton

type MouseButton uint8

MouseButton identifies a mouse button.

const (
	MouseButtonLeft   MouseButton = iota // primary (left) mouse button
	MouseButtonRight                     // secondary (right) mouse button
	MouseButtonMiddle                    // middle mouse button (scroll wheel click)
)

type NodeType

type NodeType uint8

NodeType distinguishes rendering behavior for a Node.

const (
	NodeTypeContainer       NodeType = iota // group node with no visual output
	NodeTypeSprite                          // renders a TextureRegion or custom image
	NodeTypeMesh                            // renders arbitrary triangles via DrawTriangles
	NodeTypeParticleEmitter                 // CPU-simulated particle system
	NodeTypeText                            // renders text via DistanceFieldFont
)

type Range

type Range struct {
	Min, Max float64
}

Range is a general-purpose min/max range. Used by the particle system (EmitterConfig) and potentially other systems.

func (Range) Random

func (r Range) Random() float64

Random returns a random float64 in [Min, Max].

type Rect

type Rect struct {
	X, Y, Width, Height float64
}

Rect is an axis-aligned rectangle. The coordinate system has its origin at the top-left, with Y increasing downward.

func (Rect) Contains

func (r Rect) Contains(x, y float64) bool

Contains reports whether the point (x, y) lies inside the rectangle. Points on the edge are considered inside.

func (Rect) Intersects

func (r Rect) Intersects(other Rect) bool

Intersects reports whether r and other overlap. Adjacent rectangles (sharing only an edge) are considered intersecting.

type TextAlign

type TextAlign uint8

TextAlign controls horizontal text alignment within a TextBlock.

const (
	TextAlignLeft   TextAlign = iota // align text to the left edge (default)
	TextAlignCenter                  // center text horizontally
	TextAlignRight                   // align text to the right edge
)

type TextureRegion

type TextureRegion struct {
	Page      uint16 // atlas page index (references Scene.pages)
	X, Y      uint16 // top-left corner of the sub-image rect within the atlas page
	Width     uint16 // width of the sub-image rect (may differ from OriginalW if trimmed)
	Height    uint16 // height of the sub-image rect (may differ from OriginalH if trimmed)
	OriginalW uint16 // untrimmed sprite width as authored
	OriginalH uint16 // untrimmed sprite height as authored
	OffsetX   int16  // horizontal trim offset from TexturePacker
	OffsetY   int16  // vertical trim offset from TexturePacker
	Rotated   bool   // true if the region is stored 90 degrees clockwise in the atlas
}

TextureRegion describes a sub-rectangle within an atlas page. Value type (32 bytes) — stored directly on Node, no pointer.

type TweenConfig

type TweenConfig struct {
	Duration float32        // seconds; 0 = instant
	Ease     ease.TweenFunc // nil defaults to ease.Linear
}

TweenConfig holds the duration and easing function for a tween. A nil Ease defaults to ease.Linear. Duration is in seconds; 0 means instant.

type Vec2

type Vec2 struct {
	X, Y float64
}

Vec2 is a 2D vector used for positions, offsets, sizes, and directions throughout the API.

Jump to

Keyboard shortcuts

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