@@ -754,13 +754,42 @@ protected void arcImpl(float x, float y, float w, float h,
754
754
}
755
755
} else if (mode == OPEN ) {
756
756
if (fill ) {
757
- showMissingWarning ("arc" );
757
+ // Work around:android does not support storke and fill with different color
758
+ // after drawing the arc,draw the arc with Paint.Style.Stroke style again
759
+ canvas .drawArc (rect , start , sweep , false , fillPaint );
760
+ canvas .drawArc (rect , start , sweep , false , strokePaint );
758
761
}
759
762
if (stroke ) {
760
763
canvas .drawArc (rect , start , sweep , false , strokePaint );
761
764
}
762
765
} else if (mode == CHORD ) {
763
- showMissingWarning ("arc" );
766
+ // Work around: draw an extra line between start angle point and end point
767
+ // to achiece the Chord
768
+ float endAngle = start + sweep ;
769
+ float halfRectWidth = rect .width ()/2 ;
770
+ float halfRectHeight = rect .height ()/2 ;
771
+ float centerX = rect .centerX ();
772
+ float centerY = rect .cenerY ();
773
+
774
+ float startX = (float ) (halfWidth * Math .cos (Math .toRadians (start ))) + centerX ;
775
+ float startY = (float ) (halfHeight * Math .sin (Math .toRadians (start ))) + centerY ;
776
+ float endX = (float ) (halfWidth * Math .cos (Math .toRadians (endAngle ))) + centerX ;
777
+ float endY = (float ) (halfHeight * Math .sin (Math .toRadians (endAngle ))) + centerY ;
778
+
779
+ if (fill ){
780
+ // draw the fill arc
781
+ canvas .drawArc (rect ,start ,sweep ,false ,fillPaint );
782
+ // draw the arc round border
783
+ canvas .drawAcr (rect ,start ,sweep ,false ,strokePaint );
784
+ // draw the straight border
785
+ canvas .drawLine (startX ,startY ,endX ,endY ,strokePaint );
786
+ }
787
+ if (stroke ) {
788
+ // draw the arc
789
+ canvas .drawAcr (rect ,start ,sweep ,false ,strokePaint );
790
+ // draw the straight border
791
+ canvas .drawLine (startX ,startY ,endX ,endY ,strokePaint );
792
+ }
764
793
765
794
} else if (mode == PIE ) {
766
795
if (fill ) {
@@ -2179,4 +2208,4 @@ public void copy(int sx, int sy, int sw, int sh,
2179
2208
// loadPixels();
2180
2209
// super.save(filename);
2181
2210
// }
2182
- }
2211
+ }
0 commit comments