Module Duplex.Canvas

Employed by the UIComponents to represent their visual state

The canvas is a two-dimensional table of CanvasPoints which can be resized.

Each CanvasPoint specifies both the visual appearance of a button (via color or text), as well as any sort of value that the UIComponent might define.

Also, the canvas is the layer we perform our updates "through". By checking the "delta", we can decide if something has actually changed before the update is performed.

Think of it as pre-optimization - both cabled MIDI and wireless devices are capable of choking or skipping messages.

Functions

__init (device) Initialize the Canvas class
set_size (width, height) Call whenever the size of the parent UIComponent changes
write (point, x, y) Write a single point to the canvas at the provided x/y coordinates
fill (point) Fill/flood entire canvas with given point
check_delta (point, x, y) If point is different from existing value, mark the canvas as changed both color, text and value are considered when doing the comparison
clear_delta () After the display has finished drawing the object, this is called to clear the delta buffer and mark the canvas as unchanged

Tables

self.delta (table) difference buffer, cleared on each update
self.buffer (table) the current, complete representation
self.clear table of extraneous points that should be cleared on next update created when the canvas is reduced in size, and contains just a simple set of booleans (the Display class will create the empty points when needed)

Fields

self.has_changed (bool) flag when we need to update the display
self.width (int) canvas width
self.height (int) canvas height


Functions

__init (device)
Initialize the Canvas class

Parameters:

  • device (Device)
set_size (width, height)
Call whenever the size of the parent UIComponent changes

Parameters:

  • width (int)
  • height (int)
write (point, x, y)
Write a single point to the canvas at the provided x/y coordinates

Parameters:

fill (point)
Fill/flood entire canvas with given point

Parameters:

check_delta (point, x, y)
If point is different from existing value, mark the canvas as changed both color, text and value are considered when doing the comparison

Parameters:

clear_delta ()
After the display has finished drawing the object, this is called to clear the delta buffer and mark the canvas as unchanged

Tables

self.delta
(table) difference buffer, cleared on each update

Fields:

  • {
self.buffer
(table) the current, complete representation

Fields:

  • {
self.clear
table of extraneous points that should be cleared on next update created when the canvas is reduced in size, and contains just a simple set of booleans (the Display class will create the empty points when needed)

Fields

self.has_changed
(bool) flag when we need to update the display
self.width
(int) canvas width
self.height
(int) canvas height
generated by LDoc 1.4.2