Documentation
¶
Overview ¶
Package playground is the View of the go-ndarray playground: a go-widgets canvas application compiled to WebAssembly. It builds toolkit widgets, lays them out in boxes and binds each one to the ViewModel (package vm) — it draws nothing by hand and holds no state of its own beyond layout and pointer capture. cmd/playground-wasm is the browser shell around it.
Index ¶
- func SetupText(scale float64)
- func Theme(dark bool) *toolkit.Theme
- type Debug
- type State
- func (s *State) Dark() bool
- func (s *State) Debug() Debug
- func (s *State) Dirty() bool
- func (s *State) Draw(buf []byte)
- func (s *State) HandleChar(ch string) bool
- func (s *State) HandleClick(x, y int) bool
- func (s *State) HandleKeyDown(code string) bool
- func (s *State) HandleMove(x, y int) bool
- func (s *State) HandleRelease(x, y int) bool
- func (s *State) HandleScroll(x, y, dx, dy int) bool
- func (s *State) MinHeight(w int) int
- func (s *State) Rects() map[string]toolkit.Rect
- func (s *State) Resize(w, h int)
- func (s *State) SetTheme(dark bool)
- func (s *State) Size() (int, int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Debug ¶
type Debug struct {
Steps []string `json:"steps"`
Selected int `json:"selected"`
Op string `json:"op"`
Input string `json:"input"`
Args string `json:"args"`
Error string `json:"error"`
Title string `json:"title"`
Shape string `json:"shape"`
Memory string `json:"memory"`
Timing string `json:"timing"`
Rows int `json:"rows"`
Cols int `json:"cols"`
Dark bool `json:"dark"`
Status string `json:"status"`
Code string `json:"code"`
Ops []string `json:"ops"`
Presets []string `json:"presets"`
// The code panel's language (0 Go, 1 Ruby, 2 NumPy) and the Ruby run: its
// status line, download fraction and output.
Lang int `json:"lang"`
RubyStatus string `json:"rubyStatus"`
RubyProgress float64 `json:"rubyProgress"`
RubyOutput string `json:"rubyOutput"`
CanRunRuby bool `json:"canRunRuby"`
// The selected step's result as go-ndarray computed it: its shape and its
// values in row-major order, for comparing with what Ruby printed.
ResultShape []int `json:"resultShape"`
ResultValues []float64 `json:"resultValues"`
// Goroutines and MaxProcs let a proof watch go-ndarray's helper pool
// under GOOS=js: GOMAXPROCS is 1 there, so no helper should ever start.
Goroutines int `json:"goroutines"`
MaxProcs int `json:"maxProcs"`
}
Debug is a snapshot of what the scene shows, for the browser proofs: they assert on it after driving the page with real mouse and keyboard events.
type State ¶
State is the View: the widgets, their layout, the ViewModel they are bound to, and the pointer capture.
func (*State) Draw ¶
Draw paints the whole scene into buf (w×h RGBA). Open popovers are drawn last so they float above the widgets under them.
func (*State) HandleChar ¶
HandleChar types a printable character into the focused widget.
func (*State) HandleClick ¶
HandleClick routes a primary-button press at surface (x, y).
func (*State) HandleKeyDown ¶
HandleKeyDown delivers a named key (Enter, Backspace, arrows, Tab, Escape) to the focused widget; Escape also closes any open popover.
func (*State) HandleMove ¶
HandleMove routes a pointer move: a drag of the captured widget (a scrollbar thumb) while the button is held, else a hover.
func (*State) HandleRelease ¶
HandleRelease ends a drag.
func (*State) HandleScroll ¶
HandleScroll routes a wheel of dy rows (dx sideways) at (x, y): to an open popover's list first, else to the widget under the pointer.
func (*State) MinHeight ¶
MinHeight is the least height, in device pixels, the scene needs at width w. Side by side it is 0: every widget fits whatever the window gives. Stacked, the form, the summary and the code panel have fixed heights and the table takes what is left, so a short window left it nothing: 0 px on a 390×844 phone. The host makes the canvas at least this tall and lets the page scroll.
It is measured, not computed: in the stacked layout the table is the only part that grows, so the layout is laid out once at a tall height and the table's share is replaced by minTableH. Formula and layout cannot drift.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
playground-wasm
command
|
|
|
Package engine is the model of the go-ndarray playground: a pipeline of steps, each one go-ndarray operation applied to earlier results, with the Go, Ruby and NumPy spellings of every step and what each result looks like in memory.
|
Package engine is the model of the go-ndarray playground: a pipeline of steps, each one go-ndarray operation applied to earlier results, with the Go, Ruby and NumPy spellings of every step and what each result looks like in memory. |
|
Package vm is the ViewModel of the go-ndarray playground.
|
Package vm is the ViewModel of the go-ndarray playground. |