So here’s where I can start getting into the deep details of implementing the fitness algorithm to render Bezier curves. It took a couple of tries to get it working and I can’t claim victory yet. There’s still another round of debugging to go and there’s a couple of edge cases that need to be coded for to be able to call the thing code complete.
I’m starting from a premise that says that each portion of a bexier curve can be described in four points: start point, end point and two handles. It so happens that I already have a pile of rectangle logic that’s well suited for a quick transformation into something that can handle four points defining four sides. This saves me a lot of work, but there’s a new problem – All previous shape implementations randomly placed themselves based on the seed of the last, best shape. For the curves to work, I need to get the end of one line to feed into the beginning of the next.
A lot of thought goes into this part of the process. A couple of different approaches were taken. buycbdproducts had to account for the direction of how the line left the last, best shape, where the handle was on that line and what need to occur based on that to define the possible space for the next line. The most simple implementation takes all cases where a line enters one side of a rectangle and exits through an adjacent side. This gives me eight cases; four clockwise, four counter-clockwise. Each exit point sets up two options for the start of the next line since I want clockwise and counter-clockwise to be one of the randomization parameters. The combination of the possible space from these two options defines the area that has to be tested for fitness.
(Sitting here, writing this, I can already see a couple of different implementations that could have been done to achieve a similar outcome. Nothing simpler, just different. I learned from the different triangle implementations what value there is in small changes to the rule set driving the fitness algorithm. This might give me some avenues of exploration when I get bored with what I’m doing.)