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

Method main

examples/bitmap/src/RenderToBitmap.java:7–31  ·  view source on GitHub ↗
(String [] args)

Source from the content-addressed store, hash-verified

5
6public class RenderToBitmap {
7 public static void main(String [] args) throws Exception {
8 var surface = Surface.makeRasterN32Premul(640, 360);
9 var canvas = surface.getCanvas();
10
11 canvas.clear(0xFFFFFFFF);
12
13 canvas.drawTriangles(new Point[] {
14 new Point(320, 70),
15 new Point(194, 287),
16 new Point(446, 287)
17 },
18 new int[] { 0xFFFF0000, 0xFF00FF00, 0xFF0000FF },
19 new Paint());
20
21 Path path = new Path().moveTo(253, 216)
22 .cubicTo(283, 163.5f, 358, 163.5f, 388, 216)
23 .cubicTo(358, 268.5f, 283, 268.5f, 253, 216)
24 .closePath();
25 canvas.drawPath(path, new Paint().setColor(0xFFFFFFFF));
26
27 canvas.drawCircle(320, 217, 16, new Paint().setColor(0xFF000000));
28
29 byte[] pngBytes = surface.makeImageSnapshot().encodeToData().getBytes();
30 java.nio.file.Files.write(java.nio.file.Path.of("output.png"), pngBytes);
31 }
32}

Callers 1

mainFunction · 0.45

Calls 14

makeRasterN32PremulMethod · 0.95
getCanvasMethod · 0.80
clearMethod · 0.80
drawTrianglesMethod · 0.80
closePathMethod · 0.80
cubicToMethod · 0.80
moveToMethod · 0.80
drawCircleMethod · 0.80
getBytesMethod · 0.80
encodeToDataMethod · 0.80
makeImageSnapshotMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected