• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.graphics.drawable.shapes;
18 
19 import android.graphics.Canvas;
20 import android.graphics.Paint;
21 
22 /**
23  * Creates an arc shape. The arc shape starts at a specified
24  * angle and sweeps clockwise, drawing slices of pie.
25  * The arc can be drawn to a Canvas with its own draw() method,
26  * but more graphical control is available if you instead pass
27  * the ArcShape to a {@link android.graphics.drawable.ShapeDrawable}.
28  */
29 public class ArcShape extends RectShape {
30     private float mStart;
31     private float mSweep;
32 
33     /**
34      * ArcShape constructor.
35      *
36      * @param startAngle the angle (in degrees) where the arc begins
37      * @param sweepAngle the sweep angle (in degrees). Anything equal to or
38      *                   greater than 360 results in a complete circle/oval.
39      */
ArcShape(float startAngle, float sweepAngle)40     public ArcShape(float startAngle, float sweepAngle) {
41         mStart = startAngle;
42         mSweep = sweepAngle;
43     }
44 
45     @Override
draw(Canvas canvas, Paint paint)46     public void draw(Canvas canvas, Paint paint) {
47         canvas.drawArc(rect(), mStart, mSweep, true, paint);
48     }
49 }
50 
51