MCPcopy
hub / github.com/zxing-js/library / write

Function write

src/browser/BrowserSvgCodeWriter.ts:42–64  ·  view source on GitHub ↗

* Writes the QR code to a SVG and renders it in the container.

(
        contents: string,
        width: number,
        height: number,
        hints: Map<EncodeHintType, any> = null
    )

Source from the content-addressed store, hash-verified

40 * Writes the QR code to a SVG and renders it in the container.
41 */
42 public write(
43 contents: string,
44 width: number,
45 height: number,
46 hints: Map<EncodeHintType, any> = null
47 ): SVGSVGElement {
48
49 if (contents.length === 0) {
50 throw new IllegalArgumentException('Found empty contents');
51 }
52
53 if (width < 0 || height < 0) {
54 throw new IllegalArgumentException('Requested dimensions are too small: ' + width + 'x' + height);
55 }
56
57 let quietZone = hints && hints.get(EncodeHintType.MARGIN) !== undefined
58 ? Number.parseInt(hints.get(EncodeHintType.MARGIN).toString(), 10)
59 : BrowserSvgCodeWriter.QUIET_ZONE_SIZE;
60
61 const code = this.encode(hints, contents);
62
63 return this.renderResult(code, width, height, quietZone);
64 }
65
66 /**
67 * Encodes the content to a Barcode type.

Callers

nothing calls this directly

Calls 5

parseIntMethod · 0.80
encodeMethod · 0.65
getMethod · 0.45
toStringMethod · 0.45
renderResultMethod · 0.45

Tested by

no test coverage detected