Cast long matrix to char in javascript environment?

bd's icon

Hi,

I am trying to convert a jitter matrix of type long (1 plane) to type char within the javascript environment. (The values in the long matrix have already been conditioned to 0-255; that is not the issue.)

Easy enough in a patcher, but how to perform this 'cast' in javascript?

Any help would be greatly appreciated.

Thanks,
bd

Joshua Kit Clayton's icon

outlets = 2;

function bang()
{
var ml = new JitterMatrix(1, "long", 10, 10);
var mc = new JitterMatrix(1, "char", 10, 10);

mc.frommatrix(ml);

outlet(1,"jit_matrix",ml.name);
outlet(0,"jit_matrix",mc.name);
}

// or in a more dynamic fashion
function dynamo()
{
var ml = new JitterMatrix(1, "long", 74, 74);
var mc = new JitterMatrix();

mc.adapt = 0;
mc.planecount = ml.planecount;
mc.type = "char";
mc.dim = ml.dim;

mc.frommatrix(ml);

outlet(1,"jit_matrix",ml.name);
outlet(0,"jit_matrix",mc.name);
}

bd's icon

Joshua-- thank you.