Fill Tool in Gdevelop

Hello, does anyone have an idea how to create a fill tool functionality. If you e.g. If you paint a shape where the edges are completely closed, the functionality should fill the inside of the bottle with a color by clicking. As is done with commercially available painting programs. Does anyone have an idea?

I’m not aware of a flood fill. The closest thing would to draw the shape as a path.

https://wiki.gdevelop.io/gdevelop5/all-features/primitive-drawing/reference/

You can connect points using various path types and then close it.

Is there an example somewhere how to use “fill path”?

I don’t know if there are example. There probably is. Maybe on YouTube.

The path is fairly straightforward. You start a path and then the shape actions draw a line or curve from that point, the next action uses the last point and so on until you close it.

This draws a triangle.

I think it’s not quite what I’m looking for. But I’m still experimenting with it a little. But anyway, thanks for the help.

1 Like

marching squares has a floodfill, but to make a paint program out of it would take a lot of wrangling, since you can only have two colors per instance (outline and fill)

Yes, I think that’s too complicated. But thank you very much for the suggestion.

Are they drawing say a bottle or do you just want them to be able to change the fill color of an existing bottle? If the bottle already exists thenn if the fill color is white, you can change the tint.

This is one way to create filled shapes. You could change the color first. It saves the points in an array. You could use separate shape painters for each shape and save the points to an object array. Although, you can’t use for each child with objects, so you would need to modify things.

Try me. Click and drag to draw shapes.
https://gd.games/keith_13579/timedelta

IDK if you can use a color effect on the shape painter to recolor the shape afterwards or you would have to redraw the shape.

Anyways, here is a way to draw a freeform filled shape. I used an array to hold the points and a distance check to keep the point count low.

Variables

Events

Shape painter settings. There are 2 shape painters in the scene. One for the drawing and one for the fill. After the fill, the drawing one could probably be cleared and reused.

I originally tried doing this without the array but for some reason adding to a path on different frames doesn’t work. You seem to need to add the path all at once.

Hello Keith_1357,

I’m sorry I’m only getting in touch now.
Yes, that’s a good idea. Of course I would have preferred a real filling tool. But with your variant it should work to some extent. Thank you very much for your effort and help.

1 Like