canvas

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2021 License: ISC Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(addr string, run func(*Context), size image.Rectangle) error

Types

type AuxClickEvent

type AuxClickEvent struct{ MouseEvent }

The AuxClickEvent is fired when a non-primary pointing device button (any mouse button other than the primary—usually leftmost—button) has been pressed and released both within the same element.

func (AuxClickEvent) AltKey

func (m AuxClickEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (AuxClickEvent) CtrlKey

func (m AuxClickEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (AuxClickEvent) MetaKey

func (m AuxClickEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (AuxClickEvent) ShiftKey

func (m AuxClickEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type ClickEvent

type ClickEvent struct{ MouseEvent }

The ClickEvent is fired when a pointing device button (such as a mouse's primary mouse button) is both pressed and released while the pointer is located inside the canvas.

func (ClickEvent) AltKey

func (m ClickEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (ClickEvent) CtrlKey

func (m ClickEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (ClickEvent) MetaKey

func (m ClickEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (ClickEvent) ShiftKey

func (m ClickEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type ClipboardChangeEvent added in v0.3.0

type ClipboardChangeEvent struct{ ClipboardEvent }

type ClipboardEvent added in v0.3.0

type ClipboardEvent struct {
	Data string
}

type CloseEvent

type CloseEvent struct{}

The CloseEvent is fired when the WebSocket connection to the client is closed. It is not necessary to enable the CloseEvent with the EnableEvents option, it is always enabled. Animation loops should handle the CloseEvent to quit the loop.

type Context

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

func (*Context) CanvasHeight

func (ctx *Context) CanvasHeight() int

func (*Context) CanvasWidth

func (ctx *Context) CanvasWidth() int

func (*Context) ClipboardWriteText added in v0.3.0

func (ctx *Context) ClipboardWriteText(text string)

func (*Context) Events

func (ctx *Context) Events() <-chan Event

func (*Context) Flush

func (ctx *Context) Flush()

func (*Context) UpdateDisplay

func (ctx *Context) UpdateDisplay(fb *risc.Framebuffer, r image.Rectangle)

type DblClickEvent

type DblClickEvent struct{ MouseEvent }

The DblClickEvent is fired when a pointing device button (such as a mouse's primary button) is double-clicked; that is, when it's rapidly clicked twice on the canvas within a very short span of time.

DblClickEvent fires after two ClickEvents (and by extension, after two pairs of MouseDownEvents and MouseUpEvents).

func (DblClickEvent) AltKey

func (m DblClickEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (DblClickEvent) CtrlKey

func (m DblClickEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (DblClickEvent) MetaKey

func (m DblClickEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (DblClickEvent) ShiftKey

func (m DblClickEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type DeltaMode

type DeltaMode byte

DeltaMode represents the unit of the delta values' scroll amount.

const (
	// DeltaPixel means the delta values are specified in pixels.
	DeltaPixel DeltaMode = iota
	// DeltaLine means the delta values are specified in lines.
	DeltaLine
	// DeltaPage means the delta values are specified in pages.
	DeltaPage
)

type Event

type Event interface {
	// contains filtered or unexported methods
}

Event is an interface implemented by all event subtypes. Events can be received from the channel returned by Context.Events. Use a type switch to distinguish between different event types.

type KeyDownEvent

type KeyDownEvent struct{ KeyboardEvent }

The KeyDownEvent is fired when a key is pressed.

func (KeyDownEvent) AltKey

func (m KeyDownEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (KeyDownEvent) CtrlKey

func (m KeyDownEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (KeyDownEvent) MetaKey

func (m KeyDownEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (KeyDownEvent) ShiftKey

func (m KeyDownEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type KeyUpEvent

type KeyUpEvent struct{ KeyboardEvent }

The KeyUpEvent is fired when a key is released.

func (KeyUpEvent) AltKey

func (m KeyUpEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (KeyUpEvent) CtrlKey

func (m KeyUpEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (KeyUpEvent) MetaKey

func (m KeyUpEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (KeyUpEvent) ShiftKey

func (m KeyUpEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type KeyboardEvent

type KeyboardEvent struct {
	// Key represents the key value of the key represented by the event.
	Key string
	// contains filtered or unexported fields
}

KeyboardEvent objects describe a user interaction with the keyboard; each event describes a single interaction between the user and a key (or combination of a key with modifier keys) on the keyboard.

func (KeyboardEvent) AltKey

func (m KeyboardEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (KeyboardEvent) CtrlKey

func (m KeyboardEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (KeyboardEvent) MetaKey

func (m KeyboardEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (KeyboardEvent) ShiftKey

func (m KeyboardEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type MouseButtons

type MouseButtons int

MouseButtons is a number representing one or more buttons. For more than one button pressed simultaneously, the values are combined (e.g., 3 is ButtonPrimary + ButtonSecondary).

const (
	// ButtonPrimary is the primary button (usually the left button).
	ButtonPrimary MouseButtons = 1 << iota
	// ButtonSecondary is the secondary button (usually the right button).
	ButtonSecondary
	// ButtonAuxiliary is the auxiliary button (usually the mouse wheel button
	// or middle button)
	ButtonAuxiliary
	// Button4th is the 4th button (typically the "Browser Back" button).
	Button4th
	// Button5th is the 5th button (typically the "Browser Forward" button).
	Button5th
	// ButtonNone stands for no button or un-initialized.
	ButtonNone MouseButtons = 0
)

type MouseDownEvent

type MouseDownEvent struct{ MouseEvent }

The MouseDownEvent is fired when a pointing device button is pressed.

Note: This differs from the ClickEvent in that click is fired after a full click action occurs; that is, the mouse button is pressed and released while the pointer remains inside the canvas. MouseDownEvent is fired the moment the button is initially pressed.

func (MouseDownEvent) AltKey

func (m MouseDownEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (MouseDownEvent) CtrlKey

func (m MouseDownEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (MouseDownEvent) MetaKey

func (m MouseDownEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (MouseDownEvent) ShiftKey

func (m MouseDownEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type MouseEvent

type MouseEvent struct {
	// Buttons encodes the buttons being depressed (if any) when the mouse
	// event was fired.
	Buttons MouseButtons
	// The X coordinate of the mouse pointer.
	X int
	// The Y coordinate of the mouse pointer.
	Y int
	// contains filtered or unexported fields
}

MouseEvent represents events that occur due to the user interacting with a pointing device (such as a mouse).

func (MouseEvent) AltKey

func (m MouseEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (MouseEvent) CtrlKey

func (m MouseEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (MouseEvent) MetaKey

func (m MouseEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (MouseEvent) ShiftKey

func (m MouseEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type MouseMoveEvent

type MouseMoveEvent struct{ MouseEvent }

The MouseMoveEvent is fired when a pointing device (usually a mouse) is moved.

func (MouseMoveEvent) AltKey

func (m MouseMoveEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (MouseMoveEvent) CtrlKey

func (m MouseMoveEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (MouseMoveEvent) MetaKey

func (m MouseMoveEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (MouseMoveEvent) ShiftKey

func (m MouseMoveEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type MouseUpEvent

type MouseUpEvent struct{ MouseEvent }

The MouseUpEvent is fired when a button on a pointing device (such as a mouse or trackpad) is released. It is the counterpoint to the MouseDownEvent.

func (MouseUpEvent) AltKey

func (m MouseUpEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (MouseUpEvent) CtrlKey

func (m MouseUpEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (MouseUpEvent) MetaKey

func (m MouseUpEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (MouseUpEvent) ShiftKey

func (m MouseUpEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type Touch

type Touch struct {
	// Identifier is a unique identifier for this Touch object. A given touch
	// point (say, by a finger) will have the same identifier for the duration
	// of its movement around the surface. This lets you ensure that you're
	// tracking the same touch all the time.
	Identifier uint32
	// The X coordinate of the touch point.
	X int
	// The Y coordinate of the touch point.
	Y int
}

Touch represents a single contact point on a touch-sensitive device. The contact point is commonly a finger or stylus and the device may be a touchscreen or trackpad.

type TouchCancelEvent

type TouchCancelEvent struct{ TouchEvent }

The TouchCancelEvent is fired when one or more touch points have been disrupted in an implementation-specific manner (for example, too many touch points are created).

func (TouchCancelEvent) AltKey

func (m TouchCancelEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (TouchCancelEvent) CtrlKey

func (m TouchCancelEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (TouchCancelEvent) MetaKey

func (m TouchCancelEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (TouchCancelEvent) ShiftKey

func (m TouchCancelEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type TouchEndEvent

type TouchEndEvent struct{ TouchEvent }

The TouchEndEvent is fired when one or more touch points are removed from the touch surface.

func (TouchEndEvent) AltKey

func (m TouchEndEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (TouchEndEvent) CtrlKey

func (m TouchEndEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (TouchEndEvent) MetaKey

func (m TouchEndEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (TouchEndEvent) ShiftKey

func (m TouchEndEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type TouchEvent

type TouchEvent struct {
	// Touches is a TouchList of all the Touch objects representing all current
	// points of contact with the surface, regardless of target or changed
	// status.
	Touches TouchList
	// ChangedTouches is a TouchList of all the Touch objects representing
	// individual points of contact whose states changed between the previous
	// touch event and this one.
	ChangedTouches TouchList
	// TargetTouches is a TouchList of all the Touch objects that are both
	// currently in contact with the touch surface and were also started on the
	// same element that is the target of the event.
	TargetTouches TouchList
	// contains filtered or unexported fields
}

The TouchEvent is fired when the state of contacts with a touch-sensitive surface changes. This surface can be a touch screen or trackpad, for example. The event can describe one or more points of contact with the screen and includes support for detecting movement, addition and removal of contact points, and so forth.

Touches are represented by the Touch object; each touch is described by a position, size and shape, amount of pressure, and target element. Lists of touches are represented by TouchList objects.

func (TouchEvent) AltKey

func (m TouchEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (TouchEvent) CtrlKey

func (m TouchEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (TouchEvent) MetaKey

func (m TouchEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (TouchEvent) ShiftKey

func (m TouchEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type TouchList

type TouchList []Touch

TouchList represents a list of contact points on a touch surface. For example, if the user has three fingers on the touch surface (such as a screen or trackpad), the corresponding TouchList object would have one Touch object for each finger, for a total of three entries.

type TouchMoveEvent

type TouchMoveEvent struct{ TouchEvent }

The TouchMoveEvent is fired when one or more touch points are moved along the touch surface.

func (TouchMoveEvent) AltKey

func (m TouchMoveEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (TouchMoveEvent) CtrlKey

func (m TouchMoveEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (TouchMoveEvent) MetaKey

func (m TouchMoveEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (TouchMoveEvent) ShiftKey

func (m TouchMoveEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type TouchStartEvent

type TouchStartEvent struct{ TouchEvent }

The TouchStartEvent is fired when one or more touch points are placed on the touch surface.

func (TouchStartEvent) AltKey

func (m TouchStartEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (TouchStartEvent) CtrlKey

func (m TouchStartEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (TouchStartEvent) MetaKey

func (m TouchStartEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (TouchStartEvent) ShiftKey

func (m TouchStartEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

type WheelEvent

type WheelEvent struct {
	MouseEvent
	// DeltaX represents the horizontal scroll amount.
	DeltaX float64
	// DeltaY represents the vertical scroll amount.
	DeltaY float64
	// DeltaZ represents the scroll amount for the z-axis.
	DeltaZ float64
	// DeltaMode represents the unit of the delta values' scroll amount.
	DeltaMode DeltaMode
}

The WheelEvent is fired due to the user moving a mouse wheel or similar input device.

func (WheelEvent) AltKey

func (m WheelEvent) AltKey() bool

AltKey returns true if the Alt (Option or ⌥ on OS X) key was active when the event was generated.

func (WheelEvent) CtrlKey

func (m WheelEvent) CtrlKey() bool

CtrlKey returns true if the Ctrl key was active when the event was generated.

func (WheelEvent) MetaKey

func (m WheelEvent) MetaKey() bool

MetaKey returns true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the event was generated.

func (WheelEvent) ShiftKey

func (m WheelEvent) ShiftKey() bool

ShiftKey returns true if the Shift key was active when the event was generated.

Jump to

Keyboard shortcuts

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