Difference between revisions of "SHIP:Sail:qr"

From Serious Documentation
Jump to: navigation, search
(Prototype)
(Parameters/Return Value)
Line 14: Line 14:
 
! scope="col" style="text-align:left" | Description
 
! scope="col" style="text-align:left" | Description
 
|-
 
|-
|parentNode||{{DataType|Node}}||The node to look in for children
+
|canvas||{{DataType|Node}}||Node of type canvas to render into
 
|-
 
|-
|index||{{DataType|Integer}}||The index of the child desired in the parent
+
|size||{{DataType|Dimension}}||Pixel width and height of resulting square QR code image
 +
|-
 +
|x||{{DataType|Dimension}}||Horizontal offset in canvas for bottom right corner of QR code
 +
|-
 +
|y||{{DataType|Dimension}}||Vertical offset in canvas for bottom right corner of QR code
 +
|-
 +
|type||{{DataType|Byte}}||Type of QR code 0...127
 +
|-
 +
|redundancy||{{DataType|Byte}}|| Data redundancy desired in QR image 0..100 as a percentage
 +
|-
 +
|src||{{DataType|String}}||String object for source data
 +
|-
 +
|src||{{DataType|Buffer}}||Buffer object for source data
 +
|-
 +
|fg||{{DataType|Color}}||Vertical offset in canvas for bottom right corner of QR code
 +
|-
 +
|bg||{{DataType|Color}}||Vertical offset in canvas for bottom right corner of QR code
 
|-
 
|-
! scope="col" style="text-align:left" | Return
 
! scope="col" style="text-align:left" | {{DataType|Node}}
 
! scope="col" style="text-align:left" | nth node within the parentNode's children
 
 
|}
 
|}
  

Revision as of 15:15, 25 July 2016

Function Returns Introduced Description
qr nothing v5.1 Generates a QR code image in a canvas object.

See Also:

Prototype

qr(Node canvas, Dimension size, Dimension x, Dimension y, Byte type, Byte redundancy, String src, [Color fg [, Color bg ]]);

Parameters/Return Value

Parameter Data Type Description
canvas Node Node of type canvas to render into
size Dimension Pixel width and height of resulting square QR code image
x Dimension Horizontal offset in canvas for bottom right corner of QR code
y Dimension Vertical offset in canvas for bottom right corner of QR code
type Byte Type of QR code 0...127
redundancy Byte Data redundancy desired in QR image 0..100 as a percentage
src String String object for source data
src Buffer Buffer object for source data
fg Color Vertical offset in canvas for bottom right corner of QR code
bg Color Vertical offset in canvas for bottom right corner of QR code

Detailed Description

The getChild function returns the direct child at index within the parent.

Nodes in SHIP may have 0 or more direct child nodes. For example, a group in the resources area may have N images within the group. These children, if present, are implicitly numbered 0..(N-1) where N is the total number of children of any type within the parent node.

The index is always taken "modulus the count of children within the parent", preventing inadvertent out-of-bounds accesses. For example, a reference to index 5 when the parent only has 4 children will return 5%4 => 1. Negative indices are handled also with a modulus. Therefore, as expected, index -1 returns the last child.

If the specified parent node has no children, the parent object itself is returned by the function.

Examples

Animations

getChild is particularly useful for animations where an incrementing counter variable from a timer can be used as an index into a group of images and then assigning the result to a box's object property.