* Create or update a hex * @param {object} params
(params = {})
| 72 | * @param {object} params |
| 73 | */ |
| 74 | saveHex(params = {}) { |
| 75 | const text = params.text || {}; |
| 76 | const node = { |
| 77 | id: params.id, |
| 78 | x: params.x, |
| 79 | y: params.y, |
| 80 | bgColor: params.bgColor || COLOR.white, |
| 81 | borderColor: params.borderColor || COLOR.white, |
| 82 | text: { |
| 83 | value: text.value || '', |
| 84 | color: text.color || COLOR.black, |
| 85 | font: text.font || '12px Arial', |
| 86 | xOffset: text.xOffset || 0, |
| 87 | yOffset: text.yOffset || 0 |
| 88 | }, |
| 89 | blink: { |
| 90 | text: { |
| 91 | value: '', |
| 92 | color: COLOR.black |
| 93 | }, |
| 94 | borderColor: params.borderColor || COLOR.white, |
| 95 | bgColor: COLOR.red, |
| 96 | interval: 1000, |
| 97 | on: false, |
| 98 | lastCall: 0 |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | let isExist = false; |
| 103 | |
| 104 | for (let i = 0; i < this._nodes.length; i++) { |
| 105 | if (this._nodes[i].id === node.id) { |
| 106 | this._nodes[i] = node; |
| 107 | isExist = true; |
| 108 | break; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | if (!isExist) { |
| 113 | this._nodes.push(node); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Blink on |