(aWidth, aHeight, aFormat)
| 8479 | } |
| 8480 | |
| 8481 | var PImage = function PImage(aWidth, aHeight, aFormat) { |
| 8482 | this.get = function(x, y, w, h) { |
| 8483 | if (!arguments.length) { |
| 8484 | return p.get(this); |
| 8485 | } else if (arguments.length === 2) { |
| 8486 | return p.get(x, y, this); |
| 8487 | } else if (arguments.length === 4) { |
| 8488 | return p.get(x, y, w, h, this); |
| 8489 | } |
| 8490 | }; |
| 8491 | |
| 8492 | this.set = function(x, y, c) { |
| 8493 | p.set(x, y, c, this); |
| 8494 | }; |
| 8495 | |
| 8496 | this.blend = function(srcImg, x, y, width, height, dx, dy, dwidth, dheight, MODE) { |
| 8497 | if (arguments.length === 9) { |
| 8498 | p.blend(this, srcImg, x, y, width, height, dx, dy, dwidth, dheight, this); |
| 8499 | } else if (arguments.length === 10) { |
| 8500 | p.blend(srcImg, x, y, width, height, dx, dy, dwidth, dheight, MODE, this); |
| 8501 | } |
| 8502 | }; |
| 8503 | |
| 8504 | this.copy = function(srcImg, sx, sy, swidth, sheight, dx, dy, dwidth, dheight) { |
| 8505 | if (arguments.length === 8) { |
| 8506 | p.blend(this, srcImg, sx, sy, swidth, sheight, dx, dy, dwidth, p.REPLACE, this); |
| 8507 | } else if (arguments.length === 9) { |
| 8508 | p.blend(srcImg, sx, sy, swidth, sheight, dx, dy, dwidth, dheight, p.REPLACE, this); |
| 8509 | } |
| 8510 | }; |
| 8511 | |
| 8512 | this.filter = function(mode, param) { |
| 8513 | if (arguments.length === 2) { |
| 8514 | p.filter(mode, param, this); |
| 8515 | } else if (arguments.length === 1) { |
| 8516 | // no param specified, send null to show its invalid |
| 8517 | p.filter(mode, null, this); |
| 8518 | } |
| 8519 | }; |
| 8520 | |
| 8521 | this.save = function(file){ |
| 8522 | p.save(file,this); |
| 8523 | }; |
| 8524 | |
| 8525 | this.resize = function(w, h) { |
| 8526 | if (this.width !== 0 || this.height !== 0) { |
| 8527 | // make aspect ratio if w or h is 0 |
| 8528 | if (w === 0 && h !== 0) { |
| 8529 | w = this.width / this.height * h; |
| 8530 | } else if (h === 0 && w !== 0) { |
| 8531 | h = w / (this.width / this.height); |
| 8532 | } |
| 8533 | // put 'this.imageData' into a new canvas |
| 8534 | var canvas = getCanvasData(this.imageData).canvas; |
| 8535 | // pull imageData object out of canvas into ImageData object |
| 8536 | var imageData = getCanvasData(canvas, w, h).context.getImageData(0, 0, w, h); |
| 8537 | // set this as new pimage |
| 8538 | this.fromImageData(imageData); |
nothing calls this directly
no test coverage detected