Path的使用

本文详细介绍了 Android 中 Path 类的功能及使用方法,包括如何创建复合几何路径,并通过 moveTo、lineTo、reset 和 quadTo 方法来控制路径的绘制。此外,还介绍了 Path 在 Android Canvas 上的绘制方式。

http://developer.android.com/reference/android/graphics/Path.html

public class

Path

extends  Object
java.lang.Object
   ↳ android.graphics.Path

Class Overview

The Path class encapsulates compound (multiple contour) geometric paths consisting of straight line segments, quadratic curves, and cubic curves. It can be drawn with canvas.drawPath(path, paint), either filled or stroked (based on the paint's Style), or it can be used for clipping or to draw text on a path.

Path类封装了多个化合物(轮廓)的直线段,二次曲线,三次曲线组成的几何路径。它可以绘制canvas.drawPath(路径,paint),要么填充或描边(基于paint's 风格),或者它可以用于裁剪或绘制路径上的文本。

public void moveTo (float x, float y)
Since:  API Level 1

Set the beginning of the next contour to the point (x,y).设定next的轮廓开始的点(X,Y)。

Parameters
x The x-coordinate of the start of a new contour
y The y-coordinate of the start of a new contour
public void lineTo (float x, float y)
Since:  API Level 1

Add a line from the last point to the specified point (x,y). If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).

添加一行从最后一点到指定点(X,Y)。如果没有moveTo()调用中已作出这个轮廓,第一点被自动设置为(0,0)。



Parameters
x The x-coordinate of the end of a line
y The y-coordinate of the end of a line
public void reset ()
Since:  API Level 1

Clear any lines and curves from the path, making it empty. This does NOT change the fill-type setting.

清除任何直线和曲线路径,使它成为空的。这并没有清除填充类型设置。


public void quadTo (float x1, float y1, float x2, float y2)
Since:  API Level 1

Add a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2). If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).

Parameters
x1 The x-coordinate of the control point on a quadratic curve
y1 The y-coordinate of the control point on a quadratic curve
x2 The x-coordinate of the end point on a quadratic curve
y2 The y-coordinate of the end point on a quadratic curve

二次贝塞尔加入最后一点,接近控制点(X1,Y1),和结束​​时(X2,Y2)。如果没有moveTo()调用中已作出这个轮廓,第一点被自动设置为(0,0)。

参数
X1 二次曲线的控制点的x坐标
Y1 二次曲线的控制点上的y坐标
X2 二次曲线的终点的x坐标
Y2 二次曲线的终点y坐标





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值