This is a quick function that can convert a QR code generated with the rust version of QR-Code-generator into a much smaller SVG than the to_svg_string
function included in their example.
The function is made generic so that you may use this function with other qr sources. All the function needs is a method to check coordinates if they contain a block box or not besides the size and border values.
So if you have the data for your QR code, all you need is to write a method as I did in the FakeQr
struct for the tests.
The SVG optimizations:
- Remove unneeded attributes, tags and whitespace
- Use short form for hex colors