Socket
Socket
Sign inDemoInstall

bitgener

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitgener - npm Package Compare versions

Comparing version 1.1.5 to 1.2.0

7

CHANGELOG.md
# CHANGELOG
## 1.2.0 - delivery @15/01/2020
- add opacity and bgOpacity options
- add opacity and bgOpacity to helpers.barcode.digitToSvg svg generation algorithm
- update default settings
- update Readme and doc examples
## 1.1.5 - delivery @15/01/2020

@@ -4,0 +11,0 @@

2

doc/examples/1d.js

@@ -17,3 +17,5 @@ const bitgener = require('../../lib');

color: '#FFFFFF',
opacity: 1,
bgColor: '#F7931A',
bgOpacity: 0.1,
hri: {

@@ -20,0 +22,0 @@ show: true,

4

doc/examples/2d.js

@@ -16,4 +16,6 @@ const path = require('path');

original2DSize: false,
color: '#FFFFFF',
color: 'black',
opacity: 1,
bgColor: '#F7931A',
bgOpacity: 0,
hri: {

@@ -20,0 +22,0 @@ show: true,

@@ -69,3 +69,5 @@ const stream = require('stream');

color: '#FFFFFF',
opacity: 1,
bgColor: '#F7931A',
bgOpacity: 1,
hri: {

@@ -72,0 +74,0 @@ show: true,

@@ -281,3 +281,3 @@ /**

// background
svg += `<rect width="${width}" height="${height}" x="0" y="0" fill="${settings.bgColor}" />`;
svg += `<rect width="${width}" height="${height}" x="0" y="0" fill="${settings.bgColor}" opacity="${settings.bgOpacity}" />`;

@@ -287,3 +287,3 @@ // center the code depending on padding width and padding height

const bar = `<rect width="&W" height="${moduleHeight}" x="&X" y="&Y" fill="${settings.color}" />`;
const bar = `<rect width="&W" height="${moduleHeight}" x="&X" y="&Y" fill="${settings.color}" opacity="${settings.opacity}" />`;

@@ -317,3 +317,3 @@ for (let y = 0, len = 0; y < lines; y += 1) {

*/
svg += `<text text-anchor="middle" lengthAdjust="spacingAndGlyphs" style="font-family: '${settings.hri.fontFamily}'; font-size: ${fontSize * fontSizeRatio}px;" fill="${settings.color}">${hri}</text>`;
svg += `<text text-anchor="middle" lengthAdjust="spacingAndGlyphs" style="font-family: '${settings.hri.fontFamily}'; font-size: ${fontSize * fontSizeRatio}px;" fill="${settings.color}" opacity="${settings.opacity}">${hri}</text>`;
svg += '</g>';

@@ -320,0 +320,0 @@ }

@@ -46,27 +46,31 @@ /**

/**
* @func bitgener
*
* Encode data into the specificied barcode type.
* @param {String} data [data to encode]
* @param {String} type [the supported symbology in which data will be encoded]
* @param {String} output [file path with .svg extension, buffer, stream,
* string representing svg element]
* @param {String} encoding [encoding for stream, buffer and file outputs]
* @param {Boolean} crc [cyclic redundancy check]
* @param {Boolean} rectangular [rectangular option for datamatrix]
* @param {Number} padding [the space in pixels around one side of the
* barcode that will be applied for its 4 sides]
* @param {Number} width [the width in pixels to fix for the generated image]
* @param {Number} height [the height in pixels to fix for the generated image]
* @param {Number} barWidth [the bar width in pixels for 1D barcodes]
* @param {Number} barHeight [he bar height in pixels for 1D barcodes]
* @param {Boolean} original1DSize [option to keep the original 1D barcode size]
* @param {Boolean} original2DSize [option to keep the original 2D barcode size based on width]
* @param {Boolean} addQuietZone [option to add a quiet zone at the end of 1D barcodes]
* @param {String} color [the bars color]
* @param {String} bgColor [the background color]
* @param {Object} hri [human readable interpretation]
* @param {Boolean} hri.show [whether to show hri]
* @param {Number} hri.fontFamily [a generic font name based on cssfontstack.com]
* @param {Number} hri.fontSize [the font size in pixels]
* @param {Number} hri.marginTop [the margin size in pixels between the barcode bottom and
* the hri text]
* @param {String} data data to encode
* @param {String} type the supported symbology in which data will be encoded
* @param {String} output file path with .svg extension, buffer, stream,
* string representing svg element
* @param {String} encoding encoding for stream, buffer and file outputs
* @param {Boolean} crc cyclic redundancy check
* @param {Boolean} rectangular rectangular option for datamatrix
* @param {Number} padding the space in pixels around one side of the
* barcode that will be applied for its 4 sides
* @param {Number} width the width in pixels to fix for the generated image
* @param {Number} height the height in pixels to fix for the generated image
* @param {Number} barWidth the bar width in pixels for 1D barcodes
* @param {Number} barHeight he bar height in pixels for 1D barcodes
* @param {Boolean} original1DSize option to keep the original 1D barcode size
* @param {Boolean} original2DSize option to keep the original 2D barcode size based on width
* @param {Boolean} addQuietZone option to add a quiet zone at the end of 1D barcodes
* @param {String} color the bars color
* @param {Number} opacity the bars opacity
* @param {String} bgColor the background color
* @param {Number} bgOpacity the background opacity
* @param {Object} hri human readable interpretation
* @param {Boolean} hri.show whether to show hri
* @param {Number} hri.fontFamily a generic font name based on cssfontstack.com
* @param {Number} hri.fontSize the font size in pixels
* @param {Number} hri.marginTop the margin size in pixels between the barcode bottom and
* the hri text
*/

@@ -89,3 +93,5 @@ const bitgener = async function bitgener({

color,
opacity,
bgColor,
bgOpacity,
hri,

@@ -197,2 +203,9 @@ } = {}) {

// opacity
const opacityValue = num(opacity, { ge: 0, le: 1 });
if (exists(opacityValue)) {
settings.opacity = opacityValue;
}
// bgColor

@@ -203,2 +216,9 @@ if (isColor(bgColor)) {

// bgOpacity
const bgOpacityValue = num(bgOpacity, { ge: 0, le: 1 });
if (exists(bgOpacityValue)) {
settings.bgOpacity = bgOpacityValue;
}
// hri

@@ -205,0 +225,0 @@ if (is(Object, hri)) {

@@ -15,3 +15,5 @@ const defaults = {

color: '#000000',
opacity: 1,
bgColor: '#FFFFFF',
bgOpacity: 1,
hri: {

@@ -18,0 +20,0 @@ show: true,

{
"name": "bitgener",
"version": "1.1.5",
"version": "1.2.0",
"description": "A lightweight and zero-dependencies pure Node.js barcode library",

@@ -5,0 +5,0 @@ "author": "Adrien Valcke",

@@ -39,3 +39,3 @@ <p align="center">

*Bitgener* generates barcodes in pure SVG (Scalable Vector Graphics) format. The barcode generated can be a buffer, a readable stream, a string representing svg tags content or a file. It adds features as fixing final image width and height, keeping the original 1D/2D size, adding paddings and a generic font family for hri, adding stream, buffer and file outputs with a specific encoding.
*Bitgener* generates barcodes in pure SVG (Scalable Vector Graphics) format. The barcode generated can be a buffer, a readable stream, a string representing svg tags content or a file. It adds features like background and bars opacity, fixing final image width and height, keeping the original 1D/2D size, adding paddings and a generic font family for hri, adding stream, buffer and file outputs with a specific encoding.

@@ -125,4 +125,6 @@ SVGs generated by *Bitgener* uses crisp edges shape rendering to tell the user agent to turn off anti-aliasing to preserved the contrast, colors and edges without any smoothing or blurring that applies to images scaled up or down. Browsers support is nice and can be found here: https://caniuse.com/#feat=css-crisp-edges.

- `addQuietZone` **<Boolean\>** Add a quiet zone at the end of 1D barcodes. *Default*: `true`
- `color` **<String\>** The bars color. An hexadecimal value or one of these [generic names](lib/helpers/color.js). *Default*: `#000000`
- `color` **<String\>** The bars and hri color. An hexadecimal value or one of these [generic names](lib/helpers/color.js). *Default*: `#000000`
- `opacity` **<Number\>** The bars and hri opacity. *Min*: `0` *Max*: `1` *Default*: `1`
- `bgColor` **<String\>** The background color. An hexadecimal value or one of these [generic names](lib/helpers/color.js). *Default*: `#FFFFFF`
- `bgOpacity` **<Number\>** The background opacity. *Min*: `0` *Max*: `1` *Default*: `1`
- `hri` **<Object\>** The human readable interpretation of the encoded data.

@@ -218,3 +220,5 @@ - `show` **<Boolean\>** *Default*: `true`

color: '#FFFFFF',
opacity: 1,
bgColor: '#F7931A',
bgOpacity: 0.1,
hri: {

@@ -253,3 +257,5 @@ show: true,

color: '#FFFFFF',
opacity: 1,
bgColor: '#F7931A',
bgOpacity: 1,
hri: {

@@ -341,3 +347,5 @@ show: true,

color: '#FFFFFF',
opacity: 1,
bgColor: '#F7931A',
bgOpacity: 1,
hri: {

@@ -524,3 +532,3 @@ show: true,

Copyright (C) 2019 Adrien Valcke
Copyright (C) 2020 Adrien Valcke

@@ -527,0 +535,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc