Documentation
¶
Overview ¶
Package render draws Linefire assets with the ebiten vector package. The same code is used by the editor canvas (zoomed) and the real-size preview, and is intended to be reusable by the future game.
Index ¶
- func DrawAsset(dst *ebiten.Image, a *asset.Asset, v View, antialias bool)
- func DrawLayers(dst *ebiten.Image, layers []asset.Layer, v View, antialias bool)
- func FillCircle(dst *ebiten.Image, cx, cy, r float64, col color.RGBA)
- func FillCircleAdd(dst *ebiten.Image, cx, cy, r float64, col color.RGBA, gain float64)
- func ParseColor(s string) (col color.RGBA, visible bool)
- func StrokeLine(dst *ebiten.Image, x0, y0, x1, y1, width float64, col color.RGBA)
- func StrokeLineAdd(dst *ebiten.Image, x0, y0, x1, y1, width float64, col color.RGBA, gain float64)
- type CRT
- type CRTOptions
- type Glow
- type GlowOptions
- type GlowVariant
- type Mesh
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DrawAsset ¶
DrawAsset renders every layer of the asset into dst using the given view. Filled shapes are drawn first, then strokes on top. It draws the crisp geometry only; the additive bloom that uses the per-layer glow field is applied separately by Glow (see glow.go).
func DrawLayers ¶
DrawLayers renders a slice of styled layers (used for both assets and map walls, which share the layer format).
func FillCircle ¶ added in v0.0.6
FillCircle draws a tinted disc of radius r (device px) centered at (cx, cy).
func FillCircleAdd ¶ added in v0.0.6
FillCircleAdd is FillCircle with ADDITIVE blending, scaled by gain — the same light-adding draw the bolts use. Note that a caller fades an additive mark with gain, NOT with the color's alpha: additive blending ignores the destination, so a lower alpha alone would leave the mark just as bright.
func ParseColor ¶
ParseColor parses a color string. It accepts "#rgb", "#rrggbb" and "#rrggbbaa". An empty string or "transparent" reports visible == false so the caller can skip drawing that stroke or fill.
func StrokeLine ¶ added in v0.0.6
StrokeLine draws a tinted straight streak of the given width (device px) from (x0, y0) to (x1, y1), butt-capped like the vector StrokeLine it replaces.
func StrokeLineAdd ¶ added in v0.0.6
StrokeLineAdd is StrokeLine with ADDITIVE blending, scaled by gain: the streak adds light to whatever lies under it instead of covering it. That is how kutta composites its glowing smoke, and it is what makes a mark read as hot — the same stroke drawn over-and-over blows out to white where it overlaps.
Types ¶
type CRTOptions ¶
type CRTOptions struct {
Curvature float64
ScanIntensity float64
Aberration float64 // pixels
Vignette float64
}
CRTOptions are the tunable parameters of the CRT post-process.
func DefaultCRTOptions ¶
func DefaultCRTOptions() CRTOptions
DefaultCRTOptions returns a subtle CRT look — gentle curvature and faint scanlines/aberration, meant to suggest a CRT rather than distort heavily.
type Glow ¶
type Glow struct {
// contains filtered or unexported fields
}
Glow renders an asset's strokes with an additive bloom. It owns offscreen buffers sized to the region it is used for; use one Glow per region (e.g. one for the canvas and one for the preview) so the buffers stay a stable size.
func NewGlow ¶
func NewGlow() *Glow
NewGlow returns an empty glow renderer; buffers are created on first use.
func (*Glow) Apply ¶
func (g *Glow) Apply(dst *ebiten.Image, layers []asset.Layer, view View, region image.Rectangle, opts GlowOptions)
Apply adds a bloom for the given layers into dst, confined to region, using the screen-space view (the editors' CPU-transform path). The crisp geometry should already be drawn; this only adds the additive glow on top.
func (*Glow) Bloom ¶
func (g *Glow) Bloom(dst *ebiten.Image, region image.Rectangle, opts GlowOptions, fillEmissive func(emissive *ebiten.Image))
Bloom blurs whatever fillEmissive draws into the (cleared) emissive buffer and adds it to dst with the variant's intensity. This decouples the bloom from how the bright source is produced: the editors fill it via a View; the game draws a world mesh with the camera GeoM (so the GPU does the transform). It is a no-op if the shader is unavailable.
func (*Glow) Deallocate ¶
func (g *Glow) Deallocate()
Deallocate returns the offscreen buffers' textures to the GPU immediately — otherwise they wait on Go FINALIZERS, which lag far behind on wasm (the iOS tab-kill ratchet). The Glow stays usable: the next Bloom recreates them.
type GlowOptions ¶
type GlowOptions struct {
Variant GlowVariant
Time float64 // seconds, for the pulse variant
Intensity float64 // base multiplier; 0 is treated as 1
Spread float64 // blur step in target pixels; 0 uses the variant default
Iterations int // separable blur iterations; 0 uses the variant default
AntiAlias bool
}
GlowOptions controls a glow pass.
type GlowVariant ¶
type GlowVariant int
GlowVariant selects the look of the bloom.
const ( GlowStable GlowVariant = iota // steady halo GlowPulse // halo pulses over time GlowLaser // bright tight core plus a wide soft halo )
func (GlowVariant) String ¶
func (v GlowVariant) String() string
String names the variant for the UI.
type Mesh ¶
type Mesh struct {
// contains filtered or unexported fields
}
Mesh is cached vector path data in world/asset coordinates. Draw transforms only visible paths and lets Ebitengine's modern vector renderer handle the final stroke/fill quality, avoiding rotated bitmap artifacts.
func BuildGlowMesh ¶
BuildGlowMesh caches only glowing strokes for the bloom emissive source.
func BuildLayersMesh ¶
BuildLayersMesh caches the crisp geometry of layers: fills for closed paths and strokes for visible strokes.
func (*Mesh) DrawTinted ¶
DrawTinted renders the cached geometry like Draw, but multiplies every path color by tint — e.g. a dimmed, translucent scale to draw a faded ghost. The zero ColorScale is identity, so Draw is just DrawTinted with no tint.
type View ¶
View describes how asset-space coordinates map to screen pixels: a uniform scale plus a translation. ScreenX = OffsetX + assetX*Scale. It is used by the editors (small assets, CPU transform). The game instead caches world geometry once and applies the camera to visible batches before drawing (see mesh.go).