alpha mask with and javascript

    Jan 13 2013 | 12:26 am
    Hello all,
    I like to use the object in javascript for dynamically use alpha masks.
    I tried it this way, unfortunately not very successful:
    inlets = 2; outlets = 1;
    var tmpmatrix = new JitterMatrix();
    var plane = new JitterObject("","foo"); plane.blend_enable = 1;
    var slab = new JitterObject("","foo"); slab.file = "cc.alphaglue.jxs";
    plane.texture = slab.texture;
    function jit_matrix(inname) { if(inlet == 1) { tmpmatrix = inname; } else { slab.jit_matrix([inname,tmpmatrix]); slab.draw();
    plane.texture = slab.texture;
    // post(slab.file); } }
    I'm not sure, if the js slab object handles the input of 2 inlets like an array to the jit_matrix method. I'm also not sure, if the initialisation of the js slab object is correct by assigning the "file" attribute to the desired file name. If I post the file attribute Max crashes.
    Hopefully somebody can help! Thanks Roland

    • Jan 13 2013 | 5:33 pm
      After Max also was crashing using a second in the patcher window, without any javascript, I found another solution, dropping the slab object, using jit.pack instead:
      var plane = new JitterObject("","poo"); var maskmatrix = new JitterMatrix(4,"char",320,240); var tmpmatrix = new JitterMatrix(4,"char",320,240);
      var pack = new JitterObject("jit.pack"); pack.offset = [1,1]; pack.jump = [1,3];
      function jit_matrix(inname) { if(inlet == 1) { maskmatrix.setinfo(inname); maskmatrix.frommatrix(inname); } else { pack.matrixcalc([inname,],tmpmatrix); plane.jit_matrix(; } }
      Cheers, Roland.
    • Jan 16 2013 | 3:25 pm
      Hm, after making a detour, I'm at this point again, that I need to use objects in Javascript. Please, does anybody know how to use for alpha masking in Javascript or have a good example, how to handle open gl objects with two inlets in JS? I tried al lot and have no ideas anymore. Thanks, Roland.
    • Jan 16 2013 | 5:56 pm
      hi roland. it's a little tricky, but entirely possible. the trick is to use the "activeinput" attribute to tell the slab which input will receive the textures or matrices. after that, you simply use the "jit_matrix" or "jit_gl_texture" messages followed by the matrix or texture name.
      i've attached a js and max patch to demonstrate.
    • Jan 16 2013 | 11:46 pm
      That was exactly what I needed, thanks a lot Rob.
    • Mar 10 2013 | 10:30 pm
      Wow, Rob, your patcher and JS are like the Rosetta Stone! Passing a jit_matrix into a named function, ie not jit_matrix(), rendering in JS, slabs in JS are things I've needed and had a hard time finding documentation on. Thanks! Andrew