आप वास्तव में जो भी आप ऑफस्क्रीन कैनवास में घूमना चाहते हैं उसे आकर्षित कर सकते हैं और इसे अपने मुख्य कैनवास में खींच सकते हैं। मैं एक गूगल आईओ टॉक से इस कोड को उधार:
rotobj = rotateAndCache(myimg,myangle)
और अपने drawcode में:
rotateAndCache = function(image,angle) {
var offscreenCanvas = document.createElement('canvas');
var offscreenCtx = offscreenCanvas.getContext('2d');
var size = Math.max(image.width, image.height);
offscreenCanvas.width = size;
offscreenCanvas.height = size;
offscreenCtx.translate(size/2, size/2);
offscreenCtx.rotate(angle + Math.PI/2);
offscreenCtx.drawImage(image, -(image.width/2), -(image.height/2));
return offscreenCanvas;
}
तो साथ यह कैश
mycontext.drawImage(rotobj,x_coord,y_coord)
यह केवल उपयोगी है जब आप एक वस्तु है जो केवल एक बार कोण से घुमाया जाता है और बाद में केवल परिवर्तनों के अधीन होता है।
धन्यवाद पीटर टी। यह उस बिल को लगभग फिट करता है जिसे मैं ढूंढ रहा था। एक बार फिर धन्यवाद। – Vinayak
क्या आपके पास उस बात का लिंक है? – Alexander
@Alexander वास्तव में मैं करता हूं: http://www.google.com/events/io/2011/sessions/super-browser-2-turbo-hd-remix-introduction-to-html5-game-development.html वीडियो http://www.youtube.com/watch?v=yEocRtn_j9s – PeterT