Bubblify yourself!

Post your nifty GP projects here!

Moderator: MSandro

Post Reply
manyone
Posts: 40
Joined: Nov 5th, '17, 07:56

Bubblify yourself!

Post by manyone » Oct 21st, '20, 09:21

cirpack - Copy.png
i'm sharing my most favorite program that i've written in GP.
i adapted it from the result of a coding challenge episode that i found in github a couple of years ago. it's a circle packing algorithm for filling a rectangle with varying size circles but the circles are colored with the color of the pixel found under the center. please see the notes folder for instructions.

based on the current configuration, it tries to place 10 cirles on the board , one circle at a time, at a random location on the board which is NOT already inside an existing circle. after each circle is placed on the board, ALL circles on the board are grown (increase diameter by 1px) as long as each circle doesn't colliide with another circle, or the edge of the board. when that happens, the circle stops growing. the process of putting 10 circles in each pass is repeated. as more circles are placed on the board, it is less likely to find a random spot that isn't already part of a circle. when the number of failed attempts for trying to get a complete set of 10 valid circles is greater than 70 (arbitrarily set), the board is "fully" packed. it doesnt entirely pack the whole area because the placement is random but after several thousand circles have been created, the area looks full enough to give that bubblified effect.

enjoy!
cirpack.gpp
(825.03 KiB) Downloaded 447 times

Post Reply