@@ 489-511 (lines=23) @@ | ||
486 | @example |
|
487 | myimage.draw(destcanvas,10,10,1,0,1,1); |
|
488 | */ |
|
489 | this.draw = function(dst,x,y,alpha, rot,w,h){ |
|
490 | var tmp=dst.contex.globalAlpha; |
|
491 | if(typeof(alpha)=='undefined') alpha=1; |
|
492 | dst.contex.globalAlpha=alpha; |
|
493 | if(arguments.length==3 || arguments.length==4) |
|
494 | dst.contex.drawImage(this.img, x-this.handlex,y-this.handley); |
|
495 | else if(arguments.length==5){ |
|
496 | dst.contex.translate(x,y); |
|
497 | dst.contex.rotate(rot*Math.PI/180); |
|
498 | dst.contex.translate(-this.handlex,-this.handley); |
|
499 | dst.contex.drawImage(this.img, 0,0); |
|
500 | dst.contex.setTransform(1, 0, 0, 1, 0, 0); |
|
501 | } |
|
502 | else{ |
|
503 | dst.contex.translate(x,y); |
|
504 | dst.contex.rotate(rot*Math.PI/180); |
|
505 | dst.contex.scale(w,h); |
|
506 | dst.contex.translate(-this.handlex,-this.handley); |
|
507 | dst.contex.drawImage(this.img, 0,0); |
|
508 | dst.contex.setTransform(1, 0, 0, 1, 0, 0); |
|
509 | } |
|
510 | dst.contex.globalAlpha=tmp; |
|
511 | } |
|
512 | ||
513 | /** |
|
514 | <b>Draw a tile from this image to a canvas.</b><br> |
|
@@ 264-286 (lines=23) @@ | ||
261 | @example |
|
262 | mycanvas.draw(destcanvas,10,10,1,0,1,1); |
|
263 | */ |
|
264 | this.draw = function(dst,x,y,alpha, rot,w,h){ |
|
265 | var tmp=dst.contex.globalAlpha; |
|
266 | if(typeof(alpha)=='undefined') alpha=1; |
|
267 | dst.contex.globalAlpha=alpha; |
|
268 | if(arguments.length==3 || arguments.length==4) |
|
269 | dst.contex.drawImage(this.canvas, x-this.handlex,y-this.handley); |
|
270 | else if(arguments.length==5){ |
|
271 | dst.contex.translate(x,y); |
|
272 | dst.contex.rotate(rot*Math.PI/180); |
|
273 | dst.contex.translate(-this.handlex,-this.handley); |
|
274 | dst.contex.drawImage(this.canvas, 0,0); |
|
275 | dst.contex.setTransform(1, 0, 0, 1, 0, 0); |
|
276 | } |
|
277 | else{ |
|
278 | dst.contex.translate(x,y); |
|
279 | dst.contex.rotate(rot*Math.PI/180); |
|
280 | dst.contex.scale(w,h); |
|
281 | dst.contex.translate(-this.handlex,-this.handley); |
|
282 | dst.contex.drawImage(this.canvas, 0,0); |
|
283 | dst.contex.setTransform(1, 0, 0, 1, 0, 0); |
|
284 | } |
|
285 | dst.contex.globalAlpha=tmp; |
|
286 | } |
|
287 | ||
288 | /** |
|
289 | <b>Draw a tile from this canvas to another canvas.</b><br> |