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 17package android.graphics.drawable.shapes; 18 19import android.graphics.Canvas; 20import android.graphics.Paint; 21import android.graphics.RectF; 22 23/** 24 * Creates an arc shape. The arc shape starts at a specified 25 * angle and sweeps clockwise, drawing slices of pie. 26 * The arc can be drawn to a Canvas with its own draw() method, 27 * but more graphical control is available if you instead pass 28 * the ArcShape to a {@link android.graphics.drawable.ShapeDrawable}. 29 */ 30public class ArcShape extends RectShape { 31 private float mStart; 32 private float mSweep; 33 34 /** 35 * ArcShape constructor. 36 * 37 * @param startAngle the angle (in degrees) where the arc begins 38 * @param sweepAngle the sweep angle (in degrees). Anything equal to or 39 * greater than 360 results in a complete circle/oval. 40 */ 41 public ArcShape(float startAngle, float sweepAngle) { 42 mStart = startAngle; 43 mSweep = sweepAngle; 44 } 45 46 @Override 47 public void draw(Canvas canvas, Paint paint) { 48 canvas.drawArc(rect(), mStart, mSweep, true, paint); 49 } 50} 51 52