Skip to content

Commit

Permalink
Merge branch 'master' into feature/2-pattern-marker-generator
Browse files Browse the repository at this point in the history
# Conflicts:
#	index.js
#	test/matrix-generator/index.js
#	test/pattern-marker-generator/index.js
  • Loading branch information
le0m committed Jan 18, 2020
2 parents ea32568 + 79eebc3 commit e3bac5b
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 56 deletions.
8 changes: 8 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// as default, NFT is disabled for everyone
export default {
MODULES: {
NFT: process.env.NFT && './src/modules/nft/index.js',
MARKER: process.env.MARKER && './src/modules/marker/index.js',
LOCATION: process.env.LOCATION && './src/modules/location/index.js',
},
};
23 changes: 14 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { BarcodeMarkerGenerator } from './src/tools/markers/barcode-marker-generator';
import { PatternMarkerGenerator } from './src/tools/markers/pattern-marker-generator';
import MODULES from './config';

export class StudioBackend {
static getBarcodeMarkerSVGDataURI(matrixTypeId, value) {
return new BarcodeMarkerGenerator(matrixTypeId, value).asSVGDataURI();
}
const promises = [];

static async getMarkerPattern(dataURI) {
return await new PatternMarkerGenerator(dataURI).toPattern();
Object.keys(MODULES).forEach((module) => {
if (MODULES[module]) {
promises.push(import(MODULES[module]));
}
}
});

Promise.all(promises)
.then(() => {
console.log('All AR Modules have been loaded');
})
.catch((err) => {
console.error('Error in loading AR Modules', err);
});
1 change: 1 addition & 0 deletions src/modules/location/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class LocationModule {}
8 changes: 8 additions & 0 deletions src/modules/marker/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { BarcodeMarkerGenerator } from './tools/barcode-marker-generator';
import { PatternMarkerGenerator } from './src/modules/marker/tools/pattern-marker-generator';

export class MarkerModule {
static getBarcodeMarkerSVGDataURI(matrixTypeId, value) {
return new BarcodeMarkerGenerator(matrixTypeId, value).asSVGDataURI();
}
}
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions src/modules/nft/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export class NFTModule {
}
92 changes: 46 additions & 46 deletions test/matrix-generator/index.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
import { expect } from 'chai';
import * as encoders from '../../src/tools/markers/matrix-encoders';
import {expect} from 'chai';
import * as encoders from '../../src/modules/marker/tools/matrix-encoders';
import codewords from './codewords.json';

function bitStringToBitArray(str) {
return str.split('').map(c => (c == '1' ? true : false));
return str.split('').map(c => (c == '1' ? true : false));
}

describe('matrix-generator', function () {
it('correctly encodes 3x3_hamming_6_3', function () {
for (let i = 0; i < codewords.hamming_6_3.length; ++i) {
expect(encoders.encode_3x3_hamming_6_3(i)).to.eql(
bitStringToBitArray(codewords.hamming_6_3[i]),
);
}
});
describe('matrix-generator', function() {
it('correctly encodes 3x3_hamming_6_3', function() {
for (let i = 0; i < codewords.hamming_6_3.length; ++i) {
expect(encoders.encode_3x3_hamming_6_3(i)).to.eql(
bitStringToBitArray(codewords.hamming_6_3[i]),
);
}
});

it('correctly encodes 3x3_parity_6_5', function () {
for (let i = 0; i < codewords.parity_6_5.length; ++i) {
expect(encoders.encode_3x3_parity_6_5(i)).to.eql(
bitStringToBitArray(codewords.parity_6_5[i]),
);
}
});
it('correctly encodes 3x3_parity_6_5', function() {
for (let i = 0; i < codewords.parity_6_5.length; ++i) {
expect(encoders.encode_3x3_parity_6_5(i)).to.eql(
bitStringToBitArray(codewords.parity_6_5[i]),
);
}
});

it('correctly encodes 4x4_bch_13_5_5', function () {
for (let i = 0; i < codewords.bch_13_5_5.length; ++i) {
expect(encoders.encode_4x4_bch_13_5_5(i)).to.eql(
bitStringToBitArray(codewords.bch_13_5_5[i]),
);
}
});
it('correctly encodes 4x4_bch_13_5_5', function() {
for (let i = 0; i < codewords.bch_13_5_5.length; ++i) {
expect(encoders.encode_4x4_bch_13_5_5(i)).to.eql(
bitStringToBitArray(codewords.bch_13_5_5[i]),
);
}
});

it('correctly encodes 4x4_bch_13_9_3', function () {
for (let i = 0; i < codewords.bch_13_9_3.length; ++i) {
expect(encoders.encode_4x4_bch_13_9_3(i)).to.eql(
bitStringToBitArray(codewords.bch_13_9_3[i]),
);
}
});
it('correctly encodes 4x4_bch_13_9_3', function() {
for (let i = 0; i < codewords.bch_13_9_3.length; ++i) {
expect(encoders.encode_4x4_bch_13_9_3(i)).to.eql(
bitStringToBitArray(codewords.bch_13_9_3[i]),
);
}
});

it('correctly encodes 5x5_bch_22_7_7', function () {
for (let i = 0; i < codewords.bch_22_7_7.length; ++i) {
expect(encoders.encode_5x5_bch_22_7_7(i)).to.eql(
bitStringToBitArray(codewords.bch_22_7_7[i]),
);
}
});
it('correctly encodes 5x5_bch_22_7_7', function() {
for (let i = 0; i < codewords.bch_22_7_7.length; ++i) {
expect(encoders.encode_5x5_bch_22_7_7(i)).to.eql(
bitStringToBitArray(codewords.bch_22_7_7[i]),
);
}
});

it('correctly encodes 5x5_bch_22_12_5', function () {
for (let i = 0; i < codewords.bch_22_12_5.length; ++i) {
expect(encoders.encode_5x5_bch_22_12_5(i)).to.eql(
bitStringToBitArray(codewords.bch_22_12_5[i]),
);
}
});
it('correctly encodes 5x5_bch_22_12_5', function() {
for (let i = 0; i < codewords.bch_22_12_5.length; ++i) {
expect(encoders.encode_5x5_bch_22_12_5(i)).to.eql(
bitStringToBitArray(codewords.bch_22_12_5[i]),
);
}
});
});
2 changes: 1 addition & 1 deletion test/pattern-marker-generator/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import * as generator from '../../src/tools/markers/pattern-marker-generator.js';
import * as generator from '../../src/modules/marker/tools/pattern-marker-generator.js';

describe('pattern-marker-generator', function () {
it('correctly generates pattern marker', function () {
Expand Down

0 comments on commit e3bac5b

Please sign in to comment.