tidepool 1.0.3 → 1.0.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../src/objects/box.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,qBAAa,GAAI,YAAW,UAAU;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;gBAEH,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,SAAU,EAAE,KAAK,SAAK,EAAE,MAAM,SAAI;IAWxG,UAAU,CAAC,OAAO,EAAE,UAAU;IAI9B,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;IAQxB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;IAoCvB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;CAI5B"}
1
+ {"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../src/objects/box.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,qBAAa,GAAI,YAAW,UAAU;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;gBAEH,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,SAAU,EAAE,KAAK,SAAK,EAAE,MAAM,SAAI;IAWxG,UAAU,CAAC,OAAO,EAAE,UAAU;IAI9B,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;IAWxB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;IAyCvB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;CAI9B"}
@@ -17,40 +17,45 @@ class Box {
17
17
  this.contents.push(content);
18
18
  }
19
19
  clear(screen) {
20
- for (let i = this.y; i < this.y + this.height; i++) {
21
- for (let j = this.x; j < this.x + this.width; j++) {
20
+ const maxY = Math.min(this.y + this.height, screen.length);
21
+ const maxX = Math.min(this.x + this.width, screen[0].length);
22
+ for (let i = this.y; i < maxY; i++) {
23
+ for (let j = this.x; j < maxX; j++) {
22
24
  screen[i][j] = ' ';
23
25
  }
24
26
  }
25
27
  }
26
28
  draw(screen) {
29
+ const maxY = Math.min(this.y + this.height, screen.length);
30
+ const maxX = Math.min(this.x + this.width, screen[0].length);
31
+ if (this.x >= screen[0].length || this.y >= screen.length || maxY <= this.y || maxX <= this.x) {
32
+ return;
33
+ }
27
34
  this.clear(screen);
28
35
  const colorCode = (0, util_1.getColorCode)(this.color);
29
36
  const titleColorCode = (0, util_1.getColorCode)('magenta');
30
- for (let i = this.x + 1; i < this.x + this.width - 1; i++) {
37
+ for (let i = this.x + 1; i < maxX - 1; i++) {
31
38
  screen[this.y][i] = `${colorCode}─\x1b[0m`;
32
39
  }
33
- for (let i = this.x + 1; i < this.x + this.width - 1; i++) {
34
- screen[this.y + this.height - 1][i] = `${colorCode}─\x1b[0m`;
40
+ for (let i = this.x + 1; i < maxX - 1; i++) {
41
+ screen[maxY - 1][i] = `${colorCode}─\x1b[0m`;
35
42
  }
36
- for (let i = this.y + 1; i < this.y + this.height - 1; i++) {
43
+ for (let i = this.y + 1; i < maxY - 1; i++) {
37
44
  screen[i][this.x] = `${colorCode}│\x1b[0m`;
38
- screen[i][this.x + this.width - 1] = `${colorCode}│\x1b[0m`;
45
+ screen[i][maxX - 1] = `${colorCode}│\x1b[0m`;
39
46
  }
40
47
  screen[this.y][this.x] = `${colorCode}┌\x1b[0m`;
41
- screen[this.y][this.x + this.width - 1] = `${colorCode}┐\x1b[0m`;
42
- screen[this.y + this.height - 1][this.x] = `${colorCode}└\x1b[0m`;
43
- screen[this.y + this.height - 1][this.x + this.width - 1] = `${colorCode}┘\x1b[0m`;
48
+ screen[this.y][maxX - 1] = `${colorCode}┐\x1b[0m`;
49
+ screen[maxY - 1][this.x] = `${colorCode}└\x1b[0m`;
50
+ screen[maxY - 1][maxX - 1] = `${colorCode}┘\x1b[0m`;
44
51
  if (this.title) {
45
- const titlePosition = Math.max(this.x + 2, Math.min(this.x + this.width - 2 - this.title.length, this.x + 2));
46
- for (let i = 0; i < this.title.length; i++) {
47
- if (titlePosition + i < screen[0].length && this.y < screen.length) {
48
- screen[this.y][titlePosition + i] = `${titleColorCode}${this.title[i]}\x1b[0m`;
49
- }
52
+ const titlePosition = Math.max(this.x + 2, Math.min(maxX - 2 - this.title.length, this.x + 2));
53
+ for (let i = 0; i < this.title.length && titlePosition + i < maxX; i++) {
54
+ screen[this.y][titlePosition + i] = `${titleColorCode}${this.title[i]}\x1b[0m`;
50
55
  }
51
56
  }
52
57
  for (const content of this.contents) {
53
- content.draw(screen, this.x + 1, this.y + 1, this.width - 2);
58
+ content.draw(screen, this.x + 1, this.y + 1, maxX - this.x - 2);
54
59
  }
55
60
  }
56
61
  move(dx, dy) {
@@ -1 +1 @@
1
- {"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,UAA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C,SAAS,EAAE,UAAU;IAIlC,OAAO,CAAC,sBAAsB;IAiB9B,OAAO,CAAC,YAAY;IAMpB,oBAAoB;IAUpB,OAAO,CAAC,MAAM;IAOd,iBAAiB,CAAC,EAAE,EAAE,MAAM,IAAI;IAIhC,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB,SAAS;IAQT,WAAW;CAkBd"}
package/dist/screen.js CHANGED
@@ -32,6 +32,7 @@ class TideScreen {
32
32
  cyan: '\x1b[46m',
33
33
  white: '\x1b[47m',
34
34
  transparent: '\x1b[49m',
35
+ random: '\x1b[48;5;' + Math.floor(Math.random() * 256) + 'm',
35
36
  };
36
37
  return colors[color.toLowerCase()] || colors['black'];
37
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,UAczC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,YAetD"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,UAezC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,YAetD"}
package/dist/util.js CHANGED
@@ -13,6 +13,7 @@ function getColorCode(color) {
13
13
  magenta: '\x1b[35m',
14
14
  cyan: '\x1b[36m',
15
15
  white: '\x1b[37m',
16
+ random: '\x1b[38;5;' + Math.floor(Math.random() * 256) + 'm',
16
17
  };
17
18
  return colors[color.toLowerCase()] || colors['reset'];
18
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tidepool",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "author": "stuncs69",
5
5
  "main": "dist/index.js",
6
6
  "devDependencies": {