Thanks in large part to @zranger1 I’ve been spending a lot of time with shaders, Shadertoy, signed distance functions/fields, and so on.
Vectors are really variables of multiple dimensions. So a vec2 might have an x and y component, and vec3 would have an x,y,z, and a vec4 would have x,y,z,w.
Not that you’d have to have them represent spacial references. For example, an RGB color is a vec3, and instead of xyz, would be rgb.
I believe we can emulate a lot but not all of the vector stuff in PB, by using arrays. But we also lack array math. For example, you can add two vec2s,
sum = vec2(1,1) + vec2 (1.1,1.3) Or A = vec2(1,1) B = vec2(1,0) C = A+B
and you’ll get the Xs added together and Ys added together. But we can’t trivially write this in PB (yet). We probably will have to write a function like vadd() and do this:
A = vec2(1,1) B = vec2(1,0) C = vadd(A,B)
I’m imagining vec2 as a function returning a array, and then vadd as taking two arrays and adding them.
So far this seems like it’ll work.
Pulling out vector components is usually written
A= vec2(1,0) B = A.x // Would be equal to 1
So I’m fine with having to fake it like so:
var x = 0 //global indexing, x is always 0
B = A[x]// Would be equal to 1
I’m gonna flesh this out more. One more step towards PB as an led shader.