本文整理汇总了Java中android.graphics.Path.setFillType方法的典型用法代码示例。如果您正苦于以下问题:Java Path.setFillType方法的具体用法?Java Path.setFillType怎么用?Java Path.setFillType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Path
的用法示例。
在下文中一共展示了Path.setFillType方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: overlay
import android.graphics.Path; //导入方法依赖的package包/类
public void overlay(Canvas c, ImageView img) {
if (arrowPos != ArrowPosition.NONE) {
int x_border = (arrowPos == ArrowPosition.LEFT) ? 0 : img.getWidth();
int x_inside = x_border + ((arrowPos == ArrowPosition.LEFT) ? 1 : -1 ) * (int)(img.getWidth() * 0.2f);
int y_top = (int) (img.getHeight() * 0.2f);
int y_bottom = (int) (img.getHeight() * 0.6f);
c.save();
Path path = new Path();
path.setFillType(Path.FillType.EVEN_ODD);
path.moveTo(x_border, y_top);
path.lineTo(x_inside, (y_top + y_bottom)/2);
path.lineTo(x_border, y_bottom);
path.lineTo(x_border, y_top);
path.close();
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStrokeWidth(0);
paint.setColor(android.graphics.Color.BLACK);
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setAntiAlias(true);
c.drawPath(path, paint);
c.restore();
}
}
示例2: initPaintObjects
import android.graphics.Path; //导入方法依赖的package包/类
private void initPaintObjects() {
int labelTextSize = getResources().getDimensionPixelSize(R.dimen.label_text_size);
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
textPaint.setTextSize(labelTextSize);
if (typeface != null) {
textPaint.setTypeface(typeface);
}
textPaint.setColor(baseColor);
baseAlpha = textPaint.getAlpha();
selectorPath = new Path();
selectorPath.setFillType(Path.FillType.EVEN_ODD);
selectorPoints = new Point[3];
for (int i = 0; i < 3; i++) {
selectorPoints[i] = new Point();
}
}
示例3: onDraw
import android.graphics.Path; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
int w = getWidth(), h = getHeight();
paint.setStrokeWidth(2);
paint.setColor(getResources().getColor(R.color.white));
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setAntiAlias(true);
path = new Path();
path.setFillType(Path.FillType.EVEN_ODD);
path.moveTo(0,0);
path.lineTo(0,h);
path.lineTo(w,h);
path.close();
canvas.drawPath(path, paint);
}
示例4: setupClip
import android.graphics.Path; //导入方法依赖的package包/类
private void setupClip() {
if (mClipDataSet && mClipRuleSet) {
mClipPath = new Path();
switch (mClipRule) {
case CLIP_RULE_EVENODD:
mClipPath.setFillType(Path.FillType.EVEN_ODD);
break;
case CLIP_RULE_NONZERO:
break;
default:
Log.v(TAG, "clipRule " + mClipRule + " unrecognized");
}
createPath(mClipData, mClipPath);
}
}
示例5: addObjectToClip
import android.graphics.Path; //导入方法依赖的package包/类
private void addObjectToClip(SVG.Path obj, Path combinedPath,
Matrix combinedPathMatrix) {
updateStyleForElement(state, obj);
if (!display())
return;
if (!visible())
return;
if (obj.transform != null)
combinedPathMatrix.preConcat(obj.transform);
Path path = (new PathConverter(obj.d)).getPath();
if (obj.boundingBox == null) {
obj.boundingBox = calculatePathBounds(path);
}
checkForClipPath(obj);
// path.setFillType(getClipRuleFromState());
combinedPath.setFillType(getClipRuleFromState());
combinedPath.addPath(path, combinedPathMatrix);
}
示例6: makePathAndBoundingBox
import android.graphics.Path; //导入方法依赖的package包/类
private Path makePathAndBoundingBox(SVG.PolyLine obj) {
Path path = new Path();
path.moveTo(obj.points[0], obj.points[1]);
for (int i = 2; i < obj.points.length; i += 2) {
path.lineTo(obj.points[i], obj.points[i + 1]);
}
if (obj instanceof SVG.Polygon)
path.close();
if (obj.boundingBox == null) {
obj.boundingBox = calculatePathBounds(path);
}
path.setFillType(getClipRuleFromState());
return path;
}
示例7: fillTypeTest
import android.graphics.Path; //导入方法依赖的package包/类
private void fillTypeTest(Canvas canvas) {
paint.setStyle(Paint.Style.FILL); // 设置画布模式为填充kk
canvas.translate(mWidth / 2, mHeight / 2); // 移动画布(坐标系)
Path path = new Path(); // 创建Path
path.setFillType(Path.FillType.INVERSE_WINDING); // 设置Path填充模式为 奇偶规则
// path.setFillType(Path.FillType.INVERSE_EVEN_ODD); // 反奇偶规则
path.addRect(-400, -400, 400, 400, Path.Direction.CW); // 给Path中添加一个矩形
canvas.drawPath(path, paint);
}
示例8: createTriangle
import android.graphics.Path; //导入方法依赖的package包/类
/**
* This requires the three points to be in a sequence that traces out a triangle in clockwise
* fashion. This is required for the triangle to be filled correctly when drawing, otherwise
* it will end up black.
*/
private static Path createTriangle(Point start, Point middle, Point end) {
Path path = new Path();
path.setFillType(Path.FillType.EVEN_ODD);
path.moveTo(start.x, start.y);
path.lineTo(middle.x, middle.y);
path.lineTo(end.x, end.y);
path.close();
return path;
}
示例9: setupPath
import android.graphics.Path; //导入方法依赖的package包/类
protected void setupPath() {
// init path after both fillRule and path have been set
if (mFillRuleSet && mD != null) {
mPath = new Path();
mPath.setFillType(mFillRule);
super.createPath(mD, mPath);
}
}
示例10: XYGraph
import android.graphics.Path; //导入方法依赖的package包/类
public XYGraph(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mPaintLine = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaintEdge = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaintGraph = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaintGraphStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
mPathGraph = new Path();
mPaintEdge.setStyle(Paint.Style.STROKE);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.XYGraph, defStyleAttr, 0);
int accentColor = ViewUtils.getThemeAccentColor(getContext());
mPaintLine.setColor(a.getColor(R.styleable.XYGraph_linecolor, accentColor));
mPaintEdge.setColor(a.getColor(R.styleable.XYGraph_edgecolor, accentColor));
mPaintEdge.setStrokeWidth(a.getDimension(R.styleable.XYGraph_edgestrokewidth,
getResources().getDimension(R.dimen.xygraph_edge_stroke_width)));
int graphColor = a.getColor(R.styleable.XYGraph_graphcolor, accentColor);
mPaintGraphStroke.setColor(graphColor);
mPaintGraphStroke.setStyle(Paint.Style.STROKE);
mPaintGraphStroke.setStrokeWidth(a.getDimension(R.styleable.XYGraph_graphstrokewidth,
getResources().getDimension(R.dimen.xygraph_graph_stroke_width)));
graphColor = Color.argb(120, Color.red(graphColor), Color.green(graphColor), Color.blue(graphColor));
mPaintGraph.setColor(graphColor);
mPaintGraph.setStyle(Paint.Style.FILL);
mPathGraph.setFillType(Path.FillType.EVEN_ODD);
mEdgeVisible = a.getBoolean(R.styleable.XYGraph_edgevisibile, true);
a.recycle();
}
示例11: onDraw
import android.graphics.Path; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
//super.onDraw(canvas);
canvas.save();
canvas.translate(0,-Ui.cd.getHt(10));
canvas.save();
bass.draw(canvas);
float radius = 10;
final RectF oval = new RectF();
oval.set(0, 0, bass.width, bass.height);
Path ph = new Path();
ph.setFillType(Path.FillType.WINDING);
ph.moveTo(bass.width/2, bass.width/2);
if(angle > 110 - 1){
ph.addArc(oval,-(200) + 110,angle - 110);
}else{
ph.addArc(oval,-(90) - (110 - angle),(110 - angle));
}
ph.lineTo(bass.width/2,bass.width/2);
canvas.clipPath(ph);
basstop.draw(canvas);
canvas.restore();
canvas.save();
canvas.rotate(-(90+20),XX,YY);
canvas.rotate(angle,XX,YY);
bassdot.draw(canvas);
canvas.restore();
int val = (angle - 110);
val = (int) ((100f / 110) * val);
levelText.setText(val+"",true);
levelText.draw(canvas);
canvas.restore();
super.drawShape(canvas);
//canvas.drawPath(ph,bass.img.maskPaint);
}
示例12: drawBackground
import android.graphics.Path; //导入方法依赖的package包/类
private void drawBackground(Canvas canvas) {
Rect imageRect = getImageRect();
PointF topLeftImageRect = sourceToViewCoord(imageRect.left, imageRect.top);
PointF bottomRightImageRect = sourceToViewCoord(imageRect.left, imageRect.top);
PointF topLeft = sourceToViewCoord(cropRect.left, cropRect.top);
PointF bottomRight = sourceToViewCoord(cropRect.right, cropRect.bottom);
if (topLeftImageRect == null || bottomRightImageRect == null ||
topLeft == null || bottomRight == null) {
return;
}
Path background = new Path();
background.setFillType(Path.FillType.INVERSE_EVEN_ODD);
background.moveTo(topLeft.x, topLeft.y);
background.lineTo(bottomRight.x, topLeft.y);
background.lineTo(bottomRight.x, bottomRight.y);
background.lineTo(topLeft.x, bottomRight.y);
background.close();
background.moveTo(topLeftImageRect.x, topLeftImageRect.y);
background.lineTo(bottomRightImageRect.x, topLeftImageRect.y);
background.lineTo(bottomRightImageRect.x, bottomRightImageRect.y);
background.lineTo(topLeftImageRect.x, bottomRightImageRect.y);
background.close();
backgroundPaint.setAlpha(touching ? 100 : 200);
canvas.drawPath(background, backgroundPaint);
}
示例13: render
import android.graphics.Path; //导入方法依赖的package包/类
private void render(SVG.Path obj) {
debug("Path render");
if (obj.d == null)
return;
updateStyleForElement(state, obj);
if (!display())
return;
if (!visible())
return;
if (!state.hasStroke && !state.hasFill)
return;
if (obj.transform != null)
canvas.concat(obj.transform);
Path path = (new PathConverter(obj.d)).getPath();
if (obj.boundingBox == null) {
obj.boundingBox = calculatePathBounds(path);
}
updateParentBoundingBox(obj);
checkForGradientsAndPatterns(obj);
checkForClipPath(obj);
boolean compositing = pushLayer();
if (state.hasFill) {
path.setFillType(getFillTypeFromState());
doFilledPath(obj, path);
}
if (state.hasStroke)
doStroke(path);
renderMarkers(obj);
if (compositing)
popLayer(obj);
}
示例14: initPaint
import android.graphics.Path; //导入方法依赖的package包/类
private void initPaint() {
mPathEffect = new DashPathEffect(new float[]{dp2, dp2}, 1);
mGradeAxisPaint = new Paint();
mGradeAxisPaint.reset();
mGradeAxisPaint.setStyle(Paint.Style.STROKE);
mGradeAxisPaint.setStrokeWidth(1);
mGradeAxisPaint.setColor(isDebug ? Color.parseColor("#f00000") : Color.parseColor("#16ffffff"));
mGradeAxisPaint.setAntiAlias(true);
mGradeAxisPaint.setPathEffect(mPathEffect);
mChartPaint = new Paint();
mChartPaint.setStyle(Paint.Style.FILL);
mChartPaint.setStrokeWidth(4);
mChartPaint.setAntiAlias(true);
mChartTestLinePaint = new Paint();
mChartTestLinePaint.setStyle(Paint.Style.STROKE);
mChartTestLinePaint.setStrokeWidth(dp2px(1));
mChartTestLinePaint.setColor(Color.parseColor("#DF6A56"));
mChartTestLinePaint.setAntiAlias(true);
mChartTestLinePaint.setAlpha(0);
if (isDebug) {
mChartTestLinePaint.setAlpha(255);
}
mChartIndicatorPaint = new Paint();
mChartIndicatorPaint.setStyle(Paint.Style.STROKE);
mChartIndicatorPaint.setStrokeWidth(dp2px(1));
mWhitePaint = new Paint();
mWhitePaint.setStyle(Paint.Style.FILL);
mWhitePaint.setColor(Color.parseColor("#ffffff"));
mWhiteTextPaint = new TextPaint();
mWhiteTextPaint.setColor(Color.parseColor("#ffffff"));
mWhiteTextPaint.setTextSize(dp2px(11));
mWhiteTextPaint.setAntiAlias(true);
mWhiteTextPaintHeight = mWhiteTextPaint.descent() + mWhiteTextPaint.ascent();
mDarkTextPaint = new TextPaint(mWhiteTextPaint);
mDarkTextPaint.setAlpha(127);
mPathIndicatorLine = new Path();
mPathIndicatorLine.setFillType(Path.FillType.WINDING);
mPathGradLine = new Path();
mRectIndicator = new RectF();
}