Documentation ¶
Index ¶
- type Canvas
- func (c *Canvas[T]) Add(object Object[T])
- func (c *Canvas[T]) Clear()
- func (c *Canvas[T]) HandleEvent(event tinygl.Event, x, y int)
- func (c *Canvas[T]) Layout(width, height int)
- func (c *Canvas[T]) MarkUpdated()
- func (c *Canvas[T]) MinSize() (width, height int)
- func (c *Canvas[T]) RequestUpdate()
- func (c *Canvas[T]) SetEventHandler(eventHandler func(event tinygl.Event, x, y int))
- func (c *Canvas[T]) Size() (width, height int)
- func (c *Canvas[T]) Update(screen *tinygl.Screen[T], ...)
- type Circle
- type CustomCanvas
- type Image
- func (obj *Image[T]) Bounds() (x, y, width, height int)
- func (obj *Image[T]) Draw(bufX, bufY int, buf pixel.Image[T])
- func (obj *Image[T]) Hidden() bool
- func (obj *Image[T]) Move(x, y int)
- func (obj *Image[T]) SetHidden(hidden bool)
- func (obj *Image[T]) SetImage(img image.Image[T])
- func (obj *Image[T]) SetScale(scale int)
- type Line
- type Object
- type Rect
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Canvas ¶
A canvas based on small tiles that supports modifying these objects and only redraws the affected tiles. This results in very fast incremental updates if only small parts of the screen changed.
func (*Canvas[T]) Add ¶
Add a previously created object to the canvas. An object can't be added more than once.
func (*Canvas[T]) HandleEvent ¶
HandleEvent handles events such as touch events and calls the event handler with the x/y coordinate as parameters.
func (*Canvas[T]) MarkUpdated ¶
func (c *Canvas[T]) MarkUpdated()
func (*Canvas[T]) RequestUpdate ¶
func (c *Canvas[T]) RequestUpdate()
func (*Canvas[T]) SetEventHandler ¶
SetEventHandler sets the callback when a (touch) event occurs on this canvas.
type Circle ¶
Circle is a simple solid color circle.
func NewCircle ¶
NewCircle implements a circle object, with antialiased edges.
The (x, y) coordinates are of the center of the circle, right in the middle of the innermost 4 pixels. This means for example that if you draw a circle at (0, 0) of a large enough canvas, exactly a quarter of the circle is shown.
Warning: this API might change once circles with holes and/or circles with borders are added.
type CustomCanvas ¶
type CustomCanvas[T pixel.Color] struct { tinygl.Rect[T] // contains filtered or unexported fields }
CustomCanvas is a canvas widget to draw custom data.
func NewCustomCanvas ¶
func NewCustomCanvas[T pixel.Color](background T, minWidth, minHeight int, update func(screen *tinygl.Screen[T], displayX, displayY, displayWidth, displayHeight, x, y int)) *CustomCanvas[T]
NewCustomCanvas returns a ready made custom canvas. The update callback should always redraw the entire canvas, even if not the entire canvas changed.
func (*CustomCanvas[T]) Layout ¶
func (c *CustomCanvas[T]) Layout(width, height int)
Layout implements tinygl.Object.
func (*CustomCanvas[T]) MinSize ¶
func (c *CustomCanvas[T]) MinSize() (width, height int)
MinSize returns the minimal size as set when the canvas was created.
func (*CustomCanvas[T]) Size ¶
func (c *CustomCanvas[T]) Size() (width, height int)
Size returns the current canvas size, as updated after the first layout.
type Image ¶
Image wraps an image.Image object to be drawn on a canvas.
func (*Image[T]) Bounds ¶
Bounds returns the rectangle coordinates relative to (0, 0) of the canvas.
func (*Image[T]) SetHidden ¶
SetHidden implements gfx.Object. It sets the visibility status of the rectangle on screen.
type Line ¶
Line is a line from a start coordinate to an end coordinate.
func NewLine ¶
NewLine creates a new line object, with antialiased edges.
The two coordinates (x1, y1) and (x2, y2) describe the starting and ending coordinate. The strokeWidth describes the width of the line, like the SVG property. Lines by default have an ending like SVG stroke-linecap="butt".
func (*Line[T]) SetHidden ¶
SetHidden implements gfx.Object. It sets the visibility status of the object on screen.
func (*Line[T]) SetPosition ¶
Set the line position (start and end point).
type Object ¶
type Object[T pixel.Color] interface { // Draw the object on the given image. // The X and Y coordinates are the offsets of img from the top left (0, 0) // of the canvas. Draw(x, y int, img pixel.Image[T]) // SetHidden changes the visibility of an object. SetHidden(bool) // contains filtered or unexported methods }
Object on a canvas.
type Rect ¶
Rect is a simple solid color rectangle.