Pure QR code encoder/decoder written in MoonBit
| Package | What it is |
|---|---|
| naoto24kawa/moonqr/gf256 | GF(256) arithmetic + Reed–Solomon encode/decode, used by both encode and decode |
| naoto24kawa/moonqr/encode | Text → QR Matrix (module placement, masking, format/version info) + SVG rendering |
| naoto24kawa/moonqr/decode | RGBA pixels → decoded text (binarization, finder-pattern location, perspective extraction, codeword decode); ported from jsQR |
moon add naoto24kawa/moonqrlet matrix = @encode.encode("HELLO WORLD", @encode.EcLevel::M, None)
match matrix {
Some(m) => {
// m.size x m.size module grid; m.get(x, y) : Bool (true = dark module)
let svg = @encode.to_svg_string(m, 4, 8) // margin=4 modules, cell=8px
...
}
None => ... // capacity exceeded, or an explicit `version` too small for the text
}// data: RGBA bytes, width * height * 4 long
let result = @decode.decode(data, width, height, true) // invert=true also tries the inverted binarization
match result {
Some(r) => {
// r.text : String, r.bytes : Array[Int], r.version : Int,
// r.ec : @encode.EcLevel, r.corners : Array[Point] (TL, TR, BR, BL, in pixel space)
...
}
None => ... // no QR code found in the frame
}Pure QR code encoder/decoder written in MoonBit