How to fill a layer with a radial gradient in playn (1.3)?

I'm trying to start with playn 1.3 (should I use 1.4?), But I am confused early on the question of how easy it is to fill a layer with a radial gradient. graphics (). createRadialGradient tells me that it creates a template, but it just creates a gradient that I cannot use on setFillPattern. Using createCanvasLayer is deprecated, so I'm trying to use ImageLayer and SurfaceLayer, but I can't find a way to create the actual template from the gradient or something like that that finally fills the layer with my gradient. Of course, I should just ignore something, so I would be happy to get a hint here, because the plane really looks promising to me :)

Greetings

+4
source share
1 answer

Tested in PlayN 1.4:

CanvasImage canvasImage = graphics().createImage(100, 100); Canvas canvas = canvasImage.canvas(); Gradient radialGradient = graphics().createRadialGradient(50, 50, 50, new int[]{Color.rgb(255, 0, 0), Color.argb(0, 255, 0, 0)}, new float[]{0, 1}); canvas.setFillGradient(radialGradient); canvas.fillRect(0, 0, 100, 100); ImageLayer imageLayer = graphics().createImageLayer(); imageLayer.setImage(canvasImage); imageLayer.setDepth(1); graphics().rootLayer().addAt(imageLayer, graphics().width() / 2, graphics().height() / 2); 
+1
source

Source: https://habr.com/ru/post/1434930/


All Articles