Skip to content

Commit

Permalink
- chore: fixed marker examples
Browse files Browse the repository at this point in the history
  • Loading branch information
le0m committed Feb 27, 2020
1 parent 1d6f991 commit 84c4b7d
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ This method is used to create a barcode image from a value.
Accepts a matrix type (see exported `MATRIX_*` constants) and a value and returns a data URI string,
representing an SVG of the barcode marker.

Supported matrix types (values start from 0):

| Matrix type | Max value |
| ----------------- | ----------- |
| `3x3_hamming_6_3` | 7 |
| `3x3_parity_6_5` | 31 |
| `4x4_bch_13_5_5` | 31 |
| `4x4_bch_13_9_3` | 511 |
| `5x5_bch_22_7_7` | 128 |
| `5x5_bch_22_12_5` | 4095 |

**MarkerModule.getMarkerPattern(dataURI)**

This method is used to create a `.patt` file from an image.
Expand All @@ -75,19 +86,23 @@ a data URI string representing the final marker image.
const { MarkerModule, MATRIX_3X3_HAMMING_63 } = ARjsStudioBackend;

// generate an SVG data URI for the value '8'
const barcodeMarkerSVG = MarkerModule.getBarcodeMarkerSVGDataURI(MATRIX_3X3_HAMMING_63, 8);
const barcodeMarkerSVG = MarkerModule.getBarcodeMarkerSVGDataURI(MATRIX_3X3_HAMMING_63, 7);

const barcodeImage = new Image();
barcodeImage.src = barcodeMarkerSVG; // use the image 'load' event to know when image is ready

// ----

// draw the image on an off-screen canvas and use `.toDataURL()` to get a data URI
const fullMarker = MarkerModule.getFullMarkerImage(imageDataURI, 1.0, 100, 'black');
const pattFile = MarkerModule.getMarkerPattern(imageDataURI);
const fullMarker = await MarkerModule.getFullMarkerImage(imageDataURI, 1.0, 100, 'black');
const pattFile = await MarkerModule.getMarkerPattern(imageDataURI);

const patternImage = new Image();
patternImage.src = fullMarker; // use the image 'load' event to know when image is ready
patternImage.src = fullMarker;
// use the image 'load' event to know when image is ready
patternImage.addEventListener('load', () => {
document.body.appendChild(patternImage);
})

const pattFileDownload = document.createElement('a');
pattFileDownload.href = `data:text/plain;charset=utf-8,${pattFile}`;
Expand Down

0 comments on commit 84c4b7d

Please sign in to comment.