2D draw primitives in a Lemur GUI - How can it be achieved?

I am new to JME and test the possibilities of the different GUI options.

My project includes GUI components consisting of arcs, rectangles that adapt dynamically to the space that they are given. I did this in JavaFX, where I redraw the whole component, everytime the components width or height changed.

I’ve read that I could use Swing to create BufferedImages that I could then use as a texture. If I am not mistaken, that would require jme-desktop and thus reduce my chance to run on Android devices.

Are there any other options - preferrably with Lemur?

Someone had written an Image painter add-on library that worked with JME’s ImageRaster to allow painting things onto textures. I think it was even setup as a plugin for the SDK but the source code should be in the JME contributions area, I guess.

1 Like

Or if you just want a basic setup…

ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * 4);
Image image = new Image(Image.Format.RGB8, width, height, buffer, ColorSpace.sRGB);

// assign the image to a texture...
Texture texture = new Texture2D(image);

// set some pixel colors...
ImageRaster imageRaster = ImageRaster.create(image);
imageRaster.setPixel(x, y, new ColorRGBA(1,1,1,1));

What’s cool about the ImageRaster class is that it modifies the image directly so you get a binding effect. No need to keep re-setting the texture on a material.


Thank you. I can see how to achieve what I want. I would need to extend the ImagePainter to draw filled arcs and circles. Possible, though I admit I had hoped not to mess around with implemented the draw methods myself :wink:

But at least I am not stuck and can continue.

Depending on what you want to do, you could also have a picture of a circle and paint it stretched.

…but really, implementing circle drawing is not hard.