Documentation
¶
Index ¶
- Variables
- func GenerateCircle(radius float64) *ebiten.Image
- type Light
- type LightLayer
- func (ll *LightLayer) AddLight(l *Light)
- func (ll *LightLayer) AmbientAlpha() float64
- func (ll *LightLayer) ClearLights()
- func (ll *LightLayer) Dispose()
- func (ll *LightLayer) Lights() []*Light
- func (ll *LightLayer) Node() *node.Node
- func (ll *LightLayer) Redraw()
- func (ll *LightLayer) RemoveLight(l *Light)
- func (ll *LightLayer) RenderTextureImage() *ebiten.Image
- func (ll *LightLayer) SetAmbientAlpha(a float64)
- func (ll *LightLayer) SetCircleRadius(radius float64)
- func (ll *LightLayer) SetPages(pages []*ebiten.Image)
Constants ¶
This section is empty.
Variables ¶
var ( // NewRenderTextureFn creates a RenderTexture and returns it as any. NewRenderTextureFn func(w, h int) any // RenderTextureImageFn returns the *ebiten.Image from a RenderTexture (any). RenderTextureImageFn func(rt any) *ebiten.Image // RenderTextureNewSpriteFn creates a sprite node from a RenderTexture. RenderTextureNewSpriteFn func(rt any, name string) *node.Node // RenderTextureDisposeFn disposes a RenderTexture. RenderTextureDisposeFn func(rt any) // MagentaPlaceholderPage is the sentinel page index. MagentaPlaceholderPage uint16 = 0xFFFF // EnsureMagentaImageFn returns the 1x1 magenta placeholder image. EnsureMagentaImageFn func() *ebiten.Image // Clamp01Fn clamps a value to [0, 1]. Clamp01Fn func(v float64) float64 )
Function pointers wired by root to break dependency on render/ and atlas/.
Functions ¶
func GenerateCircle ¶
GenerateCircle creates a feathered white circle image with the given radius.
Types ¶
type Light ¶
type Light struct {
X, Y float64
Radius float64
Rotation float64
Intensity float64
Enabled bool
Color types.Color
// TextureRegion, if non-zero, uses this sprite sheet region instead of
// the default feathered circle.
TextureRegion types.TextureRegion
// Target, if set, makes the light follow this node's pivot point each Redraw.
Target *node.Node
OffsetX float64
OffsetY float64
}
Light represents a light source in a LightLayer.
type LightLayer ¶
type LightLayer struct {
// contains filtered or unexported fields
}
LightLayer provides a convenient 2D lighting effect using erase blending.
func NewLightLayer ¶
func NewLightLayer(w, h int, ambientAlpha float64) *LightLayer
NewLightLayer creates a light layer covering (w x h) pixels.
func (*LightLayer) AddLight ¶
func (ll *LightLayer) AddLight(l *Light)
AddLight adds a light to the layer.
func (*LightLayer) AmbientAlpha ¶
func (ll *LightLayer) AmbientAlpha() float64
AmbientAlpha returns the current ambient darkness level.
func (*LightLayer) ClearLights ¶
func (ll *LightLayer) ClearLights()
ClearLights removes all lights from the layer.
func (*LightLayer) Dispose ¶
func (ll *LightLayer) Dispose()
Dispose releases all resources owned by the light layer.
func (*LightLayer) Lights ¶
func (ll *LightLayer) Lights() []*Light
Lights returns the current light list. The returned slice MUST NOT be mutated.
func (*LightLayer) Node ¶
func (ll *LightLayer) Node() *node.Node
Node returns the sprite node that displays the light layer.
func (*LightLayer) Redraw ¶
func (ll *LightLayer) Redraw()
Redraw fills the texture with ambient darkness then erases light shapes.
func (*LightLayer) RemoveLight ¶
func (ll *LightLayer) RemoveLight(l *Light)
RemoveLight removes a light from the layer.
func (*LightLayer) RenderTextureImage ¶
func (ll *LightLayer) RenderTextureImage() *ebiten.Image
RenderTextureImage returns the underlying *ebiten.Image of the render texture.
func (*LightLayer) SetAmbientAlpha ¶
func (ll *LightLayer) SetAmbientAlpha(a float64)
SetAmbientAlpha sets the base darkness level.
func (*LightLayer) SetCircleRadius ¶
func (ll *LightLayer) SetCircleRadius(radius float64)
SetCircleRadius pre-generates a feathered circle texture at the given radius.
func (*LightLayer) SetPages ¶
func (ll *LightLayer) SetPages(pages []*ebiten.Image)
SetPages stores the atlas page images used to resolve Light.TextureRegion.