@operato/scene-mpi 1.3.7

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 (125) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +31 -0
  3. package/assets/favicon.ico +0 -0
  4. package/assets/images/spinner.png +0 -0
  5. package/dist/auto-clicker.d.ts +10 -0
  6. package/dist/auto-clicker.js +84 -0
  7. package/dist/auto-clicker.js.map +1 -0
  8. package/dist/boot-button.d.ts +20 -0
  9. package/dist/boot-button.js +90 -0
  10. package/dist/boot-button.js.map +1 -0
  11. package/dist/gateway-on-button.d.ts +7 -0
  12. package/dist/gateway-on-button.js +88 -0
  13. package/dist/gateway-on-button.js.map +1 -0
  14. package/dist/gateway-on-message.d.ts +3 -0
  15. package/dist/gateway-on-message.js +375 -0
  16. package/dist/gateway-on-message.js.map +1 -0
  17. package/dist/gateway.d.ts +58 -0
  18. package/dist/gateway.js +396 -0
  19. package/dist/gateway.js.map +1 -0
  20. package/dist/index.d.ts +5 -0
  21. package/dist/index.js +7 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/indicator-on-message.d.ts +2 -0
  24. package/dist/indicator-on-message.js +5 -0
  25. package/dist/indicator-on-message.js.map +1 -0
  26. package/dist/indicator-user-action.d.ts +5 -0
  27. package/dist/indicator-user-action.js +263 -0
  28. package/dist/indicator-user-action.js.map +1 -0
  29. package/dist/indicator.d.ts +83 -0
  30. package/dist/indicator.js +544 -0
  31. package/dist/indicator.js.map +1 -0
  32. package/dist/reply-button.d.ts +20 -0
  33. package/dist/reply-button.js +67 -0
  34. package/dist/reply-button.js.map +1 -0
  35. package/dist/segment-display.d.ts +41 -0
  36. package/dist/segment-display.js +521 -0
  37. package/dist/segment-display.js.map +1 -0
  38. package/dist/seven-segment.d.ts +7 -0
  39. package/dist/seven-segment.js +137 -0
  40. package/dist/seven-segment.js.map +1 -0
  41. package/dist/templates/auto-clicker.d.ts +17 -0
  42. package/dist/templates/auto-clicker.js +19 -0
  43. package/dist/templates/auto-clicker.js.map +1 -0
  44. package/dist/templates/boot-button.d.ts +16 -0
  45. package/dist/templates/boot-button.js +18 -0
  46. package/dist/templates/boot-button.js.map +1 -0
  47. package/dist/templates/gateway.d.ts +16 -0
  48. package/dist/templates/gateway.js +18 -0
  49. package/dist/templates/gateway.js.map +1 -0
  50. package/dist/templates/index.d.ts +16 -0
  51. package/dist/templates/index.js +15 -0
  52. package/dist/templates/index.js.map +1 -0
  53. package/dist/templates/indicator.d.ts +16 -0
  54. package/dist/templates/indicator.js +18 -0
  55. package/dist/templates/indicator.js.map +1 -0
  56. package/dist/templates/reply-button.d.ts +16 -0
  57. package/dist/templates/reply-button.js +18 -0
  58. package/dist/templates/reply-button.js.map +1 -0
  59. package/dist/templates/seven-segment.d.ts +28 -0
  60. package/dist/templates/seven-segment.js +30 -0
  61. package/dist/templates/seven-segment.js.map +1 -0
  62. package/dist/uuid.d.ts +1 -0
  63. package/dist/uuid.js +21 -0
  64. package/dist/uuid.js.map +1 -0
  65. package/helps/scene/component/auto-clicker.ko.md +3 -0
  66. package/helps/scene/component/auto-clicker.md +3 -0
  67. package/helps/scene/component/auto-clicker.zh.md +3 -0
  68. package/helps/scene/component/boot-button.ko.md +3 -0
  69. package/helps/scene/component/boot-button.md +3 -0
  70. package/helps/scene/component/boot-button.zh.md +3 -0
  71. package/helps/scene/component/gateway.ko.md +3 -0
  72. package/helps/scene/component/gateway.md +3 -0
  73. package/helps/scene/component/gateway.zh.md +3 -0
  74. package/helps/scene/component/indicator.ko.md +3 -0
  75. package/helps/scene/component/indicator.md +3 -0
  76. package/helps/scene/component/indicator.zh.md +3 -0
  77. package/helps/scene/component/reply-button.ko.md +3 -0
  78. package/helps/scene/component/reply-button.md +3 -0
  79. package/helps/scene/component/reply-button.zh.md +3 -0
  80. package/helps/scene/component/seven-segment.ko.md +3 -0
  81. package/helps/scene/component/seven-segment.md +3 -0
  82. package/helps/scene/component/seven-segment.zh.md +3 -0
  83. package/icons/boot-button.png +0 -0
  84. package/icons/button-error.png +0 -0
  85. package/icons/button-start.png +0 -0
  86. package/icons/button-status.png +0 -0
  87. package/icons/button-stop.png +0 -0
  88. package/icons/gateway.png +0 -0
  89. package/icons/icon-boot-button.png +0 -0
  90. package/icons/icon-gateway.png +0 -0
  91. package/icons/icon-indicator.png +0 -0
  92. package/icons/icon-reply-button.png +0 -0
  93. package/icons/icon-seven-segment.png +0 -0
  94. package/icons/indicator.png +0 -0
  95. package/icons/no-image.png +0 -0
  96. package/icons/reply-button.png +0 -0
  97. package/package.json +61 -0
  98. package/src/auto-clicker.ts +97 -0
  99. package/src/boot-button.ts +112 -0
  100. package/src/gateway-on-button.ts +97 -0
  101. package/src/gateway-on-message.ts +405 -0
  102. package/src/gateway.ts +484 -0
  103. package/src/index.ts +6 -0
  104. package/src/indicator-on-message.ts +6 -0
  105. package/src/indicator-user-action.ts +292 -0
  106. package/src/indicator.ts +638 -0
  107. package/src/reply-button.ts +88 -0
  108. package/src/segment-display.ts +608 -0
  109. package/src/seven-segment.ts +162 -0
  110. package/src/templates/auto-clicker.ts +19 -0
  111. package/src/templates/boot-button.ts +18 -0
  112. package/src/templates/gateway.ts +18 -0
  113. package/src/templates/index.ts +15 -0
  114. package/src/templates/indicator.ts +18 -0
  115. package/src/templates/reply-button.ts +18 -0
  116. package/src/templates/seven-segment.ts +30 -0
  117. package/src/uuid.ts +20 -0
  118. package/things-scene.config.js +5 -0
  119. package/translations/en.json +26 -0
  120. package/translations/ja.json +26 -0
  121. package/translations/ko.json +26 -0
  122. package/translations/ms.json +23 -0
  123. package/translations/zh.json +23 -0
  124. package/tsconfig.json +22 -0
  125. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,67 @@
1
+ const reply = new URL('../../icons/reply-button.png', import.meta.url).href;
2
+ import { Component, RectPath, Shape } from '@hatiolab/things-scene';
3
+ import { consoleLogger } from './gateway-on-message';
4
+ export const buttons = [
5
+ {
6
+ icon: reply,
7
+ handler: onClickReply
8
+ }
9
+ ];
10
+ const NATURE = {
11
+ mutable: false,
12
+ resizable: true,
13
+ rotatable: true,
14
+ properties: [
15
+ {
16
+ type: 'string',
17
+ name: 'publisher',
18
+ label: 'publisher'
19
+ }
20
+ ],
21
+ help: 'scene/component/reply-button'
22
+ };
23
+ export default class ReplyButton extends RectPath(Shape) {
24
+ static get image() {
25
+ if (!ReplyButton._image) {
26
+ ReplyButton._image = new Image();
27
+ ReplyButton._image.src = reply;
28
+ }
29
+ return ReplyButton._image;
30
+ }
31
+ get publisher() {
32
+ if (this.state.publisher) {
33
+ return this.root.findById(this.state.publisher);
34
+ }
35
+ }
36
+ render(context) {
37
+ var { left, top, width, height } = this.bounds;
38
+ context.beginPath();
39
+ context.rect(left, top, width, height);
40
+ this.drawFill(context);
41
+ this.drawStroke(context);
42
+ this.drawImage(context, ReplyButton.image, left, top, width, height);
43
+ }
44
+ onmousedown(e, hint) {
45
+ var button = this.buttonContains();
46
+ if (button) {
47
+ button.handler(this);
48
+ }
49
+ }
50
+ buttonContains() {
51
+ return buttons[0];
52
+ }
53
+ get nature() {
54
+ return NATURE;
55
+ }
56
+ }
57
+ function onClickReply(button) {
58
+ consoleLogger('onClickReply');
59
+ var gateways = button.root.findAll('gateway');
60
+ gateways.forEach((gw, index) => {
61
+ gw.indicators.forEach(ind => {
62
+ ind.onButton();
63
+ });
64
+ });
65
+ }
66
+ Component.register('reply-button', ReplyButton);
67
+ //# sourceMappingURL=reply-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reply-button.js","sourceRoot":"","sources":["../src/reply-button.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,8BAA8B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AAE3E,OAAO,EAAE,SAAS,EAAmB,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEpF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGpD,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;QACE,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,YAAY;KACtB;CACF,CAAA;AAED,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,WAAW;SACnB;KACF;IACD,IAAI,EAAE,8BAA8B;CACrC,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,QAAQ,CAAC,KAAK,CAAC;IAGtD,MAAM,KAAK,KAAK;QACd,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;YACxB,WAAW,CAAC,MAAM,GAAG,IAAI,KAAK,EAAE,CAAA;YAChC,WAAW,CAAC,MAAM,CAAC,GAAG,GAAG,KAAK,CAAA;QAChC,CAAC;QAED,OAAO,WAAW,CAAC,MAAM,CAAA;IAC3B,CAAC;IAED,IAAI,SAAS;QACX,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QACjD,CAAC;IACH,CAAC;IAED,MAAM,CAAC,OAAiC;QACtC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QAE9C,OAAO,CAAC,SAAS,EAAE,CAAA;QAEnB,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;QAEtC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QACtB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QAExB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IACtE,CAAC;IAED,WAAW,CAAC,CAAa,EAAE,IAAS;QAClC,IAAI,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;QAClC,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;IAED,cAAc;QACZ,OAAO,OAAO,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,YAAY,CAAC,MAAiB;IACrC,aAAa,CAAC,cAAc,CAAC,CAAA;IAE7B,IAAI,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAc,CAAA;IAE1D,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;QAC7B,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1B,GAAG,CAAC,QAAQ,EAAE,CAAA;QAChB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA","sourcesContent":["const reply = new URL('../../icons/reply-button.png', import.meta.url).href\n\nimport { Component, ComponentNature, RectPath, Shape } from '@hatiolab/things-scene'\n\nimport { consoleLogger } from './gateway-on-message'\nimport Gateway from './gateway'\n\nexport const buttons = [\n {\n icon: reply,\n handler: onClickReply\n }\n]\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'string',\n name: 'publisher',\n label: 'publisher'\n }\n ],\n help: 'scene/component/reply-button'\n}\n\nexport default class ReplyButton extends RectPath(Shape) {\n static _image?: HTMLImageElement\n\n static get image() {\n if (!ReplyButton._image) {\n ReplyButton._image = new Image()\n ReplyButton._image.src = reply\n }\n\n return ReplyButton._image\n }\n\n get publisher() {\n if (this.state.publisher) {\n return this.root.findById(this.state.publisher)\n }\n }\n\n render(context: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n\n context.beginPath()\n\n context.rect(left, top, width, height)\n\n this.drawFill(context)\n this.drawStroke(context)\n\n this.drawImage(context, ReplyButton.image, left, top, width, height)\n }\n\n onmousedown(e: MouseEvent, hint: any) {\n var button = this.buttonContains()\n if (button) {\n button.handler(this)\n }\n }\n\n buttonContains() {\n return buttons[0]\n }\n\n get nature() {\n return NATURE\n }\n}\n\nfunction onClickReply(button: Component) {\n consoleLogger('onClickReply')\n\n var gateways = button.root.findAll('gateway') as Gateway[]\n\n gateways.forEach((gw, index) => {\n gw.indicators.forEach(ind => {\n ind.onButton()\n })\n })\n}\n\nComponent.register('reply-button', ReplyButton)\n"]}
@@ -0,0 +1,41 @@
1
+ /*!
2
+ * segment-display.js
3
+ *
4
+ * Copyright 2012, Rüdiger Appel
5
+ * http://www.3quarks.com
6
+ * Published under Creative Commons 3.0 License.
7
+ *
8
+ * Date: 2012-02-14
9
+ * Version: 1.0.0
10
+ *
11
+ * Dokumentation: http://www.3quarks.com/de/Segmentanzeige
12
+ * Documentation: http://www.3quarks.com/en/SegmentDisplay
13
+ */
14
+ export default class SegmentDisplay {
15
+ static SevenSegment: number;
16
+ static FourteenSegment: number;
17
+ static SixteenSegment: number;
18
+ static SymmetricCorner: number;
19
+ static SquaredCorner: number;
20
+ static RoundedCorner: number;
21
+ width: number;
22
+ height: number;
23
+ pattern: string;
24
+ value: string;
25
+ digitHeight: number;
26
+ digitWidth: number;
27
+ digitDistance: number;
28
+ displayAngle: number;
29
+ segmentWidth: number;
30
+ segmentDistance: number;
31
+ segmentCount: number;
32
+ cornerType: number;
33
+ colorOn: string;
34
+ colorOff: string;
35
+ constructor(width: number, height: number);
36
+ setValue(value: any): void;
37
+ draw(context: CanvasRenderingContext2D): void;
38
+ drawDigit(context: CanvasRenderingContext2D, xPos: number, mask: string, c: string): number;
39
+ drawPoint(context: CanvasRenderingContext2D, x1: number, y1: number, size: number): void;
40
+ getSegmentColor(c: string, charSet7: string | null, charSet14?: string, charSet16?: string): string;
41
+ }
@@ -0,0 +1,521 @@
1
+ /*!
2
+ * segment-display.js
3
+ *
4
+ * Copyright 2012, Rüdiger Appel
5
+ * http://www.3quarks.com
6
+ * Published under Creative Commons 3.0 License.
7
+ *
8
+ * Date: 2012-02-14
9
+ * Version: 1.0.0
10
+ *
11
+ * Dokumentation: http://www.3quarks.com/de/Segmentanzeige
12
+ * Documentation: http://www.3quarks.com/en/SegmentDisplay
13
+ */
14
+ class SegmentDisplay {
15
+ constructor(width, height) {
16
+ this.width = width;
17
+ this.height = height;
18
+ this.pattern = '##:##:##';
19
+ this.value = '12:34:56';
20
+ this.digitHeight = 20;
21
+ this.digitWidth = 10;
22
+ this.digitDistance = 2.5;
23
+ this.displayAngle = 12;
24
+ this.segmentWidth = 2.5;
25
+ this.segmentDistance = 0.2;
26
+ this.segmentCount = SegmentDisplay.SevenSegment;
27
+ this.cornerType = SegmentDisplay.RoundedCorner;
28
+ this.colorOn = 'rgb(233, 93, 15)';
29
+ this.colorOff = 'rgb(75, 30, 5)';
30
+ }
31
+ setValue(value) {
32
+ this.value = value;
33
+ }
34
+ draw(context) {
35
+ // compute and check display width
36
+ var width = 0;
37
+ var first = true;
38
+ if (this.pattern) {
39
+ for (var i = 0; i < this.pattern.length; i++) {
40
+ var c = this.pattern.charAt(i).toLowerCase();
41
+ if (c == '#') {
42
+ width += this.digitWidth;
43
+ }
44
+ else if (c == '.' || c == ':') {
45
+ width += this.segmentWidth;
46
+ }
47
+ else if (c != ' ') {
48
+ return;
49
+ }
50
+ width += first ? 0 : this.digitDistance;
51
+ first = false;
52
+ }
53
+ }
54
+ if (width <= 0) {
55
+ return;
56
+ }
57
+ // compute skew factor
58
+ var angle = -1.0 * Math.max(-45.0, Math.min(45.0, this.displayAngle));
59
+ var skew = Math.tan((angle * Math.PI) / 180.0);
60
+ // compute scale factor
61
+ var scale = Math.min(this.width / (width + Math.abs(skew * this.digitHeight)), this.height / this.digitHeight);
62
+ // compute display offset
63
+ var offsetX = (this.width - (width + skew * this.digitHeight) * scale) / 2.0;
64
+ var offsetY = (this.height - this.digitHeight * scale) / 2.0;
65
+ // context transformation
66
+ context.save();
67
+ context.translate(offsetX, offsetY);
68
+ context.scale(scale, scale);
69
+ context.transform(1, 0, skew, 1, 0, 0);
70
+ // draw segments
71
+ var xPos = 0;
72
+ var size = this.value ? this.value.length : 0;
73
+ for (var i = 0; i < this.pattern.length; i++) {
74
+ var mask = this.pattern.charAt(i);
75
+ var value = i < size ? this.value.charAt(i).toLowerCase() : ' ';
76
+ xPos += this.drawDigit(context, xPos, mask, value);
77
+ }
78
+ // finish drawing
79
+ context.restore();
80
+ }
81
+ drawDigit(context, xPos, mask, c) {
82
+ switch (mask) {
83
+ case '#':
84
+ var r = Math.sqrt((this.segmentWidth * this.segmentWidth) / 2.0);
85
+ var d = Math.sqrt((this.segmentDistance * this.segmentDistance) / 2.0);
86
+ var e = d / 2.0;
87
+ var f = (this.segmentWidth - d) * Math.sin((45.0 * Math.PI) / 180.0);
88
+ var g = f / 2.0;
89
+ var h = (this.digitHeight - 3.0 * this.segmentWidth) / 2.0;
90
+ var w = (this.digitWidth - 3.0 * this.segmentWidth) / 2.0;
91
+ var s = this.segmentWidth / 2.0;
92
+ var t = this.digitWidth / 2.0;
93
+ // draw segment a (a1 and a2 for 16 segments)
94
+ if (this.segmentCount == 16) {
95
+ var x = xPos;
96
+ var y = 0;
97
+ context.fillStyle = this.getSegmentColor(c, null, '02356789abcdefgiopqrstz@%');
98
+ context.beginPath();
99
+ switch (this.cornerType) {
100
+ case SegmentDisplay.SymmetricCorner:
101
+ context.moveTo(x + s + d, y + s);
102
+ context.lineTo(x + this.segmentWidth + d, y);
103
+ break;
104
+ case SegmentDisplay.SquaredCorner:
105
+ context.moveTo(x + s + e, y + s - e);
106
+ context.lineTo(x + this.segmentWidth, y);
107
+ break;
108
+ default:
109
+ context.moveTo(x + this.segmentWidth - f, y + this.segmentWidth - f - d);
110
+ context.quadraticCurveTo(x + this.segmentWidth - g, y, x + this.segmentWidth, y);
111
+ }
112
+ context.lineTo(x + t - d - s, y);
113
+ context.lineTo(x + t - d, y + s);
114
+ context.lineTo(x + t - d - s, y + this.segmentWidth);
115
+ context.lineTo(x + this.segmentWidth + d, y + this.segmentWidth);
116
+ context.fill();
117
+ var x = xPos;
118
+ var y = 0;
119
+ context.fillStyle = this.getSegmentColor(c, null, '02356789abcdefgiopqrstz@');
120
+ context.beginPath();
121
+ context.moveTo(x + this.digitWidth - this.segmentWidth - d, y + this.segmentWidth);
122
+ context.lineTo(x + t + d + s, y + this.segmentWidth);
123
+ context.lineTo(x + t + d, y + s);
124
+ context.lineTo(x + t + d + s, y);
125
+ switch (this.cornerType) {
126
+ case SegmentDisplay.SymmetricCorner:
127
+ context.lineTo(x + this.digitWidth - this.segmentWidth - d, y);
128
+ context.lineTo(x + this.digitWidth - s - d, y + s);
129
+ break;
130
+ case SegmentDisplay.SquaredCorner:
131
+ context.lineTo(x + this.digitWidth - this.segmentWidth, y);
132
+ context.lineTo(x + this.digitWidth - s - e, y + s - e);
133
+ break;
134
+ default:
135
+ context.lineTo(x + this.digitWidth - this.segmentWidth, y);
136
+ context.quadraticCurveTo(x + this.digitWidth - this.segmentWidth + g, y, x + this.digitWidth - this.segmentWidth + f, y + this.segmentWidth - f - d);
137
+ }
138
+ context.fill();
139
+ }
140
+ else {
141
+ var x = xPos;
142
+ var y = 0;
143
+ context.fillStyle = this.getSegmentColor(c, '02356789acefp', '02356789abcdefgiopqrstz@');
144
+ context.beginPath();
145
+ switch (this.cornerType) {
146
+ case SegmentDisplay.SymmetricCorner:
147
+ context.moveTo(x + s + d, y + s);
148
+ context.lineTo(x + this.segmentWidth + d, y);
149
+ context.lineTo(x + this.digitWidth - this.segmentWidth - d, y);
150
+ context.lineTo(x + this.digitWidth - s - d, y + s);
151
+ break;
152
+ case SegmentDisplay.SquaredCorner:
153
+ context.moveTo(x + s + e, y + s - e);
154
+ context.lineTo(x + this.segmentWidth, y);
155
+ context.lineTo(x + this.digitWidth - this.segmentWidth, y);
156
+ context.lineTo(x + this.digitWidth - s - e, y + s - e);
157
+ break;
158
+ default:
159
+ context.moveTo(x + this.segmentWidth - f, y + this.segmentWidth - f - d);
160
+ context.quadraticCurveTo(x + this.segmentWidth - g, y, x + this.segmentWidth, y);
161
+ context.lineTo(x + this.digitWidth - this.segmentWidth, y);
162
+ context.quadraticCurveTo(x + this.digitWidth - this.segmentWidth + g, y, x + this.digitWidth - this.segmentWidth + f, y + this.segmentWidth - f - d);
163
+ }
164
+ context.lineTo(x + this.digitWidth - this.segmentWidth - d, y + this.segmentWidth);
165
+ context.lineTo(x + this.segmentWidth + d, y + this.segmentWidth);
166
+ context.fill();
167
+ }
168
+ // draw segment b
169
+ x = xPos + this.digitWidth - this.segmentWidth;
170
+ y = 0;
171
+ context.fillStyle = this.getSegmentColor(c, '01234789adhpy', '01234789abdhjmnopqruwy');
172
+ context.beginPath();
173
+ switch (this.cornerType) {
174
+ case SegmentDisplay.SymmetricCorner:
175
+ context.moveTo(x + s, y + s + d);
176
+ context.lineTo(x + this.segmentWidth, y + this.segmentWidth + d);
177
+ break;
178
+ case SegmentDisplay.SquaredCorner:
179
+ context.moveTo(x + s + e, y + s + e);
180
+ context.lineTo(x + this.segmentWidth, y + this.segmentWidth);
181
+ break;
182
+ default:
183
+ context.moveTo(x + f + d, y + this.segmentWidth - f);
184
+ context.quadraticCurveTo(x + this.segmentWidth, y + this.segmentWidth - g, x + this.segmentWidth, y + this.segmentWidth);
185
+ }
186
+ context.lineTo(x + this.segmentWidth, y + h + this.segmentWidth - d);
187
+ context.lineTo(x + s, y + h + this.segmentWidth + s - d);
188
+ context.lineTo(x, y + h + this.segmentWidth - d);
189
+ context.lineTo(x, y + this.segmentWidth + d);
190
+ context.fill();
191
+ // draw segment c
192
+ x = xPos + this.digitWidth - this.segmentWidth;
193
+ y = h + this.segmentWidth;
194
+ context.fillStyle = this.getSegmentColor(c, '013456789abdhnouy', '01346789abdghjmnoqsuw@', '%');
195
+ context.beginPath();
196
+ context.moveTo(x, y + this.segmentWidth + d);
197
+ context.lineTo(x + s, y + s + d);
198
+ context.lineTo(x + this.segmentWidth, y + this.segmentWidth + d);
199
+ context.lineTo(x + this.segmentWidth, y + h + this.segmentWidth - d);
200
+ switch (this.cornerType) {
201
+ case SegmentDisplay.SymmetricCorner:
202
+ context.lineTo(x + s, y + h + this.segmentWidth + s - d);
203
+ context.lineTo(x, y + h + this.segmentWidth - d);
204
+ break;
205
+ case SegmentDisplay.SquaredCorner:
206
+ context.lineTo(x + s + e, y + h + this.segmentWidth + s - e);
207
+ context.lineTo(x, y + h + this.segmentWidth - d);
208
+ break;
209
+ default:
210
+ context.quadraticCurveTo(x + this.segmentWidth, y + h + this.segmentWidth + g, x + f + d, y + h + this.segmentWidth + f); //
211
+ context.lineTo(x, y + h + this.segmentWidth - d);
212
+ }
213
+ context.fill();
214
+ // draw segment d (d1 and d2 for 16 segments)
215
+ if (this.segmentCount == 16) {
216
+ x = xPos;
217
+ y = this.digitHeight - this.segmentWidth;
218
+ context.fillStyle = this.getSegmentColor(c, null, '0235689bcdegijloqsuz_=@');
219
+ context.beginPath();
220
+ context.moveTo(x + this.segmentWidth + d, y);
221
+ context.lineTo(x + t - d - s, y);
222
+ context.lineTo(x + t - d, y + s);
223
+ context.lineTo(x + t - d - s, y + this.segmentWidth);
224
+ switch (this.cornerType) {
225
+ case SegmentDisplay.SymmetricCorner:
226
+ context.lineTo(x + this.segmentWidth + d, y + this.segmentWidth);
227
+ context.lineTo(x + s + d, y + s);
228
+ break;
229
+ case SegmentDisplay.SquaredCorner:
230
+ context.lineTo(x + this.segmentWidth, y + this.segmentWidth);
231
+ context.lineTo(x + s + e, y + s + e);
232
+ break;
233
+ default:
234
+ context.lineTo(x + this.segmentWidth, y + this.segmentWidth);
235
+ context.quadraticCurveTo(x + this.segmentWidth - g, y + this.segmentWidth, x + this.segmentWidth - f, y + f + d);
236
+ context.lineTo(x + this.segmentWidth - f, y + f + d);
237
+ }
238
+ context.fill();
239
+ x = xPos;
240
+ y = this.digitHeight - this.segmentWidth;
241
+ context.fillStyle = this.getSegmentColor(c, null, '0235689bcdegijloqsuz_=@', '%');
242
+ context.beginPath();
243
+ context.moveTo(x + t + d + s, y + this.segmentWidth);
244
+ context.lineTo(x + t + d, y + s);
245
+ context.lineTo(x + t + d + s, y);
246
+ context.lineTo(x + this.digitWidth - this.segmentWidth - d, y);
247
+ switch (this.cornerType) {
248
+ case SegmentDisplay.SymmetricCorner:
249
+ context.lineTo(x + this.digitWidth - s - d, y + s);
250
+ context.lineTo(x + this.digitWidth - this.segmentWidth - d, y + this.segmentWidth);
251
+ break;
252
+ case SegmentDisplay.SquaredCorner:
253
+ context.lineTo(x + this.digitWidth - s - e, y + s + e);
254
+ context.lineTo(x + this.digitWidth - this.segmentWidth, y + this.segmentWidth);
255
+ break;
256
+ default:
257
+ context.lineTo(x + this.digitWidth - this.segmentWidth + f, y + f + d);
258
+ context.quadraticCurveTo(x + this.digitWidth - this.segmentWidth + g, y + this.segmentWidth, x + this.digitWidth - this.segmentWidth, y + this.segmentWidth);
259
+ }
260
+ context.fill();
261
+ }
262
+ else {
263
+ x = xPos;
264
+ y = this.digitHeight - this.segmentWidth;
265
+ context.fillStyle = this.getSegmentColor(c, '0235689bcdelotuy_', '0235689bcdegijloqsuz_=@');
266
+ context.beginPath();
267
+ context.moveTo(x + this.segmentWidth + d, y);
268
+ context.lineTo(x + this.digitWidth - this.segmentWidth - d, y);
269
+ switch (this.cornerType) {
270
+ case SegmentDisplay.SymmetricCorner:
271
+ context.lineTo(x + this.digitWidth - s - d, y + s);
272
+ context.lineTo(x + this.digitWidth - this.segmentWidth - d, y + this.segmentWidth);
273
+ context.lineTo(x + this.segmentWidth + d, y + this.segmentWidth);
274
+ context.lineTo(x + s + d, y + s);
275
+ break;
276
+ case SegmentDisplay.SquaredCorner:
277
+ context.lineTo(x + this.digitWidth - s - e, y + s + e);
278
+ context.lineTo(x + this.digitWidth - this.segmentWidth, y + this.segmentWidth);
279
+ context.lineTo(x + this.segmentWidth, y + this.segmentWidth);
280
+ context.lineTo(x + s + e, y + s + e);
281
+ break;
282
+ default:
283
+ context.lineTo(x + this.digitWidth - this.segmentWidth + f, y + f + d);
284
+ context.quadraticCurveTo(x + this.digitWidth - this.segmentWidth + g, y + this.segmentWidth, x + this.digitWidth - this.segmentWidth, y + this.segmentWidth);
285
+ context.lineTo(x + this.segmentWidth, y + this.segmentWidth);
286
+ context.quadraticCurveTo(x + this.segmentWidth - g, y + this.segmentWidth, x + this.segmentWidth - f, y + f + d);
287
+ context.lineTo(x + this.segmentWidth - f, y + f + d);
288
+ }
289
+ context.fill();
290
+ }
291
+ // draw segment e
292
+ x = xPos;
293
+ y = h + this.segmentWidth;
294
+ context.fillStyle = this.getSegmentColor(c, '0268abcdefhlnoprtu', '0268acefghjklmnopqruvw@');
295
+ context.beginPath();
296
+ context.moveTo(x, y + this.segmentWidth + d);
297
+ context.lineTo(x + s, y + s + d);
298
+ context.lineTo(x + this.segmentWidth, y + this.segmentWidth + d);
299
+ context.lineTo(x + this.segmentWidth, y + h + this.segmentWidth - d);
300
+ switch (this.cornerType) {
301
+ case SegmentDisplay.SymmetricCorner:
302
+ context.lineTo(x + s, y + h + this.segmentWidth + s - d);
303
+ context.lineTo(x, y + h + this.segmentWidth - d);
304
+ break;
305
+ case SegmentDisplay.SquaredCorner:
306
+ context.lineTo(x + s - e, y + h + this.segmentWidth + s - d + e);
307
+ context.lineTo(x, y + h + this.segmentWidth);
308
+ break;
309
+ default:
310
+ context.lineTo(x + this.segmentWidth - f - d, y + h + this.segmentWidth + f);
311
+ context.quadraticCurveTo(x, y + h + this.segmentWidth + g, x, y + h + this.segmentWidth);
312
+ }
313
+ context.fill();
314
+ // draw segment f
315
+ x = xPos;
316
+ y = 0;
317
+ context.fillStyle = this.getSegmentColor(c, '045689abcefhlpty', '045689acefghklmnopqrsuvwy@', '%');
318
+ context.beginPath();
319
+ context.moveTo(x + this.segmentWidth, y + this.segmentWidth + d);
320
+ context.lineTo(x + this.segmentWidth, y + h + this.segmentWidth - d);
321
+ context.lineTo(x + s, y + h + this.segmentWidth + s - d);
322
+ context.lineTo(x, y + h + this.segmentWidth - d);
323
+ switch (this.cornerType) {
324
+ case SegmentDisplay.SymmetricCorner:
325
+ context.lineTo(x, y + this.segmentWidth + d);
326
+ context.lineTo(x + s, y + s + d);
327
+ break;
328
+ case SegmentDisplay.SquaredCorner:
329
+ context.lineTo(x, y + this.segmentWidth);
330
+ context.lineTo(x + s - e, y + s + e);
331
+ break;
332
+ default:
333
+ context.lineTo(x, y + this.segmentWidth);
334
+ context.quadraticCurveTo(x, y + this.segmentWidth - g, x + this.segmentWidth - f - d, y + this.segmentWidth - f);
335
+ context.lineTo(x + this.segmentWidth - f - d, y + this.segmentWidth - f);
336
+ }
337
+ context.fill();
338
+ // draw segment g for 7 segments
339
+ if (this.segmentCount == 7) {
340
+ x = xPos;
341
+ y = (this.digitHeight - this.segmentWidth) / 2.0;
342
+ context.fillStyle = this.getSegmentColor(c, '2345689abdefhnoprty-=');
343
+ context.beginPath();
344
+ context.moveTo(x + s + d, y + s);
345
+ context.lineTo(x + this.segmentWidth + d, y);
346
+ context.lineTo(x + this.digitWidth - this.segmentWidth - d, y);
347
+ context.lineTo(x + this.digitWidth - s - d, y + s);
348
+ context.lineTo(x + this.digitWidth - this.segmentWidth - d, y + this.segmentWidth);
349
+ context.lineTo(x + this.segmentWidth + d, y + this.segmentWidth);
350
+ context.fill();
351
+ }
352
+ // draw inner segments for the fourteen- and sixteen-segment-display
353
+ if (this.segmentCount != 7) {
354
+ // draw segment g1
355
+ x = xPos;
356
+ y = (this.digitHeight - this.segmentWidth) / 2.0;
357
+ context.fillStyle = this.getSegmentColor(c, null, '2345689aefhkprsy-+*=', '%');
358
+ context.beginPath();
359
+ context.moveTo(x + s + d, y + s);
360
+ context.lineTo(x + this.segmentWidth + d, y);
361
+ context.lineTo(x + t - d - s, y);
362
+ context.lineTo(x + t - d, y + s);
363
+ context.lineTo(x + t - d - s, y + this.segmentWidth);
364
+ context.lineTo(x + this.segmentWidth + d, y + this.segmentWidth);
365
+ context.fill();
366
+ // draw segment g2
367
+ x = xPos;
368
+ y = (this.digitHeight - this.segmentWidth) / 2.0;
369
+ context.fillStyle = this.getSegmentColor(c, null, '234689abefghprsy-+*=@', '%');
370
+ context.beginPath();
371
+ context.moveTo(x + t + d, y + s);
372
+ context.lineTo(x + t + d + s, y);
373
+ context.lineTo(x + this.digitWidth - this.segmentWidth - d, y);
374
+ context.lineTo(x + this.digitWidth - s - d, y + s);
375
+ context.lineTo(x + this.digitWidth - this.segmentWidth - d, y + this.segmentWidth);
376
+ context.lineTo(x + t + d + s, y + this.segmentWidth);
377
+ context.fill();
378
+ // draw segment j
379
+ x = xPos + t - s;
380
+ y = 0;
381
+ context.fillStyle = this.getSegmentColor(c, null, 'bdit+*', '%');
382
+ context.beginPath();
383
+ if (this.segmentCount == 14) {
384
+ context.moveTo(x, y + this.segmentWidth + this.segmentDistance);
385
+ context.lineTo(x + this.segmentWidth, y + this.segmentWidth + this.segmentDistance);
386
+ }
387
+ else {
388
+ context.moveTo(x, y + this.segmentWidth + d);
389
+ context.lineTo(x + s, y + s + d);
390
+ context.lineTo(x + this.segmentWidth, y + this.segmentWidth + d);
391
+ }
392
+ context.lineTo(x + this.segmentWidth, y + h + this.segmentWidth - d);
393
+ context.lineTo(x + s, y + h + this.segmentWidth + s - d);
394
+ context.lineTo(x, y + h + this.segmentWidth - d);
395
+ context.fill();
396
+ // draw segment m
397
+ x = xPos + t - s;
398
+ y = this.digitHeight;
399
+ context.fillStyle = this.getSegmentColor(c, null, 'bdity+*@', '%');
400
+ context.beginPath();
401
+ if (this.segmentCount == 14) {
402
+ context.moveTo(x, y - this.segmentWidth - this.segmentDistance);
403
+ context.lineTo(x + this.segmentWidth, y - this.segmentWidth - this.segmentDistance);
404
+ }
405
+ else {
406
+ context.moveTo(x, y - this.segmentWidth - d);
407
+ context.lineTo(x + s, y - s - d);
408
+ context.lineTo(x + this.segmentWidth, y - this.segmentWidth - d);
409
+ }
410
+ context.lineTo(x + this.segmentWidth, y - h - this.segmentWidth + d);
411
+ context.lineTo(x + s, y - h - this.segmentWidth - s + d);
412
+ context.lineTo(x, y - h - this.segmentWidth + d);
413
+ context.fill();
414
+ // draw segment h
415
+ x = xPos + this.segmentWidth;
416
+ y = this.segmentWidth;
417
+ context.fillStyle = this.getSegmentColor(c, null, 'mnx\\*');
418
+ context.beginPath();
419
+ context.moveTo(x + this.segmentDistance, y + this.segmentDistance);
420
+ context.lineTo(x + this.segmentDistance + r, y + this.segmentDistance);
421
+ context.lineTo(x + w - this.segmentDistance, y + h - this.segmentDistance - r);
422
+ context.lineTo(x + w - this.segmentDistance, y + h - this.segmentDistance);
423
+ context.lineTo(x + w - this.segmentDistance - r, y + h - this.segmentDistance);
424
+ context.lineTo(x + this.segmentDistance, y + this.segmentDistance + r);
425
+ context.fill();
426
+ // draw segment k
427
+ x = xPos + w + 2.0 * this.segmentWidth;
428
+ y = this.segmentWidth;
429
+ context.fillStyle = this.getSegmentColor(c, null, '0kmvxz/*', '%');
430
+ context.beginPath();
431
+ context.moveTo(x + w - this.segmentDistance, y + this.segmentDistance);
432
+ context.lineTo(x + w - this.segmentDistance, y + this.segmentDistance + r);
433
+ context.lineTo(x + this.segmentDistance + r, y + h - this.segmentDistance);
434
+ context.lineTo(x + this.segmentDistance, y + h - this.segmentDistance);
435
+ context.lineTo(x + this.segmentDistance, y + h - this.segmentDistance - r);
436
+ context.lineTo(x + w - this.segmentDistance - r, y + this.segmentDistance);
437
+ context.fill();
438
+ // draw segment l
439
+ x = xPos + w + 2.0 * this.segmentWidth;
440
+ y = h + 2.0 * this.segmentWidth;
441
+ context.fillStyle = this.getSegmentColor(c, null, '5knqrwx\\*');
442
+ context.beginPath();
443
+ context.moveTo(x + this.segmentDistance, y + this.segmentDistance);
444
+ context.lineTo(x + this.segmentDistance + r, y + this.segmentDistance);
445
+ context.lineTo(x + w - this.segmentDistance, y + h - this.segmentDistance - r);
446
+ context.lineTo(x + w - this.segmentDistance, y + h - this.segmentDistance);
447
+ context.lineTo(x + w - this.segmentDistance - r, y + h - this.segmentDistance);
448
+ context.lineTo(x + this.segmentDistance, y + this.segmentDistance + r);
449
+ context.fill();
450
+ // draw segment n
451
+ x = xPos + this.segmentWidth;
452
+ y = h + 2.0 * this.segmentWidth;
453
+ context.fillStyle = this.getSegmentColor(c, null, '0vwxz/*', '%');
454
+ context.beginPath();
455
+ context.moveTo(x + w - this.segmentDistance, y + this.segmentDistance);
456
+ context.lineTo(x + w - this.segmentDistance, y + this.segmentDistance + r);
457
+ context.lineTo(x + this.segmentDistance + r, y + h - this.segmentDistance);
458
+ context.lineTo(x + this.segmentDistance, y + h - this.segmentDistance);
459
+ context.lineTo(x + this.segmentDistance, y + h - this.segmentDistance - r);
460
+ context.lineTo(x + w - this.segmentDistance - r, y + this.segmentDistance);
461
+ context.fill();
462
+ }
463
+ return this.digitDistance + this.digitWidth;
464
+ case '.':
465
+ context.fillStyle = c == '#' || c == '.' ? this.colorOn : this.colorOff;
466
+ this.drawPoint(context, xPos, this.digitHeight - this.segmentWidth, this.segmentWidth);
467
+ return this.digitDistance + this.segmentWidth;
468
+ case ':':
469
+ context.fillStyle = c == '#' || c == ':' ? this.colorOn : this.colorOff;
470
+ var y = (this.digitHeight - this.segmentWidth) / 2.0 - this.segmentWidth;
471
+ this.drawPoint(context, xPos, y, this.segmentWidth);
472
+ this.drawPoint(context, xPos, y + 2.0 * this.segmentWidth, this.segmentWidth);
473
+ return this.digitDistance + this.segmentWidth;
474
+ default:
475
+ return this.digitDistance;
476
+ }
477
+ }
478
+ drawPoint(context, x1, y1, size) {
479
+ var x2 = x1 + size;
480
+ var y2 = y1 + size;
481
+ var d = size / 4.0;
482
+ context.beginPath();
483
+ context.moveTo(x2 - d, y1);
484
+ context.quadraticCurveTo(x2, y1, x2, y1 + d);
485
+ context.lineTo(x2, y2 - d);
486
+ context.quadraticCurveTo(x2, y2, x2 - d, y2);
487
+ context.lineTo(x1 + d, y2);
488
+ context.quadraticCurveTo(x1, y2, x1, y2 - d);
489
+ context.lineTo(x1, y1 + d);
490
+ context.quadraticCurveTo(x1, y1, x1 + d, y1);
491
+ context.fill();
492
+ }
493
+ getSegmentColor(c, charSet7, charSet14, charSet16) {
494
+ if (c == '#') {
495
+ return this.colorOn;
496
+ }
497
+ else {
498
+ switch (this.segmentCount) {
499
+ case 7:
500
+ return (charSet7 === null || charSet7 === void 0 ? void 0 : charSet7.indexOf(c)) == -1 ? this.colorOff : this.colorOn;
501
+ case 14:
502
+ return (charSet14 === null || charSet14 === void 0 ? void 0 : charSet14.indexOf(c)) == -1 ? this.colorOff : this.colorOn;
503
+ case 16:
504
+ var pattern = charSet14 + (charSet16 === undefined ? '' : charSet16);
505
+ return pattern.indexOf(c) == -1 ? this.colorOff : this.colorOn;
506
+ default:
507
+ return this.colorOff;
508
+ }
509
+ }
510
+ }
511
+ }
512
+ // Segment display types
513
+ SegmentDisplay.SevenSegment = 7;
514
+ SegmentDisplay.FourteenSegment = 14;
515
+ SegmentDisplay.SixteenSegment = 16;
516
+ // Segment corner types
517
+ SegmentDisplay.SymmetricCorner = 0;
518
+ SegmentDisplay.SquaredCorner = 1;
519
+ SegmentDisplay.RoundedCorner = 2;
520
+ export default SegmentDisplay;
521
+ //# sourceMappingURL=segment-display.js.map