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