-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/2-pattern-marker-generator
# Conflicts: # index.js # test/matrix-generator/index.js # test/pattern-marker-generator/index.js
- Loading branch information
Showing
11 changed files
with
80 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export class LocationModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export class NFTModule { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]), | ||
); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters