render

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 27 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package render is the drawing side of gram, knowing nothing of Stages, Scenes or plugins: what a Scene and a plugin draw with. Everything is drawn on the GPU (internal/gpu), in WGSL; the engine hands render its window's device (UseDevice, Present).

A Scene's parts are [Renderer]s, drawing on the screen once a frame; a Picture is what is in the world before a camera, drawn through the camera it is handed and shown by a Feed at a size (Surface): whole, in layers or with its figures sharp. A Reporter adds lines to the telemetry panel.

The world's picture is a Composer of [Source]s, each handing its pieces to a Frame where they lie (At), drawn back to front against the depth; a Direct source draws its part itself with a shader of its own (NewMeshShaderWith, [Image.DrawMesh]; instances that stand are kept on the GPU, Instances), in the passes it asks for: the opaque ground ([Frame.DrawOpaque]), the cutouts after it ([Frame.DrawCutout]: what stands whole, cut at half its alpha, writing the depth, in no order, so what stands behind or under it is hidden), and among what is seen through ([Frame.DrawAt]); Sprites as instances, [Sprites.Cutout] naming those of the cutout pass; Sprites lay what is seen from afar as points too, a pixel at least, as opaque as they cover of it. What must show under what covers it is uncovered ([Frame.DrawUncovered], before the cutouts, into a depth of its own, Target.Uncovered): what gives way is left out in part where it lies nearer ([Sprites.Uncover], [Sprites.GiveWay]). What is worked out per pixel is a material (RegisterMaterials), what every shader of a frame reads beside the uniforms an image (RegisterImage, [Frame.Image]).

Pictures are [Image]s on the GPU, drawn into and filled ([Image.FillRect] and kin); sprites are painted on the CPU into an Atlas (SpriteDrawer, Solid and kin, Blob one seen from afar) or shot on the GPU into their places on it ([Atlas.AddShot]), text in a Font, and by points of the world, as deep as they stand, in Labels (text and badges). A Look is a drawer, a material or frames (Phases, Loops); an Appearance is the sprite a thing is drawn from. A color.RGBA given to render is straight alpha; render premultiplies it for the GPU.

The machinery is render/internal's: gpu (the device), wgsl (the shaders' library, the materials and the frame's images), gfx (images, depths, meshes, shaders), atlas, text, feed, compose (the composer and its frame) and instanced (sprites as instances); render names their types by alias.

Index

Constants

View Source
const (
	Opaque     = compose.Opaque
	Uncovered  = compose.Uncovered
	Cutout     = compose.Cutout
	SeeThrough = compose.SeeThrough
)

The passes: the opaque ground first, then what is uncovered, into a depth of its own, then the cutouts, what stands whole cut at half its alpha and writing the depth, then what is seen through, back to front.

View Source
const (
	TakesRelief = compose.TakesRelief
	TakesBlocks = compose.TakesBlocks
	TakesClouds = compose.TakesClouds
	TakesLamps  = compose.TakesLamps
	Shines      = compose.Shines
	TakesAll    = compose.TakesAll
)

The shades a drawn thing takes.

View Source
const (
	FilterNearest = gfx.FilterNearest
	FilterLinear  = gfx.FilterLinear
)

The filters.

View Source
const (
	Patch      = light.Patch
	Silhouette = light.Silhouette
	Baked      = light.Baked
	NoShadow   = light.NoShadow
)

The ways a thing casts its shadow (light.Patch…).

View Source
const (
	// BadgeDisc is a round badge.
	BadgeDisc = instanced.BadgeDisc
	// BadgeDiamond is a square badge standing on a corner.
	BadgeDiamond = instanced.BadgeDiamond
)
View Source
const LayerFeather = feed.LayerFeather

LayerFeather is the shown pixels an inner layer's edge fades over.

View Source
const MaxLamps = wgsl.Lamps

MaxLamps is how many lamps at most light a picture: the nearest its camera.

View Source
const MaxOpenings = light.MaxOpenings

MaxOpenings is how many of a shelter's openings let the distant light in.

View Source
const MaxSprites = 1 << 16

MaxSprites is how many sprites an atlas holds: the range of SpriteID.

View Source
const ShadeBands = compose.ShadeBands

ShadeBands is how many bands of rows down the ground's shade fade on their own.

View Source
const ShadowReach = light.ShadowReach

ShadowReach is how many times its caster's height any shadow reaches at most (light.ShadowReach).

Variables

View Source
var (
	// Furthest is behind the whole world: the sky.
	Furthest = compose.Furthest
	// Nearest is before the whole world: what falls through the air.
	Nearest = compose.Nearest
)
View Source
var WhiteLight = Illumination{Light: Light{1, 1, 1}, Takes: TakesAll}

WhiteLight is a thing drawn as it is, taking every shade: a world without a light plugin.

Functions

func ActualFPS added in v0.3.0

func ActualFPS() float64

ActualFPS is how many frames the engine drew in the last second.

func BadgeWidth added in v0.20.0

func BadgeWidth(n int, shape BadgeShape, size float32) float32

BadgeWidth is how many shown pixels across a badge of shape at least size across is to hold n written in its middle, nothing written where n is not positive; it may be asked on any goroutine.

func Compile added in v0.3.0

func Compile() error

Compile compiles the composer's shader now rather than at its first draw.

func DebugPrintAt added in v0.3.0

func DebugPrintAt(dst *Image, s string, x, y int)

DebugPrintAt prints s with its top-left corner at (x, y), a line of it under another at each newline, in the fixed debug text.

func Files added in v0.3.0

func Files(fs embed.FS, names ...string) []byte

Files joins the named files of fs, in order, into one WGSL source.

func MeanColour added in v0.19.0

func MeanColour(draw SpriteDrawer, size int) color.RGBA

MeanColour is the colour a Blob of draw drawn size x size fills its disc with, opaque: draw's mean weighted by its alpha; clear for a clear sprite.

func Prepare added in v0.5.0

func Prepare() error

Prepare compiles every shader, fills every image deferred and puts on the GPU every texture whose pixels wait on the CPU: what a stage's first frame would do on its own, done before it.

func Present added in v0.5.0

func Present(enc *wgpu.CommandEncoder, view *wgpu.TextureView, format gputypes.TextureFormat,
	w, h int, screen *Image) error

Present draws screen over the window's surface view, w by h pixels of format, into enc, the window's frame encoder. Everything drawn before is submitted first.

func RegisterImage added in v0.3.0

func RegisterImage(name string)

RegisterImage names an image every shader built on the materials may read, a texture_2d<f32> of that name in WGSL, which a frame hands them (Frame.Image). It panics once a shader has been built, for a name given twice and past gpu.FrameImages names.

func SetRates added in v0.3.0

func SetRates(fps float64)

SetRates notes the frames the engine drew in the last second, on the frame's barrier.

func SetSpent added in v0.3.0

func SetSpent(update, draw, present time.Duration)

SetSpent notes where a frame's time went on average over the last second, on the frame's barrier: its tick (the simulation and the publishing), its drawing and its presenting.

func ShaderSource added in v0.3.0

func ShaderSource() string

ShaderSource is the composer's shader as it compiles.

func Spent added in v0.3.0

func Spent() (update, draw, present time.Duration)

Spent is where a frame's time went on average over the last second.

func StyleOf added in v0.3.0

func StyleOf[S Style](s *Styles, id SpriteID) (S, bool)

StyleOf is the style of type S declared for the sprite id, false where none was; a nil Styles has none.

func Submit added in v0.5.0

func Submit()

Submit sends every draw gathered so far to the GPU.

func UseDevice added in v0.5.0

func UseDevice(dev *wgpu.Device, backend gputypes.Backend) error

UseDevice has render draw on dev, the device of the engine's window, made by backend: Vulkan takes a program's SPIR-V kept on disk, the others want its WGSL.

func VisitWrapImages

func VisitWrapImages(
	box plane.AABB,
	worldW, worldH float32,
	fn func(img geom.AABB, dx, dy float32) bool,
)

VisitWrapImages calls fn with the box and world shift of each image of box, until fn says stop.

func Windowed added in v0.5.0

func Windowed()

Windowed says the device will be the engine's window's: none is made without it.

Types

type Appearance added in v0.3.0

type Appearance struct {
	SpriteID SpriteID
	Sway     float32
	// Angle turns the look about the middle of the entity's box, in degrees, 0 east, against the
	// clock with the screen's y growing down. The box stays axis-aligned: content past the circle
	// inscribed in it swings outside the box as the sprite turns.
	Angle float32
}

Appearance is the sprite a thing is drawn from and how far it sways where what lays it leans what sways, 0 not at all to 1 in full.

func (Appearance) Knob added in v0.3.0

func (Appearance) Knob()

Knob: an effect may turn it (effect.Knob).

type At added in v0.3.0

type At = compose.At

At is where a piece of the picture lies: at a height in the world, or on top of it as a mark.

func OnTop added in v0.3.0

func OnTop(level float32) At

OnTop is a mark at level, not the world: drawn over it on the screen, a higher level over a lower, at one level in the order the marks came.

type Atlas

type Atlas = atlas.Atlas

Atlas is an AtlasSource built by adding sprites, each at a size of its own, and then Close, which lays the sheet out and bakes it.

func NewAtlas

func NewAtlas() *Atlas

NewAtlas starts an empty atlas.

type AtlasSource

type AtlasSource = gfx.AtlasSource

AtlasSource supplies the sprite sheet a Frame draws from.

type BadgeShape added in v0.20.0

type BadgeShape = instanced.BadgeShape

BadgeShape is the outline of a badge Labels draws.

type Beam added in v0.5.0

type Beam = light.Beam

Beam is a Distant ready to light many surfaces (light.Beam).

type Beat added in v0.3.0

type Beat struct {
	Frame int
	Span  time.Duration
}

Beat is one span of a timed look: which frame is shown, for how long.

type Block added in v0.5.0

type Block = light.Block

Block is a solid whose shadow the ground bakes (light.Block).

type BlockSet added in v0.20.0

type BlockSet = light.BlockSet

BlockSet is the blocks standing in one part of the world, versioned (light.BlockSet).

type Buffered added in v0.5.0

type Buffered[T any] struct {
	// contains filtered or unexported fields
}

Buffered is what a source draws, kept twice: Back is written by its publisher while Front is drawn, and Swap, while nothing draws, trades them.

func (*Buffered[T]) Back added in v0.5.0

func (b *Buffered[T]) Back() *T

Back is what is drawn next, being written.

func (*Buffered[T]) Front added in v0.5.0

func (b *Buffered[T]) Front() *T

Front is what is drawn.

func (*Buffered[T]) Swap added in v0.5.0

func (b *Buffered[T]) Swap()

Swap has the back drawn and the front written next.

type Canvas added in v0.3.0

type Canvas = atlas.Canvas

Canvas is a sprite's pixels as a SpriteDrawer paints them.

type Casting added in v0.5.0

type Casting = light.Casting

Casting is how a thing casts its shadow on the ground (light.Casting).

type Composer added in v0.3.0

type Composer = compose.Composer

Composer is a Picture drawing its Sources as one picture, laid in layers as a Laid one.

func NewComposer added in v0.3.0

func NewComposer(sources ...Source) *Composer

NewComposer composes sources into one picture; a nil source is left out.

type Corners added in v0.3.0

type Corners = gfx.Corners

Corners are a quad's screen corners: top-left, top-right, bottom-left, bottom-right.

func ProjectCorners added in v0.3.0

func ProjectCorners(cam camera.Camera, x0, y0, x1, y1, z float32) Corners

ProjectCorners is the four corners of the world box (x0, y0)-(x1, y1) at height z through cam.

type Depth added in v0.3.0

type Depth = gfx.Depth

Depth is a depth buffer for meshes, reversed (1 nearest).

func NewDepth added in v0.3.0

func NewDepth() *Depth

NewDepth is a depth buffer, fitted to the image it is drawn with.

type Direct added in v0.3.0

type Direct = compose.Direct

Direct is a Source that draws a part of the picture itself, with a shader of its own.

type Distant added in v0.5.0

type Distant = light.Distant

Distant is a light from far off, the same everywhere (light.Distant).

type DrawImageOptions added in v0.3.0

type DrawImageOptions = gfx.DrawImageOptions

DrawImageOptions is how Image.DrawImage draws.

type DrawMeshOptions added in v0.3.0

type DrawMeshOptions = gfx.DrawMeshOptions

DrawMeshOptions is how Image.DrawMesh draws a mesh.

type DrawTrianglesShaderOptions added in v0.3.0

type DrawTrianglesShaderOptions = gfx.DrawTrianglesShaderOptions

DrawTrianglesShaderOptions is what Image.DrawTrianglesShader draws with.

type Fade added in v0.3.0

type Fade = gfx.Fade

Fade is how many pixels each side of a soft quad takes to fade out; 0 leaves a side hard.

type Feed added in v0.3.0

type Feed = feed.Feed

Feed is the world seen through a camera: a Picture drawn through it every frame at its camera's resolution, in layers or with its figures sharp as the camera says, shown at its size.

func NewFeed added in v0.3.0

func NewFeed(cam camera.Camera, picture Picture) *Feed

NewFeed is the world picture draws seen through cam.

type Filter added in v0.3.0

type Filter = gfx.Filter

Filter is how an image drawn scaled is sampled.

type Font added in v0.3.0

type Font = text.Font

Font is a typeface at a size, its glyphs drawn on demand into a sheet of its own; Draw draws a string in it.

func DefaultBoldFont added in v0.3.0

func DefaultBoldFont() *Font

DefaultBoldFont is Go Bold at 14 pixels, DefaultFont's weight for a heading.

func DefaultFont added in v0.3.0

func DefaultFont() *Font

DefaultFont is Go Regular at 14 pixels, which has the Latin letters of every European language.

func DefaultLargeFont added in v0.3.0

func DefaultLargeFont() *Font

DefaultLargeFont is Go Bold at 28 pixels, for a screen's title.

func NewFont added in v0.3.0

func NewFont(ttf []byte, size float64) (*Font, error)

NewFont is the face of the TrueType or OpenType font ttf at size pixels.

type Frame added in v0.3.0

type Frame = compose.Frame

Frame gathers what the sources of a Composer draw for one viewport, in screen pixels, each piece where it lies (At), and where the Direct sources draw themselves.

type GeoM added in v0.3.0

type GeoM = gfx.GeoM

GeoM is an affine transform of the plane, the identity as it comes.

type Glass added in v0.3.0

type Glass = compose.Glass

Glass is a Source drawing on the glass over its picture, after everything laid over it.

type GroundHeights added in v0.3.0

type GroundHeights = compose.GroundHeights

GroundHeights is the ground's heights for the shaders to read.

type GroundShade added in v0.3.0

type GroundShade = compose.GroundShade

GroundShade is the sun on the ground for the shaders to read.

type Illumination added in v0.3.0

type Illumination = light.Illumination

Illumination is the light a thing is drawn in (light.Illumination).

type Image added in v0.3.0

type Image = gfx.Image

Image is a picture on the GPU: a texture, or a rectangle of one, drawn into and read.

func NewImage added in v0.3.0

func NewImage(w, h int) *Image

NewImage is a w by h image, transparent.

type IndexRange added in v0.3.0

type IndexRange = gfx.IndexRange

IndexRange is Count of a mesh's indices from First.

type Indices added in v0.3.0

type Indices = gfx.Indices

Indices are a mesh's triangles, kept on the GPU once drawn.

func NewIndices added in v0.3.0

func NewIndices(indices []uint32) *Indices

NewIndices keeps the triangles of indices.

type InstanceRange added in v0.22.0

type InstanceRange = gfx.InstanceRange

InstanceRange is Count of the instances kept from First.

func JoinSpan added in v0.22.0

func JoinSpan(spans []InstanceRange, r InstanceRange) []InstanceRange

JoinSpan is spans with r after them, one with the last where it follows it at once.

type Instances added in v0.22.0

type Instances = gfx.Instances

Instances are an instanced mesh's instances, kept on the GPU once drawn.

func NewInstances added in v0.22.0

func NewInstances(data []float32) *Instances

NewInstances keeps the instances of data, to be drawn as DrawMeshOptions.Kept.

func PackInstances added in v0.22.0

func PackInstances(floats int, blocks ...map[int][]float32) (*Instances,
	[]map[int]InstanceRange)

PackInstances keeps the instances of every block's groups, floats each, a block after another and a block's groups in the order of their keys, and says where each group lies.

type Labels added in v0.20.0

type Labels = instanced.Labels

Labels is text a Direct source draws on the GPU by points of the world, standing upright on each point for the depth test, and badges with a number in.

type Laid added in v0.3.0

type Laid = feed.Laid

Laid is a Picture drawn in layers from one composition (a Composer).

type Lamp added in v0.5.0

type Lamp = light.Lamp

Lamp is a lamp in the world (light.Lamp).

type Lattice added in v0.5.0

type Lattice = light.Lattice

Lattice is the ground a shade is baked over (light.Lattice).

type Light added in v0.3.0

type Light = compose.Light

Light is a colour of light, red, green and blue; 1 each is white.

type Lights added in v0.5.0

type Lights = light.Lights

Lights are a scene's lights for a frame, which a Composer lights its frames by (Composer.Light; light.Lights).

type Look added in v0.3.0

type Look interface {
	~func(dst *Canvas, size int) | MaterialID | Phases | Loops
}

Look is the ways a look is painted: drawn once into the sheet (a SpriteDrawer), worked out per pixel every frame (a MaterialID), frames along an effect's course (Phases) or frames round and round by the clock (Loops).

type Loops added in v0.3.0

type Loops struct {
	N          int
	Period     time.Duration
	Beat       []Beat
	Draw       func(frame int) SpriteDrawer
	DrawFacing func(angleDeg float64, frame int) SpriteDrawer
}

Loops is a look of N frames shown round and round while an effect is on: in turn, each for Period of game time, or to a Beat. One of Draw and DrawFacing draws a frame.

func LoopedFacing added in v0.3.0

func LoopedFacing(n int, period time.Duration,
	draw func(angleDeg float64, frame int) SpriteDrawer) Loops

LoopedFacing is the look of n frames round and round, each shown period, of a sprite that faces every way: draw draws each frame at each angle.

func Timed added in v0.3.0

func Timed(beat []Beat, draw func(frame int) SpriteDrawer) Loops

Timed is the look going round a beat, frame after frame each for its span, drawn by draw once a frame named: a blink of 150 ms every 3 s is two beats of two frames.

func TimedFacing added in v0.3.0

func TimedFacing(beat []Beat, draw func(angleDeg float64, frame int) SpriteDrawer) Loops

TimedFacing is Timed for a sprite that faces n ways: draw draws each frame at each angle.

func (Loops) Frame added in v0.3.0

func (l Loops) Frame(now time.Duration) int

Frame is the frame shown at the game time now.

type MaterialID added in v0.3.0

type MaterialID = wgsl.MaterialID

MaterialID is a material registered with RegisterMaterials, which the shader works an Overlay out with.

func RegisterMaterials added in v0.3.0

func RegisterMaterials(source []byte, reads []Uniform, entry ...string) []MaterialID

RegisterMaterials adds to the composer's shader the materials of source, WGSL with the uniforms it reads (U.Name), one material for each of entries, the function an Overlay of it is handed to:

fn Entry(p: vec2<f32>, red: f32, fraction: f32, custom: vec4<f32>) -> vec4<f32>

It panics once a shader has been built on the materials.

type Opening added in v0.22.0

type Opening = light.Opening

Opening is where a shelter's wall lets the distant light in (light.Opening).

type Overlay added in v0.3.0

type Overlay = compose.Overlay

Overlay is a quad laid over a sprite for a material to work out in the shader.

type Overlying added in v0.3.0

type Overlying = compose.Overlying

Overlying is a Source whose pieces lie over the figures' ground.

type Pass added in v0.3.0

type Pass = compose.Pass

Pass is which part of the picture a Direct draws in.

type Phases added in v0.3.0

type Phases struct {
	N          int
	Draw       func(frame int) SpriteDrawer
	DrawFacing func(angleDeg float64, frame int) SpriteDrawer
}

Phases is a look of n frames spread along an effect's course, from the first as the effect begins to the last as it runs out, once; a look an atlas takes Under an effect that Lasts. One of Draw and DrawFacing draws a frame, the latter for each way a facing sprite looks.

func Phased added in v0.3.0

func Phased(n int, draw func(frame int) SpriteDrawer) Phases

Phased is the look of n frames along an effect's course, each drawn by draw for its frame.

func PhasedFacing added in v0.3.0

func PhasedFacing(n int, draw func(angleDeg float64, frame int) SpriteDrawer) Phases

PhasedFacing is Phased for a sprite that faces n ways: draw draws each frame at each angle.

func (Phases) Frame added in v0.3.0

func (p Phases) Frame(progress float32) int

Frame is the frame shown at progress, 0 as the effect begins to 1 as it runs out.

type Picture added in v0.3.0

type Picture = feed.Picture

Picture is what is in the world before a camera, drawn through the camera it is handed.

type Renderer

type Renderer interface {
	Draw(screen *Image)
}

Renderer draws once a frame on the whole screen, in screen pixels.

type Reporter added in v0.3.0

type Reporter interface {
	Report(line func(label, value string))
}

Reporter is a plugin's part of the telemetry panel: lines it adds under the standard ones, each a label and a value, asked for after the ticks, not as a frame is drawn.

type Shade added in v0.3.0

type Shade = compose.Shade

Shade is the light a piece is drawn in at its corners, blended across it.

func Even added in v0.3.0

func Even(v float32) Shade

Even is a white Shade of v at every corner; Even(1) draws a sprite as it is.

func Lit added in v0.3.0

func Lit(l Light) Shade

Lit is a Shade of l at every corner.

type Shader added in v0.3.0

type Shader = gfx.Shader

Shader is a WGSL fragment with its uniforms, built on the materials.

func NewMeshShaderWith added in v0.3.0

func NewMeshShaderWith(label string, source []byte, own []Uniform) *Shader

NewMeshShaderWith is a mesh's shader, as NewShaderWith, whose source has a vertex stage of its own: vs_main and fs_main, and fs_prime for a mesh drawn Primed.

func NewShaderWith added in v0.3.0

func NewShaderWith(label string, fragment []byte, own []Uniform) *Shader

NewShaderWith is a shader on the composer's library and every material registered, with fragment's own uniforms and fragment after them. No material may be registered once it has been built.

type ShadowPolicy added in v0.5.0

type ShadowPolicy = light.ShadowPolicy

ShadowPolicy is how a thing casts its live shadow at a distance from the eye (light.ShadowPolicy).

type Shadowing added in v0.5.0

type Shadowing = light.Shadowing

Shadowing is how a thing casts its shadow and which shade it takes (light.Shadowing).

type Sheet added in v0.3.0

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

Sheet is an image of sprites laid out in cells of one size, a frame cut out by its column and row, pixel for pixel: drawn into a square sprite, a frame of another shape is stretched, and an entity's box of the frame's shape draws it true.

func DecodeSheet added in v0.3.0

func DecodeSheet(name string, data []byte, w, h int) Sheet

DecodeSheet is the PNG data as a sheet of frames w by h pixels; name says which file in a panic.

func (Sheet) At added in v0.3.0

func (s Sheet) At(col, row int) SpriteDrawer

At is the drawer of the frame in column col and row row, counted from zero.

type Shelter added in v0.22.0

type Shelter = light.Shelter

Shelter is a roof over part of the world, the distant light getting in by its openings (light.Shelter).

type SolidBackground

type SolidBackground struct{ Color color.RGBA }

SolidBackground fills the screen with one colour.

func (SolidBackground) Draw

func (b SolidBackground) Draw(screen *Image)

type Source added in v0.3.0

type Source = compose.Source

Source is what draws a part of the world by handing its pieces to a Frame.

type SpriteDrawer

type SpriteDrawer = atlas.SpriteDrawer

SpriteDrawer paints one sprite's size x size pixels into dst.

func Arrow

func Arrow(angleDeg float64, width float32, c color.RGBA) SpriteDrawer

func Blob added in v0.18.0

func Blob(draw SpriteDrawer) SpriteDrawer

Blob is a SpriteDrawer filling a disc in the middle of the sprite with draw's mean colour, weighted by its alpha, the disc's radius half the sprite's times the root of the share draw covers: a kind seen from afar.

func Border

func Border(c color.RGBA) SpriteDrawer

Border is a SpriteDrawer outlining the sprite with c, transparent inside.

func Cross

func Cross(c color.RGBA) SpriteDrawer

Cross is a SpriteDrawer filling a cross with c, transparent outside.

func Diamond

func Diamond(c color.RGBA) SpriteDrawer

Diamond is a SpriteDrawer filling a diamond with c, transparent outside.

func Dot

func Dot(radius float32, c color.RGBA) SpriteDrawer

func Hexagon added in v0.3.0

func Hexagon(c color.RGBA) SpriteDrawer

Hexagon is a SpriteDrawer filling a pointy-top hexagon with c, transparent at the corners. Drawn over a cell of width √3·r and height 2·r it is regular.

func Solid

func Solid(c color.RGBA) SpriteDrawer

Solid is a SpriteDrawer filling the whole sprite with c.

type SpriteID

type SpriteID = gfx.SpriteID

SpriteID identifies a sprite in an Atlas.

type Sprited added in v0.3.0

type Sprited = atlas.Sprited

Sprited is whoever is drawn from one slot of the sheet: a kind's handle, or a bare SpriteID, which stands for itself.

type Sprites added in v0.3.0

type Sprites = instanced.Sprites

Sprites is sprites a Direct source draws on the GPU as instances, by Layer or else in the order they came, one call a run sharing an atlas.

type Style added in v0.3.0

type Style interface{ Style() }

Style is how a plugin draws about a kind of entity (an outline, a cone, a route): a value of the plugin's own type, declared on the kind's slot of the world's atlas by a figure's Look. A type is one by its method Style(), a mark never called, confirmed beside the type.

type Styles added in v0.3.0

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

Styles keeps the styles declared on an atlas, one of each type a sprite at most; StyleOf reads them by type.

func (*Styles) Set added in v0.3.0

func (s *Styles) Set(id SpriteID, st Style)

Set declares st for the sprite id, in place of one of its type declared before.

type Surface added in v0.3.0

type Surface interface {
	// Resize gives the surface its size in pixels.
	Resize(w, h int)
	// Draw is the picture for this frame, drawn anew; nil while it has no size.
	Draw() *Image
}

Surface is a picture shown at a size whoever shows it gives it.

type Taking added in v0.3.0

type Taking = compose.Taking

Taking is which shade a drawn thing takes, bits of it.

type Target added in v0.3.0

type Target = compose.Target

Target is where a Direct source draws.

type Umbra added in v0.5.0

type Umbra = light.Umbra

Umbra is where a shadow lies on the ground (light.Umbra).

type Uniform added in v0.3.0

type Uniform = gfx.Uniform

Uniform is one of a shader's uniforms: Size floats, 1 to 4.

func SharedUniforms added in v0.3.0

func SharedUniforms() []Uniform

SharedUniforms are the uniforms every shader built on the materials has: the library's and those the registered materials read, for a shader of one's own to keep its names apart.

type Uniforms added in v0.3.0

type Uniforms = compose.Uniforms

Uniforms is the composer's shader's uniforms this frame, by name, for a Direct source.

func UniformsOf added in v0.3.0

func UniformsOf(m map[string]any) Uniforms

UniformsOf is the uniforms m, by name, each a []float32, or an *Image for a frame's image.

type Vertex added in v0.3.0

type Vertex = gfx.Vertex

Vertex is one corner of a triangle drawn.

type World added in v0.3.0

type World = compose.World

World is where each corner of a piece lies in the world, in the order of its Corners.

func Box added in v0.3.0

func Box(x0, y0, x1, y1 float32) World

Box is the World of the world box (x0, y0)-(x1, y1).

Directories

Path Synopsis
Package gputest readies the GPU for a test that draws.
Package gputest readies the GPU for a test that draws.
internal
atlas
Package atlas is sprites painted on the CPU, each on a Canvas, laid out on one sheet and baked to the GPU, and sprites drawn there into their places on it (Atlas.AddShot).
Package atlas is sprites painted on the CPU, each on a Canvas, laid out on one sheet and baked to the GPU, and sprites drawn there into their places on it (Atlas.AddShot).
compose
Package compose is the world's picture: Sources hand their pieces to a Frame where they lie (At); the Composer draws the opaque ground, then the rest back to front against the depth, the Direct sources in the passes they ask for, then the marks.
Package compose is the world's picture: Sources hand their pieces to a Frame where they lie (At); the Composer draws the opaque ground, then the rest back to front against the depth, the Direct sources in the passes they ask for, then the marks.
feed
Package feed is the world seen through a camera at a size: a Picture drawn whole, in layers from one composition (Laid) or with its figures sharp over its ground.
Package feed is the world seen through a camera at a size: a Picture drawn whole, in layers from one composition (Laid) or with its figures sharp over its ground.
gfx
Package gfx is what draws straight into an image on the GPU: images and their depths, meshes and shaders built on the materials, the 2D fills and the soft blit, and the sprite sheet a frame draws from.
Package gfx is what draws straight into an image on the GPU: images and their depths, meshes and shaders built on the materials, the 2D fills and the soft blit, and the sprite sheet a frame draws from.
gpu
Package gpu draws for render on WebGPU (gogpu/wgpu): textures images live in, programs drawing triangles into them with a fragment written in WGSL, and the frame's commands, gathered and submitted at once.
Package gpu draws for render on WebGPU (gogpu/wgpu): textures images live in, programs drawing triangles into them with a fragment written in WGSL, and the frame's commands, gathered and submitted at once.
instanced
Package instanced is the sprites a Direct source draws on the GPU as instances, by layer or in the order they came.
Package instanced is the sprites a Direct source draws on the GPU as instances, by layer or in the order they came.
light
Package light is how render lights a scene: the distant light and the lamps, the light on what is drawn, and the shadows cast.
Package light is how render lights a scene: the distant light and the lamps, the light on what is drawn, and the shadows cast.
text
Package text is fonts, their glyphs drawn on demand into a sheet of their own, and the fixed debug text.
Package text is fonts, their glyphs drawn on demand into a sheet of their own, and the fixed debug text.
wgsl
Package wgsl is what every shader built on the materials shares: the library's WGSL and uniforms, the materials registered and the frame's images, sealed once a shader is built on them.
Package wgsl is what every shader built on the materials shares: the library's WGSL and uniforms, the materials registered and the frame's images, sealed once a shader is built on them.

Jump to

Keyboard shortcuts

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