MCPcopy Create free account
hub / github.com/JetBrains/skija / draw

Method draw

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

Source from the content-addressed store, hash-verified

20 }
21
22 @Override
23 public void draw(Canvas canvas, int width, int height, float dpi, int xpos, int ypos) {
24 if (_dom != null) {
25 try (SVGSVG root = _dom.getRoot();
26 var paint = new Paint().setColor(0xFFEEEEEE);)
27 {
28 var bounds = new Point(width - 50, height - 50);
29 SVGLengthContext lc = new SVGLengthContext(bounds);
30 var svgWidth = lc.resolve(root.getWidth(), SVGLengthType.HORIZONTAL);
31 var svgHeight = lc.resolve(root.getHeight(), SVGLengthType.VERTICAL);
32 _dom.setContainerSize(bounds);
33 var scale = Math.min(bounds.getX() / svgWidth, bounds.getY() / svgHeight);
34 canvas.translate((width - svgWidth * scale) / 2f, (height - svgHeight * scale) / 2f);
35 canvas.drawRect(Rect.makeWH(svgWidth * scale, svgHeight * scale), paint);
36 canvas.scale(scale, scale);
37 _dom.render(canvas);
38 }
39 } else if (_error != null) {
40 Scene.drawStringCentered(canvas, _error.getMessage(), width / 2, height / 2, Scene.inter13, Scene.blackFill);
41 } else if (_thread != null) {
42 Scene.drawStringCentered(canvas, "Loading " + _variants[_variantIdx] + "...", width / 2, height / 2, Scene.inter13, Scene.blackFill);
43 } else {
44 _thread = new Fetch(_variants[_variantIdx]);
45 _thread.start();
46 }
47 }
48
49 class Fetch extends Thread {
50 public String _url;

Callers

nothing calls this directly

Calls 14

resolveMethod · 0.95
makeWHMethod · 0.95
drawStringCenteredMethod · 0.95
getRootMethod · 0.80
setContainerSizeMethod · 0.80
getXMethod · 0.80
getYMethod · 0.80
drawRectMethod · 0.80
getWidthMethod · 0.65
getHeightMethod · 0.65
setColorMethod · 0.45
translateMethod · 0.45

Tested by

no test coverage detected