render Shaded
Renders a QR Code image based on its computed data. This function exists to ease the interop with Java :)
Please, see renderShaded.
Return
A QRCodeGraphics with the QR Code rendered on it. It can then be saved or manipulated as desired.
See also
Parameters
The size in pixels of each square (cell) in the QR Code. Defaults to 25
.
Amount of space in pixels to add as a margin around the rendered QR Code. Defaults to 0
.
Mapping function that maps a pixel to a color. (image, x, y, Triple<Bright, Row, Column>?) -> pixel RGBA color
.
Renders a QR Code image based on its computed data.
This function provides a way to implement more artistic QRCodes. The renderer is a function that draws a single square of the QRCode. It receives 2 parameters: cellData and a QRCodeGraphics for it to freely draw. After finished, the canvas will be placed into the final image in its respective place.
To show this, here's a renderer that makes a QR Code that is half blue and half red:
QRCode("example").renderShaded { cellData, graphics ->
if (cellData.type != QRCodeSquareType.MARGIN && cellData.dark) {
if (cellData.row cellData.size / 2) {
graphics.fill(Colors.BLUE)
}
else {
graphics.fill(Colors.RED)
}
} else {
graphics.fill(Colors.WHITE)
}
}
Tip: for the "traditional look-and-feel" QR Code, try setting margin equal to cellSize.
Return
A QRCodeGraphics with the QR Code rendered on it. It can then be saved or manipulated as desired.
See also
Parameters
The size in pixels of each square (cell) in the QR Code. Defaults to 25
.
Amount of space in pixels to add as a margin around the rendered QR Code. Defaults to 0
.
The data matrix of the QR Code. Defaults to this.encode().
The QRCodeGraphics where the QRCode will be painted into.
Lambda that draws a single QRCode square. It receives as parameters the QRCodeSquare being draw and a QRCodeGraphics for it to draw the square.