Index: excanvas.js =================================================================== --- excanvas.js (revision 63) +++ excanvas.js (working copy) @@ -255,6 +255,7 @@ o2.arcScaleX_ = o1.arcScaleX_; o2.arcScaleY_ = o1.arcScaleY_; o2.lineScale_ = o1.lineScale_; + o2.rotation_ = o1.rotation_; // used for images } var colorData = { @@ -599,6 +600,7 @@ this.arcScaleX_ = 1; this.arcScaleY_ = 1; this.lineScale_ = 1; + this.rotation_ = 0; } var contextPrototype = CanvasRenderingContext2D_.prototype; @@ -763,23 +765,31 @@ return gradient; }; - contextPrototype.drawImage = function(image, var_args) { + contextPrototype.drawImage = function(image) { var dx, dy, dw, dh, sx, sy, sw, sh; - + + // to fix new Image() we check the existance of runtimeStyle + var rts = image.runtimeStyle.width; + // to find the original width we overide the width and height - var oldRuntimeWidth = image.runtimeStyle.width; - var oldRuntimeHeight = image.runtimeStyle.height; - image.runtimeStyle.width = 'auto'; - image.runtimeStyle.height = 'auto'; + if(rts) { + var oldRuntimeWidth = image.runtimeStyle.width; + var oldRuntimeHeight = image.runtimeStyle.height; + + image.runtimeStyle.width = 'auto'; + image.runtimeStyle.height = 'auto'; + } // get the original size var w = image.width; var h = image.height; - + // and remove overides - image.runtimeStyle.width = oldRuntimeWidth; - image.runtimeStyle.height = oldRuntimeHeight; - + if(rts) { + image.runtimeStyle.width = oldRuntimeWidth; + image.runtimeStyle.height = oldRuntimeHeight; + } + if (arguments.length == 3) { dx = arguments[1]; dy = arguments[2]; @@ -816,29 +826,44 @@ var W = 10; var H = 10; + + var scaleX = scaleY = 1; + + // FIX: divs give better quality then vml image and also fixes transparent PNG's + vmlStr.push('
' , - '', - ''); + vmlStr.push(' ">'); - this.element_.insertAdjacentHTML('BeforeEnd', vmlStr.join('')); + // Draw a special cropping div if needed + if (sx || sy) { + // Apply scales to width and height + vmlStr.push('
'); + } + + + // Apply scales to width and height + vmlStr.push('
'); + + // Close the crop div if necessary + if (sx || sy) vmlStr.push('
'); + + vmlStr.push('
'); + + this.element_.insertAdjacentHTML('beforeEnd', vmlStr.join('')); }; contextPrototype.stroke = function(aFill) { @@ -1155,6 +1197,8 @@ var c = mc(aRot); var s = ms(aRot); + this.rotation_ += aRot; + var m1 = [ [c, s, 0], [-s, c, 0], @@ -1308,7 +1352,11 @@ } var doc = this.element_.ownerDocument; this.textMeasureEl_.innerHTML = ''; - this.textMeasureEl_.style.font = this.font; + // FIX: Apply current font style to textMeasureEl to get correct size + var fontStyle = getComputedStyle(processFontStyle(this.font), this.element_), + fontStyleString = buildStyle(fontStyle); + this.textMeasureEl_.style.font = fontStyleString; + // Don't use innerHTML or innerText because they allow markup/whitespace. this.textMeasureEl_.appendChild(doc.createTextNode(text)); return {width: this.textMeasureEl_.offsetWidth};