MCPcopy Create free account
hub / github.com/VCVRack/Rack / draw

Method draw

src/app/LedDisplay.cpp:11–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11void LedDisplay::draw(const DrawArgs& args) {
12 math::Rect r = box.zeroPos();
13
14 // Black background
15 nvgBeginPath(args.vg);
16 nvgRect(args.vg, RECT_ARGS(r));
17 NVGcolor topColor = nvgRGB(0x22, 0x22, 0x22);
18 NVGcolor bottomColor = nvgRGB(0x12, 0x12, 0x12);
19 nvgFillPaint(args.vg, nvgLinearGradient(args.vg, 0.0, 0.0, 0.0, 25.0, topColor, bottomColor));
20 // nvgFillColor(args.vg, bottomColor);
21 nvgFill(args.vg);
22
23 // Outer strokes
24 nvgBeginPath(args.vg);
25 nvgMoveTo(args.vg, 0.0, -0.5);
26 nvgLineTo(args.vg, box.size.x, -0.5);
27 nvgStrokeColor(args.vg, nvgRGBAf(0, 0, 0, 0.24));
28 nvgStrokeWidth(args.vg, 1.0);
29 nvgStroke(args.vg);
30
31 nvgBeginPath(args.vg);
32 nvgMoveTo(args.vg, 0.0, box.size.y + 0.5);
33 nvgLineTo(args.vg, box.size.x, box.size.y + 0.5);
34 nvgStrokeColor(args.vg, nvgRGBAf(1, 1, 1, 0.25));
35 nvgStrokeWidth(args.vg, 1.0);
36 nvgStroke(args.vg);
37
38 // Inner strokes
39 nvgBeginPath(args.vg);
40 nvgMoveTo(args.vg, 0.0, 2.5);
41 nvgLineTo(args.vg, box.size.x, 2.5);
42 nvgStrokeColor(args.vg, nvgRGBAf(1, 1, 1, 0.20));
43 nvgStrokeWidth(args.vg, 1.0);
44 nvgStroke(args.vg);
45
46 nvgBeginPath(args.vg);
47 nvgMoveTo(args.vg, 0.0, box.size.y - 2.5);
48 nvgLineTo(args.vg, box.size.x, box.size.y - 2.5);
49 nvgStrokeColor(args.vg, nvgRGBAf(1, 1, 1, 0.20));
50 nvgStrokeWidth(args.vg, 1.0);
51 nvgStroke(args.vg);
52
53 // Black border
54 math::Rect rBorder = r.shrink(math::Vec(1, 1));
55 nvgBeginPath(args.vg);
56 nvgRect(args.vg, RECT_ARGS(rBorder));
57 nvgStrokeColor(args.vg, bottomColor);
58 nvgStrokeWidth(args.vg, 2.0);
59 nvgStroke(args.vg);
60
61 // Draw children inside box
62 nvgScissor(args.vg, RECT_ARGS(args.clipBox));
63 Widget::draw(args);
64 nvgResetScissor(args.vg);
65}
66
67
68void LedDisplay::drawLayer(const DrawArgs& args, int layer) {

Callers

nothing calls this directly

Calls 3

VecClass · 0.85
zeroPosMethod · 0.80
shrinkMethod · 0.80

Tested by

no test coverage detected