Skip to content

Content

Crutiatix edited this page Apr 10, 2017 · 10 revisions

Table containing attributes defining a attributes of content drawn inside of element.

You can draw inside an element by setting its content, using element:setContent(). It only takes a function as a parameter, which will be given the ref, x and y attributes. It's needed to add atributes x and y to position of any element which is drawn in content for make it move together with main element when is dragged.

Scrolling is set in the content atribute using scroll atribute. You can later set the scroll for a specific axis manually using element:setScroll({ x, y }) and retrieve scroll using element:getScroll()

Lastly, it's possible to redefine content dimensions at runtime with element:setContentDimensions(width, height).

  • Attribute of:
  • Attributes:
    • w = [number] (element.w) - virtual width of content. Important when scrolling.
    • h = [number] (element.h) - virtual width of content. Important when scrolling.
    • wrap = [bool] (false) - if true then clip content by borders of element
    • scroll = [table] ({x=0,y=0})- define initial scroll of content
      • x = [number] (0) - Number 0 - 1 defining content scroll. 0 is at left, 1 at right.
      • y = [number] (0) - Number 0 - 1 defining content scroll. 0 is at top, 1 at bottom.
  • Functions:
    • element:setContent
      • arguments:
        • [function] - function containing drawing something
          • arguments:
            • [object] - a reference to element
            • [number] = x position of element's content (+border)
            • [number] = y position of element's content (+border)
    • element:setScroll
      • arguments:
        • [table]
          • x = [number] (0) - Number 0 - 1 defining content scroll. 0 is at left, 1 at right.
          • y = [number] (0) - Number 0 - 1 defining content scroll. 0 is at top, 1 at bottom.
    • element:getScroll
      • return:
        • [table]
          • x = [number] (0) - Number 0 - 1 defining content scroll. 0 is at left, 1 at right.
          • y = [number] (0) - Number 0 - 1 defining content scroll. 0 is at top, 1 at bottom.
    • element:setContentDimensions
      • arguments:
        • w = [number] (element.w) - virtual width of content. Important when scrolling.
        • h = [number] (element.h) - virtual width of content. Important when scrolling.
Clone this wiki locally