How can I create this effect?
BlitzMax Forums/BlitzMax Programming/How can I create this effect?
| ||
![]() I want to create this effect, where, we have circles that "merge" when they are close. I can see how it would be impossible with sprites, and that you would need to draw the image with code on the fly. Don't know what else to put in the post. :o |
| ||
I depends on whether you want the outline of the objects to be a smooth curve or whether, as in your diagram, you simply want to have the outline be removed if it intersects another circle. If you want a smooth curve, which your diagram does not show, then you want blobby objects/metaballs. See my tutorial in the tutorials forum. |
| ||
I see. Nice tutorial by the way, I loved it. I actually only want the outline to be removed if it intersects. I have a game which involves a lot of bacteria, and it looks pretty ugly when a lot of bacteria are almost on top of each other, thus I want their edges to not overlap, but be merged. |
| ||
Can you find their intersection points and then Drawpoly between those using the same colour as the sprite? You'll get the same problem though with the inner circle. Alternatively, don't have the outline? |
| ||
Hm, yes, I'm starting to wonder if simply not having the outline would be the best option, and just using the proper BLEND to get the pale pink to merge. |
| ||
When you draw the black outline first from both bacteria and then the pale pink on top it could simply hide the intersection underneath. But you need then two phases to draw, don't know if that works for you. |
| ||
Here's a very simple example, that does what you want - just change the code to use Types and images etc. |
| ||
It would be more efficient to do something computational based on the pixels. If you are willing to indulge in some custom OpenGL or DX coding you could draw all of the larger circle parts as filled circles in an OR logic operation, then use the resulting image to create some kind of outline of those shapes, perhaps by jittering or something, and then finally draw the centers of the objects. |
| ||
Make layers. Draw borders first, then faces, etc. This would be the fastest way. |
| ||
If it's only 2 sprites merging, then you could simply have a 3rd sprite image which you manipulate. I know...I cheat. :) |
| ||
Thanks guys, but I've decided to drop the outline for simplicity, and also it kinda looks better. DX |
| ||
You could fake an outline by drawing all your objects at a slight offset in a light color, then at another offset in a dark color, and then finally draw the normal colored objects. That would create a basic embossing effect. |
| ||
I've wanted to be able to do this the proper algorithmic way for years, and yesterday I finally had a bout of inspiration! Here's my code. It's pretty length, but to use it in your programs you can do with just copying everything above the example code, and the only bits you need to pay attention to are passing a list of circles to the intersectcircles function and doing whatever you want with the circle.draw method. |
| ||
Nice effect! Here's the superstrict version with locals declared and the like |
| ||
thanks for that, ziggy |
| ||
I don't think your girlfriend would like it if you did that. |