Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SVG options to render using paths. #108

Merged
merged 9 commits into from May 6, 2021
Merged

Add SVG options to render using paths. #108

merged 9 commits into from May 6, 2021

Conversation

whomwah
Copy link
Owner

@whomwah whomwah commented Mar 25, 2021

This continues the great work of @HuBandiT in rendering SVGs using a single <path> node. This greatly reduces complexity and size. The example SVG in the specs goes from 27K down to 1.8K (~1400% smaller).

It goes down to 1920 bytes on the same test (uncompressed; gzip-compressed it is down to 711 bytes).
Plus quality is better too, since we are no longer packing individual rectangles (squares) next to each other, hoping rounding is correct everywhere downstream (rasteriser, or conversion to other vector formats e.g. PDF) so that no white lines occur between them (did happen to me a few times). (Plus since it's a single object, I have a hunch it processes/displays/edits faster downstream too.)

but makes makes it opt in for the time being using:

RQRCode::QRCode.new("https://kyan.com").as_svg(
  use_path: true
)

example_output => <path d="M0 0h7v7h-7zM8 0h7v2h-1v1h1v1h-2v-2h-1v-1h-2v2h-2v-1h1v-1h-1zM17 0....h3v3h-3zM17 24v1h1v-1zM21 1h1v1h-3zM9 27h1v1h-1zM26 27h1v1h-1zM28 27h1v1h-1z" style="fill:#000" transform="translate(0,0) scale(11)"/>

This means we keep the backward compatibility, but give users the chance to opt-in. Opting in should show no change to the outputted QR Code and only change the markup.

In a future version of this Gem, this option will be made default after a bit more testing in the field.

@whomwah whomwah added the WIP label Mar 25, 2021
@whomwah whomwah self-assigned this Mar 25, 2021
@whomwah whomwah marked this pull request as draft April 22, 2021 10:51
I don't know why 11 was chosen but on the same vain I don't see why I need to change it.
@whomwah whomwah removed the WIP label Apr 22, 2021
@whomwah whomwah marked this pull request as ready for review April 22, 2021 11:10
@whomwah whomwah changed the base branch from master to dr-release-2.0.0 April 22, 2021 15:10
@whomwah whomwah changed the base branch from dr-release-2.0.0 to master April 23, 2021 13:28
@whomwah whomwah merged commit c7a46d5 into master May 6, 2021
@whomwah whomwah deleted the dr-svg-pixel branch May 6, 2021 08:27
@whomwah whomwah mentioned this pull request May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants