Module lib.masks

Masks: containers for clipping and offsetting other shado objects.

Functions

Mask:new (content, x, y, width, height) Create a new mask around an existing object.
Mask:setX (x) Update the leftmost coordinate of the mask, shifting it horizontally.
Mask:setY (y) Update the topmost coordinate of the mask, shifting it vertically.
Mask:getX () Get the leftmost coordinate of the mask.
Mask:getY () Get the topmost coordinate of the mask.
Mask:inRange (x, y) Determine whether a coordinate point (x, y) is within the mask area.
Mask:getLamp (x, y) Get the effective lamp value at position (x, y).
Mask:press (x, y, how) The default handler for button press events.
Mask:routePress00 (x, y) Internal function for routing press-on events.


Functions

Mask:new (content, x, y, width, height)
Create a new mask around an existing object. The object doesn't shift its position, but is covered with a mask which starts at (x, y) (origin is (1, 1)) and has size (width, height). Nothing appears outside the mask - the area is transparent - and button presses outside the mask are ignored.

Parameters:

  • content the object to mask
  • x the leftmost coordinate of the mask
  • y the topmost coordinate of the mask
  • width the width of the mask
  • height the height of the mask

Returns:

    a new mask
Mask:setX (x)
Update the leftmost coordinate of the mask, shifting it horizontally.

Parameters:

  • x the X coordinate
Mask:setY (y)
Update the topmost coordinate of the mask, shifting it vertically.

Parameters:

  • y the Y coordinate
Mask:getX ()
Get the leftmost coordinate of the mask.

Returns:

    the X coordinate
Mask:getY ()
Get the topmost coordinate of the mask.

Returns:

    the Y coordinate
Mask:inRange (x, y)
Determine whether a coordinate point (x, y) is within the mask area.

Parameters:

  • x the X coordinate
  • y the Y coordinate

Returns:

    true or false depending on inclusion
Mask:getLamp (x, y)
Get the effective lamp value at position (x, y). If the position is within the mask, then return the value calculated from the contained object, otherwise return LampState.THRU.

Parameters:

  • x the X coordinate
  • y the Y coordinate

Returns:

    the lamp value

See also:

Mask:press (x, y, how)
The default handler for button press events. It returns false, which will cause press events to be passed into the mask's contained object. Override to handle buttons in the mask itself, rather than its contained object.

Parameters:

  • x the X location of the press
  • y the Y location of the press
  • how the kind of button event: 1 for press, 0 for release.

Returns:

    false
Mask:routePress00 (x, y)
Internal function for routing press-on events. Returns a RouteResult object so that the corresponding press-off can be handled properly.

Return nil if the coordinate position is outside the mask. Otherwise, if the mask itself does not handle the press, then the constituent object is tried.

There is some subtlety here; if the mask itself handles the press, the coordinate system treats the top-left corner of the mask as (1, 1), regardless of where the mask is positioned over its enclosed object. If the object handles the press, the coordinates are as if the mask were not present.

Parameters:

  • x
  • y
generated by LDoc 1.4.6 Last updated 2021-12-30 22:00:16