Module aperture

Provides a scrollable view.

Like the photographer who touches the tips of her thumbs together, framing a shot.

Info:

  • License: GPL v3
  • Author: Wesley Werner

Functions

module:new (args) Creates a new aperture.
insert (hotspot) Inserts a control into the aperture.
update (dt) Process apeture animations.
pointFromScreen (x, y) Converts screen coordinates to local points.
apply () Apply transforms and clipping.
release () Release transforms and clippings.
scrollUp () Scroll the aperture one page up.
scrollDown () Scroll the aperture one page down.
scrollLeft () Scroll the aperture one page left.
scrollRight () Scroll the aperture one page right.
scrollTo (page) Scroll the aperture to the specified page.
mousemoved (x, y, dx, dy, istouch) Process mouse movement.
mousepressed (x, y, button, istouch) Process mouse presses inside the aperture.
mousereleased (x, y, button, istouch) Process mouse releases inside the aperture.

Tables

args A table of arguments for new apertures.
instance Lists properties available on the aperture instance.


Functions

module:new (args)
Creates a new aperture.

Parameters:

  • args args A table of arguments.

Returns:

    instance A new aperture instance
insert (hotspot)
Inserts a control into the aperture. This can be a hotspot, button or switch.

Parameters:

  • hotspot hotspot The hotspot to insert.
update (dt)
Process apeture animations. Call this in you main game loop.

Parameters:

  • dt number Time delta as given by the Love callback
pointFromScreen (x, y)
Converts screen coordinates to local points.

Parameters:

  • x number The x point to convert.
  • y number The y point to convert.

Returns:

    number The converted x, y points as two output parameters.
apply ()
Apply transforms and clipping. Call this to begin drawing inside the aperture. This ensures anything drawn will be constrained to within the aperture size and position on screen. Drawing positions are relative to the aperture.

See also:

release ()
Release transforms and clippings. Call this when you are done drawing aperture contents.

See also:

scrollUp ()
Scroll the aperture one page up.
scrollDown ()
Scroll the aperture one page down.
scrollLeft ()
Scroll the aperture one page left. This function is a synonymn for scrollUp and provided just for readability. Useful for apertures that display in landscape mode.

See also:

scrollRight ()
Scroll the aperture one page right. This function is a synonymn for scrollDown and provided just for readability. Useful for apertures that display in landscape mode.

See also:

scrollTo (page)
Scroll the aperture to the specified page. The given page is clamped to the aperture's limits so it is safe to give an out-of-bounds value.

Parameters:

  • page number
mousemoved (x, y, dx, dy, istouch)
Process mouse movement. Call this from your game loop to let the aperture determine if it is in focus via the "focused" property.

Parameters:

  • x
  • y
  • dx
  • dy
  • istouch
mousepressed (x, y, button, istouch)
Process mouse presses inside the aperture.

Parameters:

  • x
  • y
  • button
  • istouch

See also:

mousereleased (x, y, button, istouch)
Process mouse releases inside the aperture. This is the function that triggers any callbacks on children controls.

Parameters:

  • x
  • y
  • button
  • istouch

See also:

Tables

args
A table of arguments for new apertures. In addition to the mentioned parameters, you can add any other keys you want. All keys are copied to the aperture instance, which allows you to access them later through the instance.

Fields:

  • left number The left screen position.
  • top number The top screen position.
  • width number The width in pixels.
  • height number The height in pixels.
  • pages number Sets the total number of pages available to scroll through. (optional)
  • duration number The time in seconds the scroll animation lasts. The default is 1 second. (optional)
  • easing string The easing function used for the scroll animation. The default is "outCubic". (optional)
  • landscape bool Landscape controls horizontal scrolling. The default is false (vertical scrolling).

    (optional)

  • factor number The size of each scroll step. You can set this to a fraction too. The default is 1 and scrolls a full page each time. A factor of 0.5 steps half a page at a time. (optional)
instance
Lists properties available on the aperture instance.

Fields:

  • focused bool true while the cursor is over the aperture. This is determined automatically while you call mousemoved
  • hotspots table A collection of hotspots contained within the aperture that were added via the insert function.
generated by LDoc 1.4.6 Last updated 2018-01-03 16:24:23