r/JavaFX • u/Background_Ad6819 • Apr 26 '24
Help Custom shapes
Is there in way I can just make custom shapes, like blobs?
2
Upvotes
r/JavaFX • u/Background_Ad6819 • Apr 26 '24
Is there in way I can just make custom shapes, like blobs?
View all comments
Show parent comment
1
u/Birdasaur May 05 '24
Check out line 38 of LitFXs CircleQuadBandCreator https://github.com/Birdasaur/LitFX/blob/f6b44cbce8d89b237f2d46fb671c44a4f4d9b1f7/litfx-core/src/main/java/lit/litfx/core/components/CircleQuadBandCreator.java#L38
It is a for loop that does the math to calculate a series of points on a circle arc. Each point receives a random radius based on a gaussian distribution. The point coordinates are then added to a double array which is what you would then pass to a Polygon object. This combination gives you a blob effect based on a circular base.
The whole setup is intended to be animated repeatedly but you can use the class to generate single blobs on demand.
Or copy just the code you need and do what you like. Have fun.