Skip to content

Instantly share code, notes, and snippets.

@GoodBoyDigital
Created January 20, 2015 15:43
Show Gist options
  • Save GoodBoyDigital/03e8b3d949cc591d1adc to your computer and use it in GitHub Desktop.
Save GoodBoyDigital/03e8b3d949cc591d1adc to your computer and use it in GitHub Desktop.
FilterManager.prototype.calculateMagixMatrix = function (filterArea, wt)
{
var m = new math.Matrix();
// scale..
var ratio = this.textureSize.height / this.textureSize.width;
m.translate(filterArea.x / (this.textureSize.width), filterArea.y / this.textureSize.height);
m.scale(1 , ratio);
var transform = wt.clone();
var translateScaleX = (this.textureSize.width / 620);
var translateScaleY = (this.textureSize.height / 380);
transform.tx /= 620 * translateScaleX;
transform.ty /= 620 * translateScaleX;
transform.invert();
transform.append(m);
// apply inverse scale..
transform.scale(1 , 1/ratio);
transform.scale( translateScaleX , translateScaleY );
return transform;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment