Documentation ¶
Index ¶
- func FontFilenameToName(filename string) string
- func RGBA(c render.Color) string
- type Canvas
- type Engine
- func (e *Engine) AddEventListeners()
- func (e *Engine) Clear(color render.Color)
- func (e *Engine) ComputeTextRect(text render.Text) (render.Rect, error)
- func (e *Engine) Copy(t render.Texturer, src, dist render.Rect)
- func (e *Engine) Delay(delay uint32)
- func (e *Engine) DrawBox(color render.Color, rect render.Rect)
- func (e *Engine) DrawLine(color render.Color, a, b render.Point)
- func (e *Engine) DrawPoint(color render.Color, point render.Point)
- func (e *Engine) DrawRect(color render.Color, rect render.Rect)
- func (e *Engine) DrawText(text render.Text, point render.Point) error
- func (e *Engine) FreeTextures() int
- func (e *Engine) GetTicks() uint32
- func (e *Engine) LoadTexture(name string) (render.Texturer, error)
- func (e *Engine) Loop() error
- func (e *Engine) Poll() (*event.State, error)
- func (e *Engine) PollEvent() *Event
- func (e *Engine) Present() error
- func (e *Engine) SetTitle(title string)
- func (e *Engine) Setup() error
- func (e *Engine) StoreTexture(name string, img image.Image) (render.Texturer, error)
- func (e *Engine) Teardown()
- func (e *Engine) WindowSize() (w, h int)
- type Event
- type EventClass
- type Texture
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FontFilenameToName ¶
FontFilenameToName converts a FontFilename to its CSS font name.
The CSS font name is set to the base of the filename, without the .ttf file extension. For example, "fonts/DejaVuSans.ttf" uses the CSS font family name "DejaVuSans" and that's what this function returns.
Fonts must be defined in the index.html style sheet when serving the wasm build of Doodle.
If filename is "", returns "serif" as a sensible default.
Types ¶
type Canvas ¶
Canvas represents an HTML5 Canvas object.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine implements a rendering engine targeting an HTML canvas for WebAssembly targets.
func (*Engine) AddEventListeners ¶
func (e *Engine) AddEventListeners()
AddEventListeners sets up bindings to collect events from the browser.
func (*Engine) ComputeTextRect ¶
ComputeTextRect computes and returns a Rect for how large the text would appear if rendered.
func (*Engine) FreeTextures ¶
FreeTextures flushes the texture cache.
func (*Engine) LoadTexture ¶
LoadTexture recalls a cached texture image.
func (*Engine) StoreTexture ¶
StoreTexture caches a texture from a bitmap.
func (*Engine) WindowSize ¶
WindowSize returns the size of the canvas window.
type Event ¶
type Event struct { Name string // mouseup, keydown, etc. Class EventClass // Mouse events. X int Y int LeftClick bool RightClick bool // Key events. KeyName string State bool Repeat bool }
Event object queues up asynchronous JavaScript events to be processed linearly.
type EventClass ¶
type EventClass int
EventClass to categorize JavaScript events.
const ( MouseEvent EventClass = iota ClickEvent KeyEvent ResizeEvent WindowEvent )
EventClass values.