Recent comments
Recent pages
|
GL Line Structure Patch and JavaScript Is it possible to use a JavaScript patch to create a structure to feed into a GL Line Structure patch? I've tried this as a basic test, which takes in input structure from the Kineme Audio Input patch and creates a struct of points from it: // Initialise objects
var points = new Object();
var levels = new Object();
function (__structure outputStructure) main (__structure inputStructure, __number dummy)
{
// Adjustment variables
var dist = 0.05; // Distance between points on X-axis
var offsetx = 0.25; // Offset on X-axis
var scaley = 5.0; // Scale points on Y-axis
// Copy input levels struct if not undefined
if(inputStructure != undefined)
{
levels = inputStructure[0];
}
// Create points structure
for(i = 0; i < 64; i++) {
px = dist * i - offsetx; // Point X
py = levels[i] * scaley; // Point Y
points[i] = Array(px,py,0); // Point XYZ
}
var result = new Object();
result.outputStructure = points;
return result;
}The weird thing is, the items in the structure appearing at the output aren't in the right order. Any way to get the structure into the right order so that the resulting lines make some kind of sense? a|x
|
Structure Sort patch.
I'd assumed you could only sort keyed structures, but entering 0 in the descriptor field works a treat.
alx
Quartz Composer Blog:
http://machinesdontcare.wordpress.com
Music Site:
http://www.toneburst.net