tools

package
v0.0.0-...-5559143 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package tools exposes shader editing, parameter tuning and image previews.

Index

Constants

View Source
const SystemPrompt = `` /* 3438-byte string literal not displayed */

Variables

This section is empty.

Functions

func Register

func Register(s *State, vision bool, servers ...*wgslls.Service) (*ds4.ToolRegistry, error)

func Registry

func Registry(servers ...*wgslls.Service) map[string]Handler

func Schemas

func Schemas() []ds4.ToolSchema

Types

type Handler

type Handler func(context.Context, *State, json.RawMessage) (ds4.ToolResult, error)

type Performance

type Performance struct {
	RenderMS    float64 `json:"render_ms"`
	EncodeMS    float64 `json:"encode_ms"`
	UploadBytes int     `json:"upload_bytes"`
	SampledAt   int64   `json:"sampled_at"`
	Kitty       bool    `json:"kitty"`
	// Transport is what the last Kitty frame actually used: png, rgba, or shm.
	// With shm, UploadBytes is only the reference written to the terminal.
	Transport string `json:"transport,omitempty"`
}

Performance records wall times, not GPU timestamps or terminal display latency.

type Renderer

type Renderer interface {
	Compile(shader.Source) error
	Render(shader.Source, [16]float32, float32, float32, uint32, int, int) (*image.NRGBA, error)
}

type Snapshot

type Snapshot struct {
	Source      shader.Source      `json:"source"`
	Values      [16]float32        `json:"-"`
	Named       map[string]float32 `json:"values"`
	Time        float32            `json:"time"`
	Dt          float32            `json:"dt"`
	Frame       uint32             `json:"frame"`
	FPS         float64            `json:"fps"`
	Width       int                `json:"width"`
	Height      int                `json:"height"`
	Revision    uint64             `json:"-"`
	Performance Performance        `json:"performance"`
}

type State

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

func NewState

func NewState(src shader.Source, r Renderer) (*State, error)

func (*State) Checkpoint

func (s *State) Checkpoint() error

Checkpoint records current controls as well as source, for gallery browsing and clean shutdown. Shader replacements themselves save synchronously.

func (*State) Clock

func (s *State) Clock(t, dt float32, frame uint32, fps float64)

func (*State) Load

func (s *State) Load(path string) error

func (*State) Nudge

func (s *State) Nudge(index, steps int) error

func (*State) Randomize

func (s *State) Randomize()

func (*State) RecordPerformance

func (s *State) RecordPerformance(p Performance)

func (*State) Render

func (s *State) Render(snap Snapshot, w, h int) (*image.NRGBA, error)

func (*State) Replace

func (s *State) Replace(src shader.Source, values map[string]float32, revision uint64) error

Replace compiles before committing. A failed compile never changes live state. Concurrent edits supersede the pending replacement instead of being lost. Identical source and effective values skip compilation, history and revision changes.

func (*State) Save

func (s *State) Save(path string) error

func (*State) Set

func (s *State) Set(name string, value float32) (float32, error)

func (*State) SetArchive

func (s *State) SetArchive(save func(params.Preset) error)

SetArchive enables durable history for subsequent successful replacements. The callback must not call back into State.

func (*State) Snapshot

func (s *State) Snapshot() Snapshot

func (*State) Viewport

func (s *State) Viewport(w, h int)

Viewport records the live render size so vision sees the same aspect ratio.

Jump to

Keyboard shortcuts

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