Author Topic: a node to compile code into an image  (Read 721 times)

would be cool to have a node, that compiles code into a bitmap, let´s say you take this dragon curve transformation

P = (x, y)
w{1}(P) = (-0.5x + 0.5y + 0.5, -0.5x - 0.5y + 0.5)
w{2}(P) = (0.5x + 0.5y + 0.5, -0.5x + 0.5y + 0.5)

and you get something like this as a result:

https://en.wikipedia.org/wiki/Dragon_curve

basically a way to visualize math/algorithms... especially self simliarity (https://en.wikipedia.org/wiki/Self-similarity) would open so many doors when it comes to pattern generation
Last Edit: February 18, 2017, 08:43:16 pm

The pixel processor and FX maps can be treated like code, but each has limitations.
Pixel processor has to excecute code from the point of view of the one pixel that's being drawn to, and each are drawn in parallel. For some mathematical shapes, this is a pretty big obstacle, since it means you can't tell it to write a color to a different pixel. I don't know the format of your dragon curve formula (what is w1 and w2??) but it looks like it might return position, instead of values.

example 1: http://mathworld.wolfram.com/Hypotrochoid.html
I have not found a way to make Hypotrochoids using the pixel processor yet. The link shows a pretty clear formula for making them, but it describes positions determined through iteration, so it can't be calculated all at once by independent pixel calculations like other shapes can be.

example2: http://mathworld.wolfram.com/HeartCurve.html
Most of these heart curves I have made using pixel processor fairly easily. Each pixel can operate independently to determine if it's inside or outside of that curve, by translating position to angle and distance, and applying those formulas to get a value that I can test against a constant and return 1 or 0 as the color.

FXMaps don't have this limitation, you can use positions to determine where a shape is drawn quite easily. But it can only draw shapes or inputs, so it doesn't handle per-pixel image generation as well. For a dragon curve, this would be the tool I'd use.
https://share.allegorithmic.com/libraries/1643
This is a node I made, just for fun, that uses FXMaps to make procedural line drawings iterively, based on mathematical functions. It choses the location based on the Number variable supplied by Iterate, and choses a rotation based on Number+1, to point a line at the next node. Such a technique would work quite well for line-based math functions, I think.

Hi Cory,

as far as I know, w1 and w2 are the two transformations for the dragon curve. I would love to have a node, that allows to play with math and algorithms more directly, compared to the pixel processor and the fx maps.
Something like a mini algorithm compiler inside a node :) I know, I am naive, when it comes to stuff like this.

I will take a closer look on your node. I am curious how you manage to use an fx map to achieve that procedural line drawings.

Would be great to have more in depth tutorials on this topic (functions and fx maps), that function graph will take me a while to understand :O

great stuff, thanks for your help!
Last Edit: February 19, 2017, 11:09:24 am

A scriptable node would be a great resource indeed! most things can be achieved other ways, eventually, but often not easily at all. Let me know if you have any specific questions... Nodes behave like formulas, but they aren't read quite like formulas, and so it's often confusing.