Difference between revisions of "SHIP:Sail:qr"

From Serious Documentation
Jump to: navigation, search
(Detailed Description)
(Prototype)
Line 7: Line 7:
 
*[[SHIP:Sail:Functions|Sail Functions]]
 
*[[SHIP:Sail:Functions|Sail Functions]]
 
== Prototype ==
 
== Prototype ==
<code>{{SailFunc|qr}}({{DataType|Node}} canvas, {{DataType|Dimension}} size, {{DataType|Dimension}} x, {{DataType|Dimension}} y, {{DataType|Byte}} type, {{DataType|Byte}} redundancy, {{DataType|String}} src, <nowiki>[</nowiki>{{DataType|Color}} fg <nowiki>[</nowiki>, {{DataType|Color}} bg <nowiki>]]</nowiki>);</code><code>{{SailFunc|qr}}({{DataType|Node}} canvas, {{DataType|Dimension}} size, {{DataType|Dimension}} x, {{DataType|Dimension}} y, {{DataType|Byte}} type, {{DataType|Byte}} redundancy, {{DataType|Buffer}} src, <nowiki>[</nowiki>{{DataType|Color}} fg <nowiki>[</nowiki>, {{DataType|Color}} bg <nowiki>]]</nowiki>);</code>
+
<code>{{SailFunc|qr}}({{DataType|Node}} canvas, {{DataType|Dimension}} size, {{DataType|Dimension}} x, {{DataType|Dimension}} y, {{DataType|Byte}} type, {{DataType|Byte}} redundancy, {{DataType|String}} src, {{DataType|Node}} intVar, <nowiki>[</nowiki>{{DataType|Color}} fg <nowiki>[</nowiki>, {{DataType|Color}} bg <nowiki>]]</nowiki>);
 +
 
 +
</code><code>{{SailFunc|qr}}({{DataType|Node}} canvas, {{DataType|Dimension}} size, {{DataType|Dimension}} x, {{DataType|Dimension}} y, {{DataType|Byte}} type, {{DataType|Byte}} redundancy, {{DataType|Buffer}} src, {{DataType|Node}} intVar, <nowiki>[</nowiki>{{DataType|Color}} fg <nowiki>[</nowiki>, {{DataType|Color}} bg <nowiki>]]</nowiki>);</code>
  
 
=== Parameters/Return Value ===
 
=== Parameters/Return Value ===
Line 27: Line 29:
 
|redundancy||{{DataType|Byte}}|| Data redundancy desired in QR image 0..100 as a percentage
 
|redundancy||{{DataType|Byte}}|| Data redundancy desired in QR image 0..100 as a percentage
 
|-
 
|-
|src||{{DataType|String}}||String object for source data
+
|src||{{DataType|String}} or {{DataType|Buffer}}||String or Buffer object for source data
 
|-
 
|-
|src||{{DataType|Buffer}}||Buffer object for source data
+
|intVar||{{DataType|Integer}}||Integer variable for completion event and error code return
 
|-
 
|-
 
|fg||{{DataType|Color}}||ARGB8888 color used for rendering the foreground; if not specified default is 0xFF000000 (opaque black)
 
|fg||{{DataType|Color}}||ARGB8888 color used for rendering the foreground; if not specified default is 0xFF000000 (opaque black)

Revision as of 15:45, 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, Node intVar, [Color fg [, Color bg ]]);

qr(Node canvas, Dimension size, Dimension x, Dimension y, Byte type, Byte redundancy, Buffer src, Node intVar, [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 or Buffer String or Buffer object for source data
intVar Integer Integer variable for completion event and error code return
fg Color ARGB8888 color used for rendering the foreground; if not specified default is 0xFF000000 (opaque black)
bg Color ARGB8888 color used for rendering the background; if not specified default is 0xFFFFFFFF (opaque white)

Detailed Description

The qr function renders a QR code image into a canvas node based on runtime data held in a binary Buffer or String.

Since QR codes are always square, the size parameter indicates the pixel width and pixel height of the QR code. Since canvas dimensions are positive up-and-to-the-right (vs. box/frame which are down and to the right) the offset specified in the qr functions x and y parameters indicate the bottom-left corner of the QR code's target location. In the canvas, the QR code will be rendered at [x,y..(x+size-1),(y+size-1)].

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.