bug with applyMatrix?

edited December 2015 in JavaScript Mode

I cannot successfully convert / run this code with processing.js:

pushMatrix( );

applyMatrix( 
1, tan( radians(45) ), 0,
0, 1, 0
);

fill( 255, 0, 0 );
rect( 0, 0, 50, 50 );
popMatrix( );

Any ideas how to get this to work?

(details about this code http://forum.processing.org/two/discussion/comment/10329#Comment_10329 )

Answers

  • I don't think there is an equivalent version in processing.js

    Their reference for applyMatrix only talks about the 3D version.

  • edited February 2014 Answer ✓

    It prints out this error -> "TypeError: ec is undefined"
    Funny that applyMatrix:function(ea) accepts 6 arguments as well:

    applyMatrix:function(ea) {
      if (arguments.length===1) {
        this.applyMatrix(
        ea.elements[0],ea.elements[1],0,ea.elements[2],ea.elements[3],
        ea.elements[4],0,ea.elements[5],0,0,1,0,0,0,0,1)
      }
    
      else {
        if (arguments.length===6) {
          this.checkMatrix(2);
    
          this.matrix.apply(
          arguments[0],arguments[1],arguments[2],0,arguments[3],
          arguments[4],arguments[5],0,0,0,1,0,0,0,0,1)
        }
    
        else {
            if (arguments.length===16) {
              this.checkMatrix(3);
    
              this.matrix.apply(
              arguments[0],arguments[1],arguments[2],arguments[3],
              arguments[4],arguments[5],arguments[6],
              arguments[7],arguments[8],arguments[9],
              arguments[10],arguments[11],arguments[12],
              arguments[13],arguments[14],arguments[15])
            }
        }
      }
    }
    
  • Re: Lighthouse: Leaving a link to a site with a paywall is useless.

  • That is bad news that the lighthouse site is down. That was where all of the discussion for pjs was going on back when. Alas.

    Here is what I have in one of my copies. I hope this is helpful:

                /**
                 * Multiplies the current matrix by the one specified through the parameters. This is very slow because it will
                 * try to calculate the inverse of the transform, so avoid it whenever possible. The equivalent function
                 * in OpenGL is glMultMatrix().
                 *
                 * @param {int|float} n00-n15      numbers which define the 4x4 matrix to be multiplied
                 *
                 * @returns none
                 *
                 * @see popMatrix
                 * @see pushMatrix
                 * @see resetMatrix
                 * @see printMatrix
                 */
                DrawingShared.prototype.applyMatrix = function() {
                    var a = arguments;
                    modelView.apply(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]);
                    modelViewInv.invApply(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]);
                };
    
                Drawing2D.prototype.applyMatrix = function() {
                    var a = arguments;
                    modelView.apply(a[0], a[1], a[2], a[3], a[4], a[5]);
                    modelViewInv.invApply(a[0], a[1], a[2], a[3], a[4], a[5]);
                    curContext.transform(a[0], a[3], a[1], a[4], a[2], a[5]);
                };
    //            Drawing2D.prototype.applyMatrix = function() {
    //                var a = arguments;
    //                for (var cnt = a.length; cnt < 16; cnt++) {
    //                    a[cnt] = 0;
    //                }
    //                a[10] = a[15] = 1;
    //                DrawingShared.prototype.applyMatrix.apply(this, a);
    //            };````
    
Sign In or Register to comment.