MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / drawDigit

Function drawDigit

app/rcc/scripts/painter/segment_display.js:24–40  ·  view source on GitHub ↗
(ctx, x, y, w, h, ch)

Source from the content-addressed store, hash-verified

22};
23
24function drawDigit(ctx, x, y, w, h, ch) {
25 const segs = SEG[ch] || SEG[" "];
26 const t = Math.max(2, h * 0.10);
27
28 function bar(px, py, pw, ph, on) {
29 ctx.fillStyle = on ? theme.widget_text : theme.widget_border;
30 ctx.fillRect(px, py, pw, ph);
31 }
32
33 bar(x + t, y, w - 2 * t, t, segs[0]); // a
34 bar(x + w - t, y + t, t, h * 0.5 - t * 1.5, segs[1]); // b
35 bar(x + w - t, y + h * 0.5 + t * 0.5, t, h * 0.5 - t * 1.5, segs[2]); // c
36 bar(x + t, y + h - t, w - 2 * t, t, segs[3]); // d
37 bar(x, y + h * 0.5 + t * 0.5, t, h * 0.5 - t * 1.5, segs[4]); // e
38 bar(x, y + t, t, h * 0.5 - t * 1.5, segs[5]); // f
39 bar(x + t, y + h * 0.5 - t * 0.5, w - 2 * t, t, segs[6]); // g
40}
41
42function paint(ctx, w, h) {
43 // Cream paper background + vignette.

Callers 1

paintFunction · 0.85

Calls 1

barFunction · 0.85

Tested by

no test coverage detected