MCPcopy Index your code
hub / github.com/cifertech/DisplayKit / drawOledLine

Function drawOledLine

app.js:3479–3493  ·  view source on GitHub ↗
(ctx, x0, y0, x1, y1, color)

Source from the content-addressed store, hash-verified

3477}
3478
3479function drawOledLine(ctx, x0, y0, x1, y1, color) {
3480 ctx.fillStyle = color;
3481 let dx = Math.abs(x1 - x0);
3482 let sx = x0 < x1 ? 1 : -1;
3483 let dy = -Math.abs(y1 - y0);
3484 let sy = y0 < y1 ? 1 : -1;
3485 let err = dx + dy;
3486 while (true) {
3487 ctx.fillRect(x0, y0, 1, 1);
3488 if (x0 === x1 && y0 === y1) break;
3489 const e2 = 2 * err;
3490 if (e2 >= dy) { err += dy; x0 += sx; }
3491 if (e2 <= dx) { err += dx; y0 += sy; }
3492 }
3493}
3494
3495function drawOledCircle(ctx, cx, cy, r, color, filled) {
3496 ctx.fillStyle = color;

Callers 1

renderElementsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected