android.graphics.PathMeasure Java Examples
The following examples show how to use
android.graphics.PathMeasure.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HistoryChartView.java From YiZhi with Apache License 2.0 | 6 votes |
private void initRoomTempPath(float[] data) { mRoomTempPath.reset(); // Path path = new Path(); float pointX; float pointY; // 横向 mRoomTempPath.moveTo(Xpoint + xFirstPointOffset, getDataY(data[0], Ylabel)); mRoomTempPath.moveTo(Xpoint + xFirstPointOffset, getDataY(data[0], Ylabel)); for (int i = 0; i < Xlabel.length; i++) { float startX = Xpoint + i * Xscale + xFirstPointOffset; // 绘制数据连线 if (i != 0) { pointX = Xpoint + (i - 1) * Xscale + xFirstPointOffset; pointY = getDataY(data[i - 1], Ylabel); mRoomTempPath.lineTo(pointX, pointY); } if (i == Xlabel.length - 1) { pointX = startX; pointY = getDataY(data[i], Ylabel); mRoomTempPath.lineTo(pointX, pointY); } } mRoomTempPathMeasure = new PathMeasure(mRoomTempPath, false); }
Example #2
Source File: PathBitmapMesh.java From Android-Plugin-Framework with MIT License | 6 votes |
public void matchVertsToPath(Path path, float bottomCoord, float extraOffset) { PathMeasure pm = new PathMeasure(path, false); for (int i = 0; i < staticVerts.length / 2; i++) { float yIndexValue = staticVerts[i * 2 + 1]; float xIndexValue = staticVerts[i * 2]; float percentOffsetX = (0.000001f + xIndexValue) / bitmap.getWidth(); float percentOffsetX2 = (0.000001f + xIndexValue) / (bitmap.getWidth() + extraOffset); percentOffsetX2 += pathOffsetPercent; pm.getPosTan(pm.getLength() * (1f - percentOffsetX), coords, null); pm.getPosTan(pm.getLength() * (1f - percentOffsetX2), coords2, null); if (yIndexValue == 0) { setXY(drawingVerts, i, coords[0], coords2[1]); } else { float desiredYCoord = bottomCoord; setXY(drawingVerts, i, coords[0], desiredYCoord); } } }
Example #3
Source File: FillableLoader.java From AndroidFillableLoaders with Apache License 2.0 | 6 votes |
private void buildPathData() { SvgPathParser parser = getPathParser(); pathData = new PathData(); try { pathData.path = parser.parsePath(svgPath); } catch (ParseException e) { pathData.path = new Path(); } PathMeasure pm = new PathMeasure(pathData.path, true); while (true) { pathData.length = Math.max(pathData.length, pm.getLength()); if (!pm.nextContour()) { break; } } }
Example #4
Source File: PaperPlaneView.java From SparkleMotion with MIT License | 6 votes |
@Override protected void onSizeChanged(final int w, final int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); // Scale and translate the SVG path. Matrix matrix = new Matrix(); RectF rectF = new RectF(); mPath.computeBounds(rectF, false); RectF largeRectF = new RectF(0, 0, w * SCALE_FACTOR, h * SCALE_FACTOR); matrix.setRectToRect(rectF, largeRectF, Matrix.ScaleToFit.CENTER); float pathTranslationY = getResources().getDimension(R.dimen.path_translation_y); float pathTranslationX = getResources().getDimension(R.dimen.path_translation_x); matrix.postTranslate(pathTranslationX, pathTranslationY); mPath.transform(matrix); mPathMeasure = new PathMeasure(mPath, false); mLength = mPathMeasure.getLength(); if (mProgress != 0) { // Animate the restored frame. animate(mProgress); } }
Example #5
Source File: FloatParticle.java From kAndroid with Apache License 2.0 | 6 votes |
public FloatParticle(int width, int height) { mWidth = width; mHeight = height; mRandom = new Random(); startPoint = new Point((int) (mRandom.nextFloat() * mWidth), (int) (mRandom.nextFloat() * mHeight)); // 抗锯齿 mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setColor(Color.WHITE); // 防抖动 mPaint.setDither(true); mPaint.setStyle(Paint.Style.FILL); // 设置模糊效果 边缘模糊 mPaint.setMaskFilter(new BlurMaskFilter(BLUR_SIZE, BlurMaskFilter.Blur.SOLID)); mPath = new Path(); mPathMeasure = new PathMeasure(); startPoint.x = (int) (mRandom.nextFloat() * mWidth); startPoint.y = (int) (mRandom.nextFloat() * mHeight); }
Example #6
Source File: ScaleView.java From ScaleView with Apache License 2.0 | 6 votes |
/** * 画指示器 * * @param canvas */ private void drawIndicator(Canvas canvas) { PathMeasure mPathMeasure = new PathMeasure(); mPathMeasure.setPath(mArcPath, false); float[] tan = new float[2]; float[] pos = new float[2]; mPathMeasure.getPosTan(mPathMeasure.getLength() * (0.5f), pos, tan); canvas.save(); double angle = calcArcAngle(Math.atan2(tan[1], tan[0])) + 90; canvas.rotate((float) angle, pos[0], pos[1]); //画直线 canvas.drawLine(pos[0], pos[1], pos[0] + 80, pos[1], mIndicatorPaint); Path linePath = new Path(); //画箭头 linePath.moveTo(pos[0] + 80, pos[1] - 20); linePath.lineTo(pos[0] + 80 + 20, pos[1]); linePath.lineTo(pos[0] + 80, pos[1] + 20); canvas.drawPath(linePath, mIndicatorPaint); canvas.restore(); }
Example #7
Source File: PathInterpolatorCompat.java From android-dialer with Apache License 2.0 | 6 votes |
public PathInterpolatorBase(Path path) { final PathMeasure pathMeasure = new PathMeasure(path, false /* forceClosed */); final float pathLength = pathMeasure.getLength(); final int numPoints = (int) (pathLength / PRECISION) + 1; mX = new float[numPoints]; mY = new float[numPoints]; final float[] position = new float[2]; for (int i = 0; i < numPoints; ++i) { final float distance = (i * pathLength) / (numPoints - 1); pathMeasure.getPosTan(distance, position, null /* tangent */); mX[i] = position[0]; mY[i] = position[1]; } }
Example #8
Source File: FilterMenuLayout.java From FilterMenu with Apache License 2.0 | 6 votes |
/** * calculate and set position to menu items */ private void calculateMenuItemPosition() { float itemRadius = (expandedRadius + collapsedRadius) / 2, f; RectF area = new RectF( center.x - itemRadius, center.y - itemRadius, center.x + itemRadius, center.y + itemRadius); Path path = new Path(); path.addArc(area, (float) fromAngle, (float) (toAngle - fromAngle)); PathMeasure measure = new PathMeasure(path, false); float len = measure.getLength(); int divisor = getChildCount(); float divider = len / divisor; for (int i = 0; i < getChildCount(); i++) { float[] coords = new float[2]; measure.getPosTan(i * divider + divider * .5f, coords, null); FilterMenu.Item item = (FilterMenu.Item) getChildAt(i).getTag(); item.setX((int) coords[0] - item.getView().getMeasuredWidth() / 2); item.setY((int) coords[1] - item.getView().getMeasuredHeight() / 2); } }
Example #9
Source File: FllowerView.java From AndroidDemo with Apache License 2.0 | 6 votes |
private void init(Context context) { WindowManager wm = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); width = wm.getDefaultDisplay().getWidth(); // height = wm.getDefaultDisplay().getHeight(); height = (int) (wm.getDefaultDisplay().getHeight() * 3 / 2f); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setStrokeWidth(2); mPaint.setColor(Color.BLUE); mPaint.setStyle(Paint.Style.STROKE); pathMeasure = new PathMeasure(); mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_heart); builderFollower(fllowerCount, fllowers1); builderFollower(fllowerCount, fllowers2); builderFollower(fllowerCount, fllowers3); }
Example #10
Source File: RainType.java From FakeWeather with Apache License 2.0 | 6 votes |
public RainType(Context context, @RainLevel int rainLevel, @WindLevel int windLevel) { super(context); setColor(0xFF6188DA); this.rainLevel = rainLevel; this.windLevel = windLevel; mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setColor(Color.WHITE); mPaint.setStrokeWidth(5); mPaint.setStyle(Paint.Style.STROKE); mRains = new ArrayList<>(); mSnows = new ArrayList<>(); matrix = new Matrix(); bitmap = decodeResource(bitmap, R.drawable.ic_rain_ground); mDstFlash1 = new Path(); flashPathMeasure1 = new PathMeasure(); mDstFlash2 = new Path(); flashPathMeasure2 = new PathMeasure(); mDstFlash3 = new Path(); flashPathMeasure3 = new PathMeasure(); }
Example #11
Source File: OilTableLine.java From OXChart with Apache License 2.0 | 6 votes |
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); float size = Math.min(w, h) - tableWidth * 2; //油表的位置方框 mTableRectF = new RectF(0, 0, size, size); mPath.reset(); //在油表路径中增加一个从起始弧度 mPath.addArc(mTableRectF, 60, 240); //计算路径的长度 PathMeasure pathMeasure = new PathMeasure(mPath, false); float length = pathMeasure.getLength(); float step = length / 60; dashPathEffect = new DashPathEffect(new float[]{step / 3, step * 2 / 3}, 0); float radius = size / 2; mColorShader = new SweepGradient(radius, radius,SWEEP_GRADIENT_COLORS,null); //设置指针的路径位置 mPointerPath.reset(); mPointerPath.moveTo(radius, radius - 20); mPointerPath.lineTo(radius, radius + 20); mPointerPath.lineTo(radius * 2 - tableWidth, radius); mPointerPath.close(); }
Example #12
Source File: NSidedProgressBar.java From N-SidedProgressBar with MIT License | 6 votes |
private void initProgressBar() { basePath = new Path(); secPath = new Path(); pathMeasure = new PathMeasure(); setPaints(); xVertiCoord = new float[sideCount]; yVertiCoord = new float[sideCount]; x1VertiCoord = new float[sideCount]; y1VertiCoord = new float[sideCount]; x2VertiCoord = new float[sideCount]; y2VertiCoord = new float[sideCount]; xMidPoints = new float[sideCount]; yMidPoints = new float[sideCount]; }
Example #13
Source File: TextPathAnimView.java From DanDanPlayForAndroid with MIT License | 6 votes |
public TextPathAnimView(Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TextPathAnimView, defStyle, 0); mAnimDuration = typedArray.getInt(R.styleable.TextPathAnimView_duration, 1500); mTextBgColor = typedArray.getColor(R.styleable.TextPathAnimView_text_bg_color, Color.BLACK); mTextFgColor = typedArray.getColor(R.styleable.TextPathAnimView_text_fg_color, Color.WHITE); mIsLoop = typedArray.getBoolean(R.styleable.TextPathAnimView_loop, true); String contentText = typedArray.getString(R.styleable.TextPathAnimView_text); float sizeScale = typedArray.getFloat(R.styleable.TextPathAnimView_text_size_scale, dp2px(14)); float stokeWidth = typedArray.getFloat(R.styleable.TextPathAnimView_text_stoke_width, 3f); float textInterval = typedArray.getDimension(R.styleable.TextPathAnimView_text_interval, dp2px(5)); typedArray.recycle(); mSourceTextPath = new TextPath(contentText, sizeScale, textInterval); mSourcePath = mSourceTextPath.getPath(); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(stokeWidth); mAnimPath = new Path(); mPathMeasure = new PathMeasure(); }
Example #14
Source File: SunnyType.java From FakeWeather with Apache License 2.0 | 6 votes |
public SunnyType(Context context, ShortWeatherInfo info) { super(context); mPathFront = new Path(); mPathRear = new Path(); sunPath = new Path(); mPaint = new Paint(); pos = new float[2]; tan = new float[2]; mMatrix = new Matrix(); measure = new PathMeasure(); sunMeasure = new PathMeasure(); currentSunPosition = TimeUtils.getTimeDiffPercent(info.getSunrise(), info.getSunset()); currentMoonPosition = TimeUtils.getTimeDiffPercent(info.getMoonrise(), info.getMoonset()); if (currentSunPosition >= 0 && currentSunPosition <= 1) { setColor(colorDay); boat = decodeResource(boat, R.drawable.ic_boat_day); } else { setColor(colorNight); boat = decodeResource(boat, R.drawable.ic_boat_night); } cloud = decodeResource(cloud, R.drawable.ic_cloud); }
Example #15
Source File: DashboardView.java From Android_UE with Apache License 2.0 | 6 votes |
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); mRect = new RectF(getWidth() / 2 - RADIUS, PADDING, getWidth() / 2 + RADIUS, getHeight() - PADDING); // 刻度的数量 Path arcPath = new Path(); arcPath.addArc(mRect, START_ANAGLE, 360 - (START_ANAGLE - 45)); PathMeasure pathMeasure = new PathMeasure(arcPath, false); float pathMeasureLength = pathMeasure.getLength(); // 短刻度 mShortEffect = new PathDashPathEffect(mShortDash, (pathMeasureLength - Utils.dp2px(2)) / 50,// 每个间距为多少 0,// 第一个从什么地方开始 PathDashPathEffect.Style.ROTATE); // 长刻度 mLongEffect = new PathDashPathEffect(mLongDash, (pathMeasureLength - Utils.dp2px(2)) / 10,// 每个间距为多少 0,// 第一个从什么地方开始 PathDashPathEffect.Style.ROTATE); }
Example #16
Source File: PathInterpolatorDonut.java From RxTools-master with Apache License 2.0 | 6 votes |
public PathInterpolatorDonut(Path path) { final PathMeasure pathMeasure = new PathMeasure(path, false /* forceClosed */); final float pathLength = pathMeasure.getLength(); final int numPoints = (int) (pathLength / PRECISION) + 1; mX = new float[numPoints]; mY = new float[numPoints]; final float[] position = new float[2]; for (int i = 0; i < numPoints; ++i) { final float distance = (i * pathLength) / (numPoints - 1); pathMeasure.getPosTan(distance, position, null /* tangent */); mX[i] = position[0]; mY[i] = position[1]; } }
Example #17
Source File: LeafLineRenderer.java From LeafChart with Apache License 2.0 | 6 votes |
/** * 画折线 * * @param canvas */ public void drawLines(Canvas canvas, Line line) { if (line != null && isShow) { linePaint.setColor(line.getLineColor()); linePaint.setStrokeWidth(LeafUtil.dp2px(mContext, line.getLineWidth())); linePaint.setStyle(Paint.Style.STROKE); List<PointValue> values = line.getValues(); Path path = line.getPath(); int size = values.size(); for (int i = 0; i < size; i++) { PointValue point = values.get(i); if (i == 0) path.moveTo(point.getOriginX(), point.getOriginY()); else path.lineTo(point.getOriginX(), point.getOriginY()); } measure = new PathMeasure(path, false); linePaint.setPathEffect(createPathEffect(measure.getLength(), phase, 0.0f)); canvas.drawPath(path, linePaint); } }
Example #18
Source File: Foam.java From Depth with MIT License | 6 votes |
public void matchVertsToPath(Path path, float extraOffset) { PathMeasure pm = new PathMeasure(path, false); int index = 0; for (int i = 0; i < staticVerts.length / 2; i++) { float yIndexValue = staticVerts[i * 2 + 1]; float xIndexValue = staticVerts[i * 2]; float percentOffsetX = (0.000001f + xIndexValue) / bitmap.getWidth(); float percentOffsetX2 = (0.000001f + xIndexValue) / (bitmap.getWidth() + extraOffset); percentOffsetX2 += pathOffsetPercent; pm.getPosTan(pm.getLength() * (1f - percentOffsetX), coords, null); pm.getPosTan(pm.getLength() * (1f - percentOffsetX2), coords2, null); if (yIndexValue == 0) { setXY(drawingVerts, i, coords[0], coords2[1] + verticalOffset); } else { float desiredYCoord = Math.max(coords2[1], coords2[1] + easedFoamCoords[Math.min(easedFoamCoords.length - 1, index)]); setXY(drawingVerts, i, coords[0], desiredYCoord + verticalOffset); index += 1; } } }
Example #19
Source File: FllowerAnimation.java From AndroidStudyDemo with GNU General Public License v2.0 | 6 votes |
private void init(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); width = wm.getDefaultDisplay().getWidth(); height = (int) (wm.getDefaultDisplay().getHeight() * 3 / 2f); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setStrokeWidth(2); mPaint.setColor(Color.BLUE); mPaint.setStyle(Paint.Style.STROKE); pathMeasure = new PathMeasure(); builderFollower(fllowerCount, fllowers1); builderFollower(fllowerCount, fllowers2); builderFollower(fllowerCount, fllowers3); }
Example #20
Source File: OC_Generic_Tracing.java From GLEXP-Team-onebillion with Apache License 2.0 | 6 votes |
public OBGroup splitPath (OBPath obp) { int lengthPerSplit = 100; PathMeasure pm = new PathMeasure(obp.path(), false); float splen = pm.getLength(); int noSplits = (int) (splen / lengthPerSplit); List<OBPath> newOBPaths = splitInto(obp, pm, noSplits, 1.0f / (noSplits * 4)); for (OBPath newOBPath : newOBPaths) { //newOBPath.setBounds(obp.bounds); //newOBPath.setPosition(obp.position()); //newOBPath.sizeToBox(obp.bounds()); newOBPath.setStrokeColor(Color.argb((int) (255 * 0.4f), 255, 0, 0)); newOBPath.setLineJoin(OBStroke.kCALineJoinRound); newOBPath.setFillColor(0); newOBPath.setLineWidth(swollenLineWidth); } MainActivity.log("Now serving " + newOBPaths.size()); OBGroup grp = new OBGroup((List<OBControl>) (Object) newOBPaths); return grp; }
Example #21
Source File: OC_ReadingReadToMeNTx.java From GLEXP-Team-onebillion with Apache License 2.0 | 6 votes |
List<Path> pathsFromComplexPath(Path p) { List<Path>pathList = new ArrayList<>(); PathMeasure pm = new PathMeasure(p,false); Boolean fin = false; while (!fin) { float len = pm.getLength(); if (len > 0) { Path np = new Path(); pm.getSegment(0,len,np,true); pathList.add(np); } fin = !pm.nextContour(); } return pathList; }
Example #22
Source File: BrokenAnimator.java From BrokenView with MIT License | 6 votes |
/** * Make sure it can be seen in "FILL" mode */ private void warpStraightLines() { PathMeasure pmTemp = new PathMeasure(); for (int i = 0; i < mConfig.complexity; i++) { if(lineRifts[i].isStraight()) { pmTemp.setPath(lineRifts[i], false); lineRifts[i].setStartLength(pmTemp.getLength() / 2); float[] pos = new float[2]; pmTemp.getPosTan(pmTemp.getLength() / 2, pos, null); int xRandom = (int) (pos[0] + Utils.nextInt(-Utils.dp2px(1), Utils.dp2px(1))); int yRandom = (int) (pos[1] + Utils.nextInt(-Utils.dp2px(1), Utils.dp2px(1))); lineRifts[i].reset(); lineRifts[i].moveTo(0,0); lineRifts[i].lineTo(xRandom,yRandom); lineRifts[i].lineToEnd(); } } }
Example #23
Source File: WeatherTemplateView.java From MaterialCalendar with Apache License 2.0 | 6 votes |
protected PathPoints[] getPoints(Path path, int size) { //Size of 100 indicates that, 100 points // would be extracted from the path PathPoints[] pointArray = new PathPoints[size]; PathMeasure pm = new PathMeasure(path, false); float length = pm.getLength(); float distance = 0f; float speed = length / size; int counter = 0; float[] aCoordinates = new float[2]; while ((distance < length) && (counter < size)) { pm.getPosTan(distance, aCoordinates, null); pointArray[counter] = new PathPoints(aCoordinates[0], aCoordinates[1]); counter++; distance = distance + speed; } return pointArray; }
Example #24
Source File: FreshDownloadView.java From FreshDownloadView with Apache License 2.0 | 6 votes |
public FreshDownloadView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); circular_edge = getResources().getDimension(R.dimen.edge); bounds = new Rect(); mTempBounds = new RectF(); publicPaint = new Paint(); path1 = new Path(); path2 = new Path(); path3 = new Path(); pathMeasure1 = new PathMeasure(); pathMeasure2 = new PathMeasure(); pathMeasure3 = new PathMeasure(); textBounds = new Rect(); parseAttrs(context.obtainStyledAttributes(attrs, R.styleable.FreshDownloadView)); initPaint(); }
Example #25
Source File: PathsTest.java From Artiste with MIT License | 5 votes |
@Test public void testRegularConvexPolygonPerimeterIsRotationIndependent() { Path path1 = Paths.regularConvexPolygon(0, 0, 100, 100, 5, 0); PathMeasure pm1 = new PathMeasure(path1, false); Path path2 = Paths.regularConvexPolygon(0, 0, 100, 100, 5, 60); PathMeasure pm2 = new PathMeasure(path2, false); assertEquals(pm1.getLength(), pm2.getLength(), 0); }
Example #26
Source File: PathsTest.java From Artiste with MIT License | 5 votes |
@Test public void testRelativePerimetersOfRegularStarPolygons() { Path path1 = Paths.regularStarPolygon(0, 0, 100, 100, 5, 2, 0, true); PathMeasure pm1 = new PathMeasure(path1, false); Path path2 = Paths.regularStarPolygon(0, 0, 100, 100, 8, 3, 0, true); PathMeasure pm2 = new PathMeasure(path2, false); assertTrue(pm2.getLength() > pm1.getLength()); }
Example #27
Source File: ENSearchView.java From ENViews with Apache License 2.0 | 5 votes |
public ENSearchView(Context context, AttributeSet attrs) { super(context, attrs); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.search); int lineColor = ta.getColor(R.styleable.search_search_line_color, DEFAULT_LINE_COLOR); int lineWidth = ta.getInteger(R.styleable.search_search_line_width, DEFAULT_LINE_WIDTH); int dotSize = ta.getInteger(R.styleable.search_search_dot_size, DEFAULT_DOT_SIZE); ta.recycle(); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStrokeWidth(lineWidth); mPaint.setColor(lineColor); mArcPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mArcPaint.setStyle(Paint.Style.FILL); mArcPaint.setColor(Color.WHITE); mDotSize = dotSize; mDuration = DEFAULT_DURATION; mCurrentState = STATE_WAIT; mCurrentPos = new float[2]; mCurrentTan = new float[2]; mPath = new Path(); mArcPath = new Path(); mPathMeasure = new PathMeasure(); }
Example #28
Source File: PathEvaluator.java From android_additive_animations with Apache License 2.0 | 5 votes |
public float evaluate(float fraction, PathMode pathMode, Path path) { if(fraction == lastEvaluatedFraction) { return getResult(pathMode); } float tan[] = new float[2]; PathMeasure pathMeasure = new PathMeasure(path, true); pathMeasure.getPosTan(pathMeasure.getLength() * fraction, lastPoint, tan); lastAngle = (float)(Math.atan2(tan[1], tan[0])*180.0/Math.PI); lastEvaluatedFraction = fraction; return getResult(pathMode); }
Example #29
Source File: SmartLoadingView.java From SmartLoadingView with MIT License | 5 votes |
/** * 绘制对勾 */ private void initOk() { //对勾的路径 path.moveTo(default_all_distance + height / 8 * 3, height / 2); path.lineTo(default_all_distance + height / 2, height / 5 * 3); path.lineTo(default_all_distance + height / 3 * 2, height / 5 * 2); pathMeasure = new PathMeasure(path, true); }
Example #30
Source File: WinSearch.java From stynico with MIT License | 5 votes |
private void init() { mPaint = new Paint(); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(15); mPaint.setColor(WinSearch.this.getResources().getColor(R.color.colorPrimary)); //设置画笔为园笔 mPaint.setStrokeCap(Paint.Cap.ROUND); //抗锯齿 mPaint.setAntiAlias(true); mPath = new Path(); RectF rect = new RectF(-150,-150,150,150); mPath.addArc(rect,-90,359.9f); mPathMeasure = new PathMeasure(mPath,false); valueAnimator = ValueAnimator.ofFloat(0f,1f).setDuration(3000); valueAnimator.setRepeatCount(-1); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { t = (float) animation.getAnimatedValue(); invalidate(); } }); }