1.3.1 • Published 5 years ago

qr3d v1.3.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

logo

A simple library to generate 3D printable QR codes on both NodeJS and browser web apps!

sample

Install

# with npm
npm i qr3d --save

# or with yarn:
yarn add qr3d

Use

NodeJs

const qr3D = require('qr3d')
const fs = require('fs')

const stl = qr3D('https://www.npmjs.com/package/qr3d').data
fs.writeFileSync('sample.stl', stl)

Modern web

import qr3D from 'qr3d'
import { saveAs } from 'file-saver'

const stl = qr3D(content).data
saveAs(new Blob([stl], {type: 'text/plain;charset=utf-8'}), 'sample.stl')

Good old web

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/qr3d@1.0.0/dist/qr3d.umd.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/file-saver@2.0.2/dist/FileSaver.min.js"></script>
<script type="text/javascript">
  var exportStl = function(content, options) {
    var stl = qr3D(content, options).data;
    saveAs(new Blob([stl], {type: "text/plain;charset=utf-8"}), "sample.stl");
  }
</script>

--

You can also have a look at the samples folder for a react sample.

API

qr3D expose only one function with 2 signatures:

  • qr3D(stringToEncode, options)
  • qr3D(options)

stringToEncode should be a string. It's the string to encode into QRCode. options will copy this string into his "text" property. In this scenario, a given "text" in the options object will be replaced by the stringToEncode value.

The options parameters are :

NameTypeDefault valueDescription
textStringThe text to QR-encode
bitSizeNumber4Width/Depth (mm) of the cells composing the QRcode grid
heightNumber2Height (mm) of the qrcode part
baseNumber2Height (mm) of the solid base part
binaryBooleantrueOutput .stl content as Buffer/ArrayBuffer (depending on platform)
baseColor*Array0, 0, 0this parameter is only available in binary format Color of the solid base part
qrColor*Array0, 0, 31this parameter is only available in binary format Color of the qrcode part

* baseColor and qrColor are special parameters to add color information in .stl content output. The format of these colors is an rgb array where r,g, and b are 5 bits integers (between 0 and 31).

Those colors are not in the official specification and are available in binary format only. Furthermore there are generally not usued by softwares, so don't expect to much with it... read more on wikipedia

Return value is an Object with these properties :

{
    data, // .stl content as String, Buffer or ArrayBuffer
    qrcode // the qrcode raw data
}

Contributing

Contributions in any form are welcome! If you find a bug, please file an issue.

License

This project is licensed under the MIT license. See the LICENSE file for more details.

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.5

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago