Documentation
¶
Index ¶
- Constants
- type ColorPicker
- type Config
- type Dropdown
- type FloatSlider
- type ImageAsset
- type IntSlider
- type SaveRequest
- type Sketch
- func (s *Sketch) CanvasCoords(x, y float64) gaul.Point
- func (s *Sketch) CanvasRect() gaul.Rect
- func (s *Sketch) Clear()
- func (s *Sketch) ColorPicker(name string) color.Color
- func (s *Sketch) ControlPanelScreenRect() image.Rectangle
- func (s *Sketch) Draw(screen *ebiten.Image)
- func (s *Sketch) DrawImage(c *canvas.Context, img image.Image)
- func (s *Sketch) DrawImageAt(c *canvas.Context, x, y float64, img image.Image)
- func (s *Sketch) DrawNamedImage(c *canvas.Context, name string)
- func (s *Sketch) DrawNamedImageAt(c *canvas.Context, x, y float64, name string)
- func (s *Sketch) Dropdown(name string) int
- func (s *Sketch) EnqueueSave(relPath, format string, dpi float64, recordDB bool)
- func (s *Sketch) GetBool(folder, name string) bool
- func (s *Sketch) GetColor(folder, name string) color.Color
- func (s *Sketch) GetDropdownIndex(folder, name string) int
- func (s *Sketch) GetFloat(folder, name string) float64
- func (s *Sketch) GetInt(folder, name string) int
- func (s *Sketch) Height() float64
- func (s *Sketch) Image(name string) image.Image
- func (s *Sketch) Init()
- func (s *Sketch) Int(name string) int
- func (s *Sketch) IsMouseOverControlPanel() bool
- func (s *Sketch) Layout(outsideWidth, outsideHeight int) (int, int)
- func (s *Sketch) MarkDirty()
- func (s *Sketch) PointInSketchArea(x, y float64) bool
- func (s *Sketch) PrimaryPointerPressInSketch() (ok bool, wx, wy float64)
- func (s *Sketch) PrimaryPressInSketch() bool
- func (s *Sketch) RandomHeight() float64
- func (s *Sketch) RandomWidth() float64
- func (s *Sketch) RandomizeSlider(name string)
- func (s *Sketch) RandomizeSliderIn(folder, name string)
- func (s *Sketch) RandomizeSliders()
- func (s *Sketch) RegisterImage(name string, img image.Image)
- func (s *Sketch) SelectedDropdown(name string) string
- func (s *Sketch) SetBool(folder, name string, v bool)
- func (s *Sketch) SetFloat(folder, name string, v float64)
- func (s *Sketch) SetInt(folder, name string, v int)
- func (s *Sketch) SketchCoords(sx, sy float64) gaul.Point
- func (s *Sketch) Slider(name string) float64
- func (s *Sketch) Toggle(name string) bool
- func (s *Sketch) Update() error
- func (s *Sketch) UpdateControls()
- func (s *Sketch) Width() float64
- func (s *Sketch) WindowSize() (w, h int)
- func (s *Sketch) WindowToSketchPixels(wx, wy float64) (sx, sy float64)
- type SketchDrawer
- type SketchUpdater
- type Toggle
- type UI
- func (u *UI) Button(name string)
- func (u *UI) Checkbox(name string, checked bool)
- func (u *UI) ColorPicker(name, initial string)
- func (u *UI) Dropdown(name string, options []string, selectedIndex int)
- func (u *UI) FloatSlider(name string, min, max, val, incr float64)
- func (u *UI) FloatSliderDecimals(name string, min, max, val, incr float64, decimals int)
- func (u *UI) Folder(title string, fn func())
- func (u *UI) IntSlider(name string, min, max, val, incr int)
Constants ¶
const ( DefaultControlWindowWidth = 330 DefaultControlWindowHeight = 500 DefaultControlWindowX = 25 DefaultControlWindowY = 25 DefaultSliderTextWidth = 100 // ControlLabelColumnWidth: name column for sliders, colors, dropdowns (~20 chars at 6px/glyph + debugui padding). ControlLabelColumnWidth = 136 DefaultCheckboxColumns = 1 DefaultButtonColumns = 1 )
const ( DefaultTitle = "Sketch" DefaultPrefix = "sketch" MmPerPx = 0.26458333 DefaultDPI = 96.0 // Performance tuning constants DefaultPreviewDPI = 48.0 // Lower DPI for preview mode SaveChannelBuffer = 10 // Buffer size for async save requests // Default ebiten window size is sketch dimensions, clamped to at least this. MinWindowWidth = 640 MinWindowHeight = 480 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColorPicker ¶ added in v0.2.0
type ColorPicker struct {
Folder string
Name string
Color string
DidJustChange bool
// contains filtered or unexported fields
}
func NewColorPicker ¶ added in v0.2.0
func NewColorPicker(name, color string) ColorPicker
func (*ColorPicker) GetColor ¶ added in v0.2.0
func (c *ColorPicker) GetColor() color.Color
func (*ColorPicker) GetHex ¶ added in v0.2.0
func (c *ColorPicker) GetHex() string
func (*ColorPicker) UpdateState ¶ added in v0.2.0
func (c *ColorPicker) UpdateState()
type Config ¶ added in v0.2.0
type Config struct {
Title string
Prefix string
SketchWidth float64
SketchHeight float64
ControlWidth int
ControlHeight int
ControlBackgroundColor string
ControlOutlineColor string
// SketchBackgroundColor is currently unused at runtime (letterbox uses Builtins dark/light theme).
SketchBackgroundColor string
SketchOutlineColor string
DisableClearBetweenFrames bool
// DisableFastStroke leaves canvas path settling enabled (slower, more precise strokes).
// When false (default), Init sets canvas.FastStroke for generative-art performance.
DisableFastStroke bool
ShowFPS bool
RasterDPI float64
PreviewMode bool
RandomSeed int64
// DefaultBackground is the canvas clear color before Drawer runs; nil means black at Init.
DefaultBackground color.Color
// DefaultForeground is the initial stroke (and default pen) color for the canvas context; nil means white at Init.
DefaultForeground color.Color
// DefaultStrokeWidth is the initial stroke width in millimeters; 0 means 0.5 at Init.
DefaultStrokeWidth float64
// Images lists files to load at Init; use Image/DrawNamedImage in Drawer by Name.
Images []ImageAsset
}
Config holds sketch options set from code (no JSON).
type Dropdown ¶ added in v0.2.0
type Dropdown struct {
Folder string
Name string
Options []string
Index int
DidJustChange bool
// contains filtered or unexported fields
}
Dropdown is a string option list control.
func (*Dropdown) UpdateState ¶ added in v0.2.0
func (d *Dropdown) UpdateState()
type FloatSlider ¶ added in v0.2.0
type FloatSlider struct {
Folder string
Name string
MinVal float64
MaxVal float64
Val float64
Incr float64
DidJustChange bool
// TextDecimals is fraction digits for the value text when >= 0; when < 0, use digits derived from Incr.
TextDecimals int
// contains filtered or unexported fields
}
FloatSlider is a continuous control backed by debugui SliderF and a text field for the value.
func NewFloatSlider ¶ added in v0.2.0
func NewFloatSlider(name string, min, max, val, incr float64) FloatSlider
func NewFloatSliderWithDecimals ¶ added in v0.2.0
func NewFloatSliderWithDecimals(name string, min, max, val, incr float64, textDecimals int) FloatSlider
NewFloatSliderWithDecimals is like NewFloatSlider but sets TextDecimals for the value text field. Pass textDecimals < 0 to derive fraction digits from incr (same as SliderF precision).
func (*FloatSlider) CalcDigits ¶ added in v0.2.0
func (s *FloatSlider) CalcDigits()
func (*FloatSlider) GetPercentage ¶ added in v0.2.0
func (s *FloatSlider) GetPercentage() float64
func (*FloatSlider) Randomize ¶ added in v0.2.0
func (s *FloatSlider) Randomize()
func (*FloatSlider) StringVal ¶ added in v0.2.0
func (s *FloatSlider) StringVal() string
func (*FloatSlider) UpdateState ¶ added in v0.2.0
func (s *FloatSlider) UpdateState()
type ImageAsset ¶ added in v0.3.0
ImageAsset names an image file to load at Init. Path is relative to the sketch working directory unless absolute. Name is the key used with Image, DrawNamedImage, and DrawNamedImageAt.
type IntSlider ¶ added in v0.2.0
type IntSlider struct {
Folder string
Name string
MinVal int
MaxVal int
Val int
Incr int
DidJustChange bool
// contains filtered or unexported fields
}
IntSlider is a discrete stepped control backed by debugui Slider and a text field for the value.
func NewIntSlider ¶ added in v0.2.0
func (*IntSlider) UpdateState ¶ added in v0.2.0
func (s *IntSlider) UpdateState()
type SaveRequest ¶ added in v0.2.0
type SaveRequest struct {
RelPath string // e.g. saves/png/foo.png
Format string // "png" or "svg"
DPI float64
RecordDB bool
}
SaveRequest is an async save operation (relative path under workDir).
type Sketch ¶
type Sketch struct {
Title string
Prefix string
SketchWidth float64
SketchHeight float64
ControlWidth int
ControlHeight int
ControlBackgroundColor string
ControlOutlineColor string
// SketchBackgroundColor is unused for window filling; letterbox margins follow the Builtins UI theme.
// Kept for API compatibility; may be used again if margins become configurable.
SketchBackgroundColor string
SketchOutlineColor string
// DefaultBackground is the canvas clear color before each draw (image/color, default black).
DefaultBackground color.Color
// DefaultForeground is the initial stroke color for the canvas context before Drawer (default white).
DefaultForeground color.Color
// DefaultStrokeWidth is the initial stroke width in millimeters (default 0.5).
DefaultStrokeWidth float64
DisableClearBetweenFrames bool
DisableFastStroke bool
ShowFPS bool
RasterDPI float64
PreviewMode bool
RandomSeed int64
FloatSliders []FloatSlider
IntSliders []IntSlider
Toggles []Toggle
ColorPickers []ColorPicker
Dropdowns []Dropdown
// BuildUI registers controls; set before Init().
BuildUI func(s *Sketch, ui *UI)
Updater SketchUpdater
Drawer SketchDrawer
DidControlsChange bool
DidSlidersChange bool
DidTogglesChange bool
DidColorPickersChange bool
DidDropdownsChange bool
Rand gaul.Rng
Tick int64
SketchCanvas *canvas.Canvas
// contains filtered or unexported fields
}
func New ¶ added in v0.2.0
New returns an uninitialized sketch. Set BuildUI, Updater, and Drawer, then call Init().
func (*Sketch) CanvasRect ¶
func (*Sketch) ColorPicker ¶ added in v0.2.0
ColorPicker returns root-folder color.
func (*Sketch) ControlPanelScreenRect ¶ added in v0.2.0
ControlPanelScreenRect returns the screen-space bounds of the control panel window (must match [Sketch.controlWindow]).
func (*Sketch) DrawImage ¶ added in v0.3.0
DrawImage draws img at (x, y) in canvas coordinates (millimeters), mapping one image pixel to one sketch pixel using the sketch's pixel-to-mm scale.
func (*Sketch) DrawImageAt ¶ added in v0.3.0
DrawImageAt is like DrawImage but offsets the top-left of img to (x, y).
func (*Sketch) DrawNamedImage ¶ added in v0.3.0
DrawNamedImage draws a Config ImageAsset (or RegisterImage entry) at the origin.
func (*Sketch) DrawNamedImageAt ¶ added in v0.3.0
DrawNamedImageAt draws a named asset at (x, y).
func (*Sketch) EnqueueSave ¶ added in v0.2.0
func (*Sketch) GetDropdownIndex ¶ added in v0.2.0
GetDropdownIndex returns selected index for a dropdown.
func (*Sketch) GetFloat ¶ added in v0.2.0
GetFloat returns a float slider value in folder (use "" for root).
func (*Sketch) GetInt ¶ added in v0.2.0
GetInt returns an int slider value in folder (use "" for root).
func (*Sketch) Image ¶ added in v0.3.0
Image returns a configured or runtime-registered image by name.
func (*Sketch) Int ¶ added in v0.2.0
Int returns an int slider in the root folder. Prefer GetInt("", name).
func (*Sketch) IsMouseOverControlPanel ¶ added in v0.2.0
IsMouseOverControlPanel reports whether the cursor is over the control panel's default screen rectangle or any debug UI hover surface (dialogs, dropdowns, a dragged panel).
func (*Sketch) MarkDirty ¶ added in v0.2.0
func (s *Sketch) MarkDirty()
MarkDirty schedules a full sketch raster pass on the next Draw. Sketchy also sets dirty when a primary pointer press lands in the sketch (same rules as Sketch.PrimaryPointerPressInSketch). Call MarkDirty when the picture changes without such a press (keyboard, timers, other mouse buttons, or state updates that bypass control-driven invalidation).
func (*Sketch) PointInSketchArea ¶
func (*Sketch) PrimaryPointerPressInSketch ¶ added in v0.2.0
PrimaryPointerPressInSketch reports whether the left mouse button or a newly pressed touch just went down over the sketch (not on the control panel's default rectangle). It returns the window coordinates of that press. For the mouse, Sketch uses an edge detector ([Sketch.refreshPrimaryMouseEdge]) instead of inpututil.IsMouseButtonJustPressed, because the latter only holds when the press timestamp matches the current UI tick, which can fail depending on platform and frame timing. For touch, use the returned coordinates — not ebiten.CursorPosition, which is unset on many mobile builds. If this is true for the current frame, Sketch.Update marks the sketch dirty after Sketch.Updater returns, so the next Sketch.Draw re-rasterizes without Sketch.MarkDirty.
func (*Sketch) PrimaryPressInSketch ¶ added in v0.2.0
PrimaryPressInSketch is like Sketch.PrimaryPointerPressInSketch but only reports whether a qualifying press occurred.
func (*Sketch) RandomHeight ¶
func (*Sketch) RandomWidth ¶
func (*Sketch) RandomizeSlider ¶
func (*Sketch) RandomizeSliderIn ¶ added in v0.2.0
func (*Sketch) RandomizeSliders ¶
func (s *Sketch) RandomizeSliders()
func (*Sketch) RegisterImage ¶ added in v0.3.0
RegisterImage adds or replaces a named image after Init (e.g. for images created in code).
func (*Sketch) SelectedDropdown ¶ added in v0.2.0
SelectedDropdown returns the selected string for a root-folder dropdown.
func (*Sketch) SetInt ¶ added in v0.2.0
SetInt sets an int slider value (clamped to min/max on next UI sync; immediate assign here).
func (*Sketch) SketchCoords ¶
SketchCoords maps sketch bitmap pixel coordinates (origin top-left of the raster) to canvas mm.
func (*Sketch) Slider ¶
Slider returns a float slider in the root folder. Prefer GetFloat("", name).
func (*Sketch) UpdateControls ¶
func (s *Sketch) UpdateControls()
func (*Sketch) WindowSize ¶ added in v0.2.0
WindowSize returns outer window dimensions for ebiten: the sketch size in pixels, with width and height each at least MinWindowWidth and MinWindowHeight.
func (*Sketch) WindowToSketchPixels ¶ added in v0.2.0
WindowToSketchPixels maps game-surface coordinates into the sketch bitmap drawn at Translate(viewPad - scroll), i.e. the inverse of the Draw path for s.offscreen.
type SketchDrawer ¶
type SketchUpdater ¶
type SketchUpdater func(s *Sketch)
type Toggle ¶
type Toggle struct {
Folder string
Name string
Pos gaul.Point
Width float64
Height float64
Checked bool
IsButton bool
DidJustChange bool
// contains filtered or unexported fields
}
func (*Toggle) UpdateState ¶
func (t *Toggle) UpdateState()
type UI ¶ added in v0.2.0
type UI struct {
// contains filtered or unexported fields
}
UI registers controls inside BuildUI. Call Folder() to group controls under a collapsible header.
func (*UI) Button ¶ added in v0.2.0
Button adds a momentary button (exposes Checked toggling on click, same as before).
func (*UI) ColorPicker ¶ added in v0.2.0
ColorPicker adds a color control in the current folder (initial color as hex or HTML color name).
func (*UI) Dropdown ¶ added in v0.2.0
Dropdown adds a dropdown in the current folder. options must be non-empty.
func (*UI) FloatSlider ¶ added in v0.2.0
FloatSlider adds a float slider and value text field in the current folder.
func (*UI) FloatSliderDecimals ¶ added in v0.2.0
FloatSliderDecimals is like FloatSlider but sets the number of fraction digits shown in the value text when decimals >= 0. Use decimals < 0 to derive fraction digits from incr (same precision as the slider thumb).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
sketchy
command
|
|
|
sketchy/template
command
|
|
|
examples
|
|
|
10print
command
|
|
|
bezier
command
|
|
|
fractal
command
|
|
|
lissajous
command
|
|
|
noise
command
|
|
|
photo_stripes
command
|
|
|
scale_rotate
command
|
|
|
simple
command
|
|
|
voronoi
command
|
|
|
internal
|
|
|
visual_tests
|
|
|
color_gradient
command
|
|
|
curve_lerp
command
|
|
|
kdtree_mouse
command
|
|
|
nearest_neighbor
command
|
|
|
perpendicular
command
|
|
|
quadtree_mouse
command
|
|
|
random_points
command
|
|
|
vector_normals
command
|




