(String [] args)
| 5 | |
| 6 | public 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 | } |
no test coverage detected