@@ -619,6 +619,7 @@ _html2canvas.Parse = function ( images, options ) {
619
619
by ,
620
620
bw ,
621
621
bh ,
622
+ i ,
622
623
borderArgs ,
623
624
borderBounds ,
624
625
borders = ( function ( el ) {
@@ -636,9 +637,10 @@ _html2canvas.Parse = function ( images, options ) {
636
637
return borders ;
637
638
638
639
} ( el ) ) ,
640
+ // http://www.w3.org/TR/css3-background/#the-border-radius
639
641
borderRadius = ( function ( el ) {
640
642
var borders = [ ] ,
641
- sides = [ "TopLeft" , "TopRight" , "BottomLeft " , "BottomRight " ] ,
643
+ sides = [ "TopLeft" , "TopRight" , "BottomRight " , "BottomLeft " ] ,
642
644
s ;
643
645
644
646
for ( s = 0 ; s < 4 ; s += 1 ) {
@@ -664,42 +666,47 @@ _html2canvas.Parse = function ( images, options ) {
664
666
// top border
665
667
bh = borders [ 0 ] . width ;
666
668
667
- borderArgs [ 0 ] = [ bx , by ] ; // top left
668
- borderArgs [ 1 ] = [ bx + bw , by ] ; // top right
669
- borderArgs [ 2 ] = [ bx + bw - borders [ 1 ] . width , by + bh ] ; // bottom right
670
- borderArgs [ 3 ] = [ bx + borders [ 3 ] . width , by + bh ] ; // bottom left
669
+ i = 0 ;
670
+ borderArgs [ i ++ ] = [ "line" , bx , by ] ; // top left
671
+ borderArgs [ i ++ ] = [ "line" , bx + bw , by ] ; // top right
672
+ borderArgs [ i ++ ] = [ "line" , bx + bw - borders [ 1 ] . width , by + bh ] ; // bottom right
673
+ borderArgs [ i ++ ] = [ "line" , bx + borders [ 3 ] . width , by + bh ] ; // bottom left
671
674
672
675
break ;
673
676
case 1 :
674
677
// right border
675
678
bx = x + w - ( borders [ 1 ] . width ) ;
676
679
bw = borders [ 1 ] . width ;
677
680
678
- borderArgs [ 0 ] = [ bx , by + borders [ 0 ] . width ] ; // top left
679
- borderArgs [ 1 ] = [ bx + bw , by ] ; // top right
680
- borderArgs [ 2 ] = [ bx + bw , by + bh + borders [ 2 ] . width ] ; // bottom right
681
- borderArgs [ 3 ] = [ bx , by + bh ] ; // bottom left
681
+ i = 0 ;
682
+ borderArgs [ i ++ ] = [ "line" , bx , by + borders [ 0 ] . width ] ; // top left
683
+ borderArgs [ i ++ ] = [ "line" , bx + bw , by ] ; // top right
684
+ borderArgs [ i ++ ] = [ "line" , bx + bw , by + bh + borders [ 2 ] . width ] ; // bottom right
685
+ borderArgs [ i ++ ] = [ "line" , bx , by + bh ] ; // bottom left
682
686
683
687
break ;
684
688
case 2 :
685
689
// bottom border
686
690
by = ( by + h ) - ( borders [ 2 ] . width ) ;
687
691
bh = borders [ 2 ] . width ;
688
-
689
- borderArgs [ 0 ] = [ bx + borders [ 3 ] . width , by ] ; // top left
690
- borderArgs [ 1 ] = [ bx + bw - borders [ 2 ] . width , by ] ; // top right
691
- borderArgs [ 2 ] = [ bx + bw , by + bh ] ; // bottom right
692
- borderArgs [ 3 ] = [ bx , by + bh ] ; // bottom left
692
+
693
+
694
+ i = 0 ;
695
+ borderArgs [ i ++ ] = [ "line" , bx + borders [ 3 ] . width , by ] ; // top left
696
+ borderArgs [ i ++ ] = [ "line" , bx + bw - borders [ 2 ] . width , by ] ; // top right
697
+ borderArgs [ i ++ ] = [ "line" , bx + bw , by + bh ] ; // bottom right
698
+ borderArgs [ i ++ ] = [ "line" , bx , by + bh ] ; // bottom left
693
699
694
700
break ;
695
701
case 3 :
696
702
// left border
697
703
bw = borders [ 3 ] . width ;
698
704
699
- borderArgs [ 0 ] = [ bx , by ] ; // top left
700
- borderArgs [ 1 ] = [ bx + bw , by + borders [ 0 ] . width ] ; // top right
701
- borderArgs [ 2 ] = [ bx + bw , by + bh ] ; // bottom right
702
- borderArgs [ 3 ] = [ bx , by + bh + borders [ 2 ] . width ] ; // bottom left
705
+ i = 0 ;
706
+ borderArgs [ i ++ ] = [ "line" , bx , by ] ; // top left
707
+ borderArgs [ i ++ ] = [ "line" , bx + bw , by + borders [ 0 ] . width ] ; // top right
708
+ borderArgs [ i ++ ] = [ "line" , bx + bw , by + bh ] ; // bottom right
709
+ borderArgs [ i ++ ] = [ "line" , bx , by + bh + borders [ 2 ] . width ] ; // bottom left
703
710
704
711
break ;
705
712
}
@@ -721,12 +728,13 @@ _html2canvas.Parse = function ( images, options ) {
721
728
if ( borderData . color !== "transparent" ) {
722
729
ctx . setVariable ( "fillStyle" , borderData . color ) ;
723
730
724
- var shape = ctx . drawShape ( ) ;
725
- shape . moveTo . apply ( null , borderArgs [ 0 ] ) ; // top left
726
- shape . lineTo . apply ( null , borderArgs [ 1 ] ) ; // top right
727
- shape . lineTo . apply ( null , borderArgs [ 2 ] ) ; // bottom right
728
- shape . lineTo . apply ( null , borderArgs [ 3 ] ) ; // bottom left
729
- // ctx.fillRect (x, y, w, h);
731
+ var shape = ctx . drawShape ( ) ,
732
+ numBorderArgs = borderArgs . length ;
733
+
734
+ for ( i = 0 ; i < numBorderArgs ; i ++ ) {
735
+ shape [ ( i === 0 ) ? "moveTo" : borderArgs [ i ] [ 0 ] + "To" ] . apply ( null , borderArgs [ i ] . slice ( 1 ) ) ;
736
+ }
737
+
730
738
numDraws += 1 ;
731
739
}
732
740
0 commit comments