Forums > Javascript

placing on matrix inside another


Jan
September 9, 2009 | 9:50 pm

Hello,

i am in the process of learning how to use javascript with jitter. at the moment i am stuck with a seemingly very basic problem. I want to place on (smaller) matrix inside anothe (bigger one) to achieve somthing similar like in the patch below.

My problem is: how do i fill on matrix into another using javascript.
my javascript code is something like that

var smallmatrix = new JitterMatrix(4, "char", 320, 240);
var largematrix = new JitterMatrix(4, "char", 720, 450);

largematrix.usedstdim = 1;
largematrix.dstdimstart = [10, 10];
largematrix.dstdimend = [330, 250];

//[some foo filling the small matrix]

function bang() {
// and here starts my problem. If I use:
largematrix = smallmatrix;
// the largematrix is just identical to the smallmatrix.
//is there a function that i can use?

– Pasted Max Patch, click to expand. –


jml
September 10, 2009 | 10:54 pm

I don’t have much time to write up a fresh example, but perhaps this will help you:

var noiz = new JitterObject("jit.noise");
noiz.type = "char";
noiz.planecount = 1;
noiz.dim = [4, 4];
noiz.name = "noisay";

function bang()
{
  copymat(noiz);
}

function copymat(iname)
{
  var input = new JitterMatrix("inamed", iname.planecount, iname.type, iname.dim);
  var output = new JitterMatrix("outr", iname.planecount, iname.type, iname.dim);
  noiz.matrixcalc(input, output);
  outlet(0, "jit_matrix", output.name);
}

jml



jml
September 10, 2009 | 10:54 pm

I don’t have much time to write up a fresh example, but perhaps this will help you:

var noiz = new JitterObject("jit.noise");
noiz.type = "char";
noiz.planecount = 1;
noiz.dim = [4, 4];
noiz.name = "noisay";

function bang()
{
  copymat(noiz);
}

function copymat(iname)
{
  var input = new JitterMatrix("inamed", iname.planecount, iname.type, iname.dim);
  var output = new JitterMatrix("outr", iname.planecount, iname.type, iname.dim);
  noiz.matrixcalc(input, output);
  outlet(0, "jit_matrix", output.name);
}

jml


Viewing 3 posts - 1 through 3 (of 3 total)