本文介绍了填写正弦图的Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个code:
public class TestView extends View {
private Path mPath;
private Paint mPaint = new Paint();
public TestView(Context context) {
this(context, null);
}
public TestView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public TestView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mPath = new Path();
mPath.moveTo(0, 0);
mPath.quadTo(50, -50, 100, 0);
mPath.quadTo(150, 50, 200, 0);
mPath.quadTo(250, -50, 300, 0);
mPath.quadTo(350, 50, 400, 0);
mPath.quadTo(450, -50, 500, 0);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.save();
canvas.translate(0, getMeasuredHeight() / 2F);
// just making sure to clip starting and ending curve
canvas.clipRect(50, -100, 450, 100, Region.Op.INTERSECT);
canvas.drawPath(mPath, mPaint);
canvas.restore();
}
}
这会产生这样的:
不过,我想这(原谅我画图的技能):
But I want this (pardon my Paint skills):
在这个正弦曲线下灌装区将AP preciated任何帮助。
Any help on filling area under this sine curve will be appreciated.
推荐答案
更改值
mPath.moveTo(0,100);
mPath.quadTo(50, -50, 100, 0);
mPath.quadTo(150, 50, 200, 0);
mPath.quadTo(250, -50, 300, 0);
mPath.quadTo(350, 50, 400, 0);
mPath.quadTo(450, -50, 500, 100);
这篇关于填写正弦图的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!