@@ -43,7 +43,8 @@ function html2canvas(el, userOptions) {
4343 ready : function ( canvas ) {
4444 document . body . appendChild ( canvas ) ;
4545 } ,
46- renderViewport : true
46+ flashCanvasPath : "http://html2canvas.hertzen.com/external/flashcanvas/flashcanvas.js" ,
47+ renderViewport : false
4748 } ) ;
4849
4950 this . element = el ;
@@ -89,26 +90,25 @@ html2canvas.prototype.init = function(){
8990 this . canvas . width = $ ( document ) . width ( ) ;
9091 this . canvas . height = $ ( document ) . height ( ) ;
9192
92-
93+
94+
9395
9496 if ( ! this . canvas . getContext ) {
97+
98+ // TODO include Flashcanvas
99+ /*
100+ var script = document.createElement('script');
101+ script.type = "text/javascript";
102+ script.src = this.opts.flashCanvasPath;
103+ var s = document.getElementsByTagName('script')[0];
104+ s.parentNode.insertBefore(script, s);
105+
106+ if (typeof FlashCanvas != "undefined") {
107+
108+ FlashCanvas.initElement(this.canvas);
109+ this.ctx = this.canvas.getContext('2d');
110+ } */
95111
96- // TODO include Flashcanvas
97- /*
98-
99- var script = document.createElement('script');
100- script.type = "text/javascript";
101- script.src = "flashcanvas.js";
102- var s = document.getElementsByTagName('script')[0];
103- s.parentNode.insertBefore(script, s);
104-
105-
106- if (typeof FlashCanvas != "undefined") {
107-
108- FlashCanvas.initElement(canvas);
109- ctx = canvas.getContext('2d');
110- }
111- */
112112 } else {
113113 this . ctx = this . canvas . getContext ( '2d' ) ;
114114 }
@@ -220,7 +220,7 @@ html2canvas.prototype.drawBackground = function(el,bounds){
220220 bgp . top = bgp . top - Math . ceil ( bgp . top / image . height ) * image . height ;
221221
222222
223- for ( bgy = ( bounds . top + bgp . top ) ; bgy <= bounds . height + bounds . top ; ) {
223+ for ( bgy = ( bounds . top + bgp . top ) ; bgy < bounds . height + bounds . top ; ) {
224224
225225
226226
@@ -289,17 +289,25 @@ html2canvas.prototype.getBackgroundPosition = function(el,bounds,image){
289289 top ,
290290 left ,
291291 percentage ;
292-
293292
294- if ( bgposition [ 0 ] . indexOf ( "%" ) != - 1 ) {
293+ if ( bgposition . length == 1 ) {
294+ var val = bgposition ,
295+ bgposition = [ ] ;
296+
297+ bgposition [ 0 ] = val ,
298+ bgposition [ 1 ] = val ;
299+ }
295300
301+ if ( bgposition [ 0 ] . toString ( ) . indexOf ( "%" ) != - 1 ) {
302+
296303 percentage = ( parseFloat ( bgposition [ 0 ] ) / 100 ) ;
297304 left = ( ( bounds . width * percentage ) - ( image . width * percentage ) ) ;
305+
298306 } else {
299307 left = parseInt ( bgposition [ 0 ] , 10 ) ;
300308 }
301-
302- if ( bgposition [ 1 ] . indexOf ( "%" ) != - 1 ) {
309+
310+ if ( bgposition [ 1 ] . toString ( ) . indexOf ( "%" ) != - 1 ) {
303311
304312 percentage = ( parseFloat ( bgposition [ 1 ] ) / 100 ) ;
305313 top = ( ( bounds . height * percentage ) - ( image . height * percentage ) ) ;
@@ -325,7 +333,7 @@ html2canvas.prototype.drawbackgroundRepeatY = function(image,bgp,x,y,w,h){
325333 bgp . top = bgp . top - Math . ceil ( bgp . top / image . height ) * image . height ;
326334
327335
328- for ( bgy = ( y + bgp . top ) ; bgy <= h + y ; ) {
336+ for ( bgy = ( y + bgp . top ) ; bgy < h + y ; ) {
329337
330338
331339 if ( Math . floor ( bgy + image . height ) > h + y ) {
@@ -349,7 +357,7 @@ html2canvas.prototype.drawbackgroundRepeatX = function(image,bgp,x,y,w,h){
349357 bgp . left = bgp . left - Math . ceil ( bgp . left / image . width ) * image . width ;
350358
351359
352- for ( bgx = ( x + bgp . left ) ; bgx <= w + x ; ) {
360+ for ( bgx = ( x + bgp . left ) ; bgx < w + x ; ) {
353361
354362 if ( Math . floor ( bgx + image . width ) > w + x ) {
355363 width = ( w + x ) - bgx ;
@@ -375,7 +383,7 @@ html2canvas.prototype.drawBackgroundRepeat = function(image,x,y,width,height,elx
375383 if ( ely - y > 0 ) {
376384 sourceY = ely - y ;
377385 }
378-
386+
379387 this . ctx . drawImage (
380388 image ,
381389 sourceX , // source X
0 commit comments