arsd.qrcode

Members

Structs

QrCode
struct QrCode

Examples

import arsd.qrcode;

void main() {
	import arsd.simpledisplay;

	QrCode code = QrCode("http://arsdnet.net/");

	enum drawsize = 4;
	// you have to have some border around it
	auto window = new SimpleWindow(code.size * drawsize + 80, code.size * drawsize + 80);

	{
		auto painter = window.draw;
		painter.clear(Color.white);

		foreach(y; 0 .. code.size)
		foreach(x; 0 .. code.size) {
			if(code[x, y]) {
				painter.outlineColor = Color.black;
				painter.fillColor = Color.black;
			} else {
				painter.outlineColor = Color.white;
				painter.fillColor = Color.white;
			}
			painter.drawRectangle(Point(x * drawsize + 40, y * drawsize + 40), Size(drawsize, drawsize));
		}
	}

	window.eventLoop(0);
}

Meta

History

Originally written in C by Project Nayuki.

Ported to D by me on July 26, 2021