MCPcopy Create free account
hub / github.com/HumbleUI/Skija / draw

Method draw

examples/scenes/src/PixelGridScene.java:12–119  ·  view source on GitHub ↗
(Canvas canvas, int width, int height, float dpi, int xpos, int ypos)

Source from the content-addressed store, hash-verified

10 }
11
12 @Override
13 public void draw(Canvas canvas, int width, int height, float dpi, int xpos, int ypos) {
14 canvas.translate(20, 20);
15
16 try (var fill = new Paint().setColor(0xFF000000);
17 var stroke = new Paint().setColor(0xFF000000).setMode(PaintMode.STROKE).setStrokeWidth(1);)
18 {
19 Rect rect;
20
21 // 3px rect
22 rect = Rect.makeLTRB(0, 0, 3, 3);
23 canvas.drawRect(rect, stroke);
24 canvas.translate(20, 0);
25 canvas.drawRect(rect, fill);
26 canvas.translate(20, 0);
27 canvas.drawString(rect.toString(), 0, 10, inter13, fill);
28 canvas.translate(-40, 40);
29
30 rect = Rect.makeLTRB(0.5f, 0.5f, 2.5f, 2.5f);
31 canvas.drawRect(rect, stroke);
32 canvas.translate(20, 0);
33 canvas.drawRect(rect, fill);
34 canvas.translate(20, 0);
35 canvas.drawString(rect.toString(), 0, 10, inter13, fill);
36 canvas.translate(-40, 40);
37
38 // 10px rect
39 rect = Rect.makeLTRB(0, 0, 10, 10);
40 canvas.drawRect(rect, stroke);
41 canvas.translate(20, 0);
42 canvas.drawRect(rect, fill);
43 canvas.translate(20, 0);
44 canvas.drawString(rect.toString(), 0, 10, inter13, fill);
45 canvas.translate(-40, 40);
46
47 rect = Rect.makeLTRB(0.5f, 0.5f, 9.5f, 9.5f);
48 canvas.drawRect(rect, stroke);
49 canvas.translate(20, 0);
50 canvas.drawRect(rect, fill);
51 canvas.translate(20, 0);
52 canvas.drawString(rect.toString(), 0, 10, inter13, fill);
53 canvas.translate(-40, 40);
54
55 // Circle
56 canvas.drawCircle(5, 5, 5, stroke);
57 canvas.drawCircle(25, 5, 5, fill);
58 canvas.drawString("5", 40, 10, inter13, fill);
59 canvas.translate(0, 40);
60
61 canvas.drawCircle(5, 5, 4.5f, stroke);
62 canvas.drawCircle(25, 5, 4.5f, fill);
63 canvas.drawString("4.5", 40, 10, inter13, fill);
64 canvas.translate(0, 40);
65
66 // Oval
67 rect = Rect.makeLTRB(0, 0, 10, 10);
68 canvas.drawOval(rect, stroke);
69 canvas.translate(20, 0);

Callers

nothing calls this directly

Calls 12

setStrokeWidthMethod · 0.80
setModeMethod · 0.80
drawRectMethod · 0.80
drawCircleMethod · 0.80
drawRRectMethod · 0.80
setStrokeCapMethod · 0.80
toStringMethod · 0.65
translateMethod · 0.45
setColorMethod · 0.45
drawStringMethod · 0.45
drawOvalMethod · 0.45
drawLineMethod · 0.45

Tested by

no test coverage detected