@jamesrock/rockjs 1.19.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +9 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -334,10 +334,11 @@ export class GameBase extends DisplayObject {
334
334
  export class BrickMaker extends DisplayObject {
335
335
  constructor({
336
336
  size = 4,
337
- type = 'digits',
337
+ type = 'binary',
338
338
  color = 'red',
339
339
  scale = 30,
340
- gap = 1
340
+ gap = 1,
341
+ prefix = '0x'
341
342
  } = {}) {
342
343
 
343
344
  super();
@@ -347,10 +348,11 @@ export class BrickMaker extends DisplayObject {
347
348
  this.scale = scale;
348
349
  this.type = type;
349
350
  this.gap = gap;
351
+ this.prefix = prefix;
350
352
  this.hexMap = size*size > 16 ? makeHexMap() : makeHexMap(false);
351
353
  this.typeValues = {
352
- 'digits': makeArray(size*size, () => 1),
353
- 'binary': makeBitArray(size)
354
+ 'binary': makeArray(size*size, () => 1),
355
+ 'hex': makeBitArray(size)
354
356
  };
355
357
 
356
358
  const node = this.node = createNode('div', 'brick-maker');
@@ -386,7 +388,7 @@ export class BrickMaker extends DisplayObject {
386
388
 
387
389
  let total = null;
388
390
  switch(this.type) {
389
- case 'digits':
391
+ case 'binary':
390
392
  total = makeArray(this.size*this.size, () => 0);
391
393
  this.bits.forEach((bit, i) => {
392
394
  if(bit.dataset.active==='Y') {
@@ -395,7 +397,7 @@ export class BrickMaker extends DisplayObject {
395
397
  });
396
398
  this.value = JSON.stringify(total);
397
399
  break;
398
- case 'binary':
400
+ case 'hex':
399
401
  total = makeArray(this.size, () => 0);
400
402
  makeArray(this.size).forEach((y) => {
401
403
  this.bits.filter((bit) => bit.dataset.y == y).forEach((bit) => {
@@ -405,7 +407,7 @@ export class BrickMaker extends DisplayObject {
405
407
  });
406
408
  total[y] = this.hexMap[total[y]];
407
409
  });
408
- this.value = `0x${total.join('')}`;
410
+ this.value = `${this.prefix}${total.join('')}`;
409
411
  break;
410
412
  };
411
413
  this.dispatchEvent('result');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamesrock/rockjs",
3
- "version": "1.19.0",
3
+ "version": "1.21.0",
4
4
  "description": "utility bliss",
5
5
  "license": "ISC",
6
6
  "author": "James Rock",