quintindunn / threadArt

2 stars 0 forks source link

Custom Algorithm with colors #2

Open quintindunn opened 6 hours ago

quintindunn commented 6 hours ago

I'd like to try to create my own implantation from scratch, with color support.

I'm not quite sure how I want to do this just yet however. The final project needs to be able to be ran on a robot, which switching colors every line is not feasible, so they'd probably have to be layered on.

The first thing that came to my mind was how printers work, using the CMYK color scheme. If I convert the image from RGB -> CMYK, extract the color channels and run it with MAX_LINES/len(COLOR_CHANNELS) lines per color, then create a final image stacking the colors on top of each other, with len(COLOR_CHANNELS) sequences, it might look okay. An issue I see with this however is each sequence being independent, they all will work for the same goal, and might end up fighting.

Another way this could be implemented, still using CMYK would be to run it linearly, but every MAX_LINES/len(COLOR_CHANNELS) lines, swap the channel it's looking at, and the color being pasted in, but keep the context of the previous sequences.

A final way I could see this working would be to stay in a simpler color space like RGB. I would keep a list of the colors being used, and using Euclidian distance to see how far we are from the target, the error would in theory still optimize itself. We then would just keep track of when we swap the color we're writing, and map that to a different sequence.

quintindunn commented 6 hours ago

The robot I had in mind while writing this is from my StringArtRobot project. image I can't think of a reason why I couldn't duplicate the arm 3 more times to hold the CMYK color space, then swap between the arms while printing it out, allowing the intertwining of different colors. The output sequence could simply hold a prefix such as <TOOL_ID>-<PIN>, with TOOL_ID being mapped in the robot's firmware to a specific arm with specific colors.

As a bonus I think the robot would look a lot cooler, however I would see challenges with removing the art piece after it is constructed, so at least one of the arms would need a release/hinge.

quintindunn commented 6 hours ago

Two things: 1.) I just remembered the robot uses relative coordinates so it wouldn't be the robots firmware, but rather the preprocessor.

2.) Another thought I just had would be putting all 4 spools on one of the "arms" and just have 4 servos, 4 needles, 4 spools. I would just need to offset the arms towards the origin of the work piece to keep them aligned correctly, then just calculate where to rotate it with an offset.