3 ms·
> If you evaluate the expression with (x,y) values in the ±1 square, then color pixels black or white based on their sign I do not understand what this means a
by stevage 2y ago
> If you evaluate the expression with (x,y) values in the ±1 square, then color pixels black or white based on their sign
I do not understand what this means at all, particularly the bit before the comma.
Can someone explain it differently?
- cjs_ac 2y agoYeah, this took me a while. Basically, the entire file represents a sort of assembly language for a function. You need to evaluate that entire function for each pixel in the output image. Each line starts with a line number (with a leading underscore). This is followed by an instruction, and zero, one, or two arguments. The arguments can be either floating point constants or integers (with leading underscores) which represent the results of those corresponding lines earlier in the function. The x and y coordinates of each pixel are loaded in the assembly language using the var-x and var-y instructions.
- jstanley 2y agoBreak down the range of x values from -1 to 1, and y values from -1 to 1, each into 1024 parts (or whatever resolution you want to plot at). Evaluate the function for each (x,y) coordinate. If the resulting number is negative colour the pixel white, otherwise colour it black. The expression is (probably) a 2d signed-distance function - https://en.wikipedia.org/wiki/Signed_distance_function https://en.wikipedia.org/wiki/Signed_distance_function
- stevage 2y agoOhh.. "the +/- 1 square" means a square of size 2 centred around the origin? That was way too terse for me.
- iamwil 2y agoFor a given (x, y), you color the pixel black if you're outside of a shape, and color the pixel white if you're inside the shape. The math formula is a way to describe the contour of the shape. To tell if you're inside or outside of a shape, you plug in your (x, y) coordinate into the math formula, and if the output is > 0, then you're outside. If the output is < 0, then you're inside. I think they call it a signed distance field. You should watch his talk that explain it. It's really great. https://www.youtube.com/watch?v=UxGxsGnbyJ4 https://www.youtube.com/watch?v=UxGxsGnbyJ4