Repository navigation
feat(qr-code): qr code enhancements and goodies - #2646
Merged
Merged
Conversation
Split the value into numeric, alphanumeric and byte segments with the fewest bits, by a shortest path over the characters for each count field width group. Neighbors that tie on bits merge into one segment. A value with a long digit or uppercase run in other text can get a smaller version. Export the QrCornerDotStyle type. Document that the code writes UTF-8 with no ECI header. The single-mode property spec now checks the bits against the best single mode. New properties check the version of mixed data and decode the matrix with zxing, through a shared prepareQrDecoder() helper that the component spec also uses.
Add igniteui-webcomponents/extras/qr-payloads with createWifiPayload(), createVCardPayload(), createEpcPayload() and createEventPayload(). Each builds the value of a code that a phone turns into an action, escapes the text, and throws a RangeError for input that its format does not allow. The formats are WIFI:, vCard 3.0, EPC version 002 in UTF-8, and an iCalendar VEVENT in UTC. Property specs read the escapes back with independent parsers. Move each extra into its own folder with a README that the main README links, and give the payload helpers a specification. The subpaths do not change. The Generator story uses the helpers and adds a payment and an event. New stories show the mailto:, tel:, SMSTO: and geo: recipes and a "Scan me" frame. The QR scan specs share readQr() and readQrMatrix().
…atterns Each module covers floor(size / (modules + 2 * margin)) whole pixels, on the screen and in an export at size * scale. The spare pixels widen the quiet zone, so margin is a minimum and the code can be smaller than size. A fractional margin can make each module 1 pixel smaller, so that both sides keep the minimum. A transform on the code group and the logo does the snapping, so the viewBox stays 0 0 n n. Draw each alignment pattern as a ring of square-style around a dot of the corner dot style, in a new alignment part that takes --ig-qr-code-dark-color. A rounded module no longer joins it. Fix square-style="circle" codes that failed to scan at some sizes. zxing-cpp checks the finder pattern on its diagonals, where a square dot leaves a gap, and it did not find the alignment modules between circle dots. A square corner dot in a circle corner square now draws as a circle, and with the alignment rings the circle codes decode.
dot-style takes diamond, plus, liquid, horizontal-bars and vertical-bars. liquid fills the inside corner of each L-join of rounded modules, and a bar style draws each run of dark modules in a row or a column as one bar with round ends. Each style decodes at the 0.7 dot-scale floor, with each corner square. square-style and corner-dot-style take leaf: two opposite corners rounded at a quarter of the side, on the diagonal toward the center of the code. A fully round leaf failed to scan with zxing-cpp. A corner dot is one shape, so the corner dots draw diamond and plus as square, because both failed to scan as finder centers, and liquid and the bar styles as rounded. A circle corner square also draws a leaf corner dot as a circle.
gradient paints the modules and the corners with a linear or radial gradient, from --ig-qr-code-gradient-start to --ig-qr-code-gradient-end. gradient-angle turns a linear gradient. An explicit corner color wins for its part, and the export writes the stop colors. logo-shape clips the logo to a circle, rounded or squircle shape that fills the logo box. The cutout removes only the modules under the shape, so a pinned version can keep a larger logo. With a logo, rounded, liquid and bar modules end round at the cutout instead of being cut straight. The hidden modules stay under the mask.
Each dot style is now one entry in a table: its corner dot, whether its modules join, and how it draws them. The data modules read a grid of dark cells and zones, and the templates take one grid object. Pixel snapping moved to its own file. The part selectors match a word in `part`, and bars draw with two arcs. The other dot styles get the Latin square scans of the basic ones.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
createWifiPayload(),createVCardPayload(),createEpcPayload()andcreateEventPayload()in the newigniteui-webcomponents/extras/qr-payloadsentry point. This commit also moveschat-markdown-rendererandcombo-data-sourceinto their own folders undersrc/extras/, each with a README.alignmentpart. This also fixes codes with acirclecorner square, which zxing-cpp could not always read.dot-styletakesdiamond,plus,liquid,horizontal-barsandvertical-bars.square-styleandcorner-dot-styletakeleaf.gradientandgradient-anglepaint the modules with a linear or radial gradient from--ig-qr-code-gradient-startto--ig-qr-code-gradient-end.logo-shapeclips the logo to a circle, rounded or squircle shape, and the code removes only the modules under that shape.Existing codes render differently. The code can be smaller than
size,roundedmodules end round at the logo cutout, and some values get a smaller version. All of them still scan. No API is removed.The
igc-qr-codebundle goes from 17,628 B to 20,991 B gzip. The payload helpers are 1,786 B gzip in their own entry point.Type of Change
Testing
toImage()exports with zxing-cpp (zxing-wasm), at 6 pixels per module or more. Each new shape, gradient and logo shape has a scan spec, some also on a version 12 code.circlecorner square decoded 180 of 196 times with a square dot, and 190 of 196 times with the other dots (versions 3 to 25, 6 to 12 pixels per module). Now all 2,240 scans of the 16 corner shape pairs pass.Checklist
npm run public-api:updateand committedpublic-api.jsonandapi-reference/CHANGELOG.mdentry under[Unreleased]