MCPcopy Index your code
hub / github.com/marijnh/Eloquent-JavaScript / update

Method update

code/hangar2.js:147–164  ·  view source on GitHub ↗
(n, data)

Source from the content-addressed store, hash-verified

145 }
146
147 update(n, data) {
148 this.getParent()
149 if (!this.parent.ownerDocument.body.contains(this.dom)) this.parent.appendChild(this.dom)
150
151 let canvas = this.screens[n], cx = canvas.getContext("2d")
152 cx.clearRect(0, 0, canvas.width, canvas.height)
153 let gapX = (canvas.width * 0.4) / 51, sizeX = (canvas.width * 0.6) / 50, skipX = gapX + sizeX
154 let gapY = (canvas.height * 0.4) / 31, sizeY = (canvas.height * 0.6) / 30, skipY = gapY + sizeY
155 for (let i = 0, col = 0, row = 0; i < 1500; i++) {
156 let pixel = data[i]
157 if (pixel) {
158 cx.fillStyle = pixel == 3 ? "#fd4" : pixel == 2 ? "#a82" : "#741"
159 cx.fillRect(gapX + col * skipX, gapY + row * skipY, sizeX, sizeY)
160 }
161 if (col == 49) { col = 0; row++ }
162 else { col++ }
163 }
164 }
165 }
166 let screens = null
167

Callers 2

hashFunction · 0.80
screenFunction · 0.80

Calls 1

getParentMethod · 0.95

Tested by

no test coverage detected