private void updateLeftIndicator(RectF outerRect, RectF innerRect) { final RectF oR = outerRect; final RectF iR = innerRect; final float iH = mIndicatorHeight; final float iW = mIndicatorWidth; final float iVSW = mIndicatorVerticalStrokeWidth; final float iHSW = mIndicatorHorizontalStrokeWidth; final float iVISO = mIndicatorVerticalInnerStrokeOffset; // fill indicator path which overlaps the stroke of the popup // 1. top right | 2. middle left | 3. bottom right mIndicatorFillPath.moveTo(iR.left, oR.top + iVSW - iVISO); mIndicatorFillPath.lineTo(oR.left - iH, oR.top + iVSW + iW / 2f); mIndicatorFillPath.lineTo(iR.left, oR.top + iVSW + iW + iVISO); mIndicatorFillPath.close(); if (mStrokeWidth >= 1) { // fill path of indicator stroke which borders the popup outer stroke // 1. most top right | 2. outer middle left | 3. most bottom right // 4. bottom right | 5. inner middle left | 6. top right mIndicatorStrokePath.moveTo(oR.left, oR.top); mIndicatorStrokePath.lineTo(oR.left - iH - iHSW, oR.top + iVSW + iW / 2f); mIndicatorStrokePath.lineTo(oR.left, oR.top + iVSW * 2 + iW); mIndicatorStrokePath.lineTo(oR.left, oR.top + iVSW + iW); mIndicatorStrokePath.lineTo(oR.left - iH, oR.top + iVSW + iW / 2f); mIndicatorStrokePath.lineTo(oR.left, oR.top + iVSW); mIndicatorStrokePath.close(); } }
/** * draw lines * * <p>ラインを書く * * <p>绘制线条 * * @param canvas */ protected void drawAreas(Canvas canvas) { // distance between two points float lineLength = ((super.getWidth() - super.getAxisMarginLeft()) / displayNumber) - 1; // start point‘s X float startX; float lastY = 0; float lastX = 0; LineEntity<DateValueEntity> line1 = (LineEntity<DateValueEntity>) bandData.get(0); LineEntity<DateValueEntity> line2 = (LineEntity<DateValueEntity>) bandData.get(1); if (line1.isDisplay() && line2.isDisplay()) { Paint mPaint = new Paint(); mPaint.setColor(line1.getLineColor()); mPaint.setAlpha(70); mPaint.setAntiAlias(true); List<DateValueEntity> line1Data = line1.getLineData(); List<DateValueEntity> line2Data = line2.getLineData(); // set start point’s X startX = super.getAxisMarginLeft() + lineLength / 2f; Path areaPath = new Path(); if (line1Data != null && line2Data != null) { for (int j = displayFrom; j < displayFrom + displayNumber; j++) { float value1 = line1Data.get(j).getValue(); float value2 = line2Data.get(j).getValue(); // calculate Y float valueY1 = (float) ((1f - (value1 - this.getMinValue()) / (this.getMaxValue() - this.getMinValue())) * (super.getHeight() - super.getAxisMarginBottom())); float valueY2 = (float) ((1f - (value2 - this.getMinValue()) / (this.getMaxValue() - this.getMinValue())) * (super.getHeight() - super.getAxisMarginBottom())); // 绘制线条路径 if (j == displayFrom) { areaPath.moveTo(startX, valueY1); areaPath.lineTo(startX, valueY2); areaPath.moveTo(startX, valueY1); } else { areaPath.lineTo(startX, valueY1); areaPath.lineTo(startX, valueY2); areaPath.lineTo(lastX, lastY); areaPath.close(); areaPath.moveTo(startX, valueY1); } lastX = startX; lastY = valueY2; startX = startX + 1 + lineLength; } areaPath.close(); canvas.drawPath(areaPath, mPaint); } } }
private void getTrackPath(float x, float y, float radius) { float halfStroke = mTrackSize / 2f; mTrackPath.reset(); if (mTrackCap != Paint.Cap.ROUND) { mTempRect.set(x - radius + 1f, y - radius + 1f, x + radius - 1f, y + radius - 1f); float angle = (float) (Math.asin(halfStroke / (radius - 1f)) / Math.PI * 180); if (x - radius > mDrawRect.left) { mTrackPath.moveTo(mDrawRect.left, y - halfStroke); mTrackPath.arcTo(mTempRect, 180 + angle, -angle * 2); mTrackPath.lineTo(mDrawRect.left, y + halfStroke); mTrackPath.close(); } if (x + radius < mDrawRect.right) { mTrackPath.moveTo(mDrawRect.right, y - halfStroke); mTrackPath.arcTo(mTempRect, -angle, angle * 2); mTrackPath.lineTo(mDrawRect.right, y + halfStroke); mTrackPath.close(); } } else { float angle = (float) (Math.asin(halfStroke / (radius - 1f)) / Math.PI * 180); if (x - radius > mDrawRect.left) { float angle2 = (float) (Math.acos(Math.max(0f, (mDrawRect.left + halfStroke - x + radius) / halfStroke)) / Math.PI * 180); mTempRect.set(mDrawRect.left, y - halfStroke, mDrawRect.left + mTrackSize, y + halfStroke); mTrackPath.arcTo(mTempRect, 180 - angle2, angle2 * 2); mTempRect.set(x - radius + 1f, y - radius + 1f, x + radius - 1f, y + radius - 1f); mTrackPath.arcTo(mTempRect, 180 + angle, -angle * 2); mTrackPath.close(); } if (x + radius < mDrawRect.right) { float angle2 = (float) Math.acos(Math.max(0f, (x + radius - mDrawRect.right + halfStroke) / halfStroke)); mTrackPath.moveTo( (float) (mDrawRect.right - halfStroke + Math.cos(angle2) * halfStroke), (float) (y + Math.sin(angle2) * halfStroke)); angle2 = (float) (angle2 / Math.PI * 180); mTempRect.set( mDrawRect.right - mTrackSize, y - halfStroke, mDrawRect.right, y + halfStroke); mTrackPath.arcTo(mTempRect, angle2, -angle2 * 2); mTempRect.set(x - radius + 1f, y - radius + 1f, x + radius - 1f, y + radius - 1f); mTrackPath.arcTo(mTempRect, -angle, angle * 2); mTrackPath.close(); } } }
protected final int h(int paramInt, Object... paramVarArgs) { switch (paramInt) { } for (; ; ) { return 0; return 46; return 46; Canvas localCanvas = (Canvas) paramVarArgs[0]; paramVarArgs = (Looper) paramVarArgs[1]; c.e(paramVarArgs); c.d(paramVarArgs); Object localObject = c.h(paramVarArgs); ((Paint) localObject).setFlags(385); ((Paint) localObject).setStyle(Paint.Style.FILL); Paint localPaint1 = c.h(paramVarArgs); localPaint1.setFlags(385); localPaint1.setStyle(Paint.Style.STROKE); ((Paint) localObject).setColor(-16777216); localPaint1.setStrokeWidth(1.0F); localPaint1.setStrokeCap(Paint.Cap.BUTT); localPaint1.setStrokeJoin(Paint.Join.MITER); localPaint1.setStrokeMiter(4.0F); localPaint1.setPathEffect(null); Paint localPaint2 = c.a(localPaint1, paramVarArgs); localPaint2.set(localPaint1); localPaint2.setStrokeWidth(1.0F); localCanvas.save(); localPaint1 = c.a((Paint) localObject, paramVarArgs); localPaint1.set((Paint) localObject); localPaint1.setColor(-8744017); localObject = c.i(paramVarArgs); ((Path) localObject).moveTo(30.430653F, 34.178318F); ((Path) localObject).cubicTo(27.249908F, 36.57749F, 23.291077F, 38.0F, 19.0F, 38.0F); ((Path) localObject).cubicTo(8.50659F, 38.0F, 0.0F, 29.49341F, 0.0F, 19.0F); ((Path) localObject).cubicTo(0.0F, 8.50659F, 8.50659F, 0.0F, 19.0F, 0.0F); ((Path) localObject).cubicTo(29.49341F, 0.0F, 38.0F, 8.50659F, 38.0F, 19.0F); ((Path) localObject) .cubicTo(38.0F, 23.291077F, 36.57749F, 27.249908F, 34.178318F, 30.430653F); ((Path) localObject).lineTo(45.619164F, 41.8715F); ((Path) localObject).lineTo(41.8715F, 45.619164F); ((Path) localObject).lineTo(30.430653F, 34.178318F); ((Path) localObject).close(); ((Path) localObject).moveTo(27.062714F, 30.44662F); ((Path) localObject).cubicTo(24.783264F, 32.055153F, 22.001972F, 33.0F, 19.0F, 33.0F); ((Path) localObject).cubicTo(11.268014F, 33.0F, 5.0F, 26.731987F, 5.0F, 19.0F); ((Path) localObject).cubicTo(5.0F, 11.268014F, 11.268014F, 5.0F, 19.0F, 5.0F); ((Path) localObject).cubicTo(26.731987F, 5.0F, 33.0F, 11.268014F, 33.0F, 19.0F); ((Path) localObject) .cubicTo(33.0F, 22.001972F, 32.055153F, 24.783264F, 30.44662F, 27.062714F); ((Path) localObject).lineTo(27.062714F, 30.44662F); ((Path) localObject).close(); WeChatSVGRenderC2Java.setFillType((Path) localObject, 2); localCanvas.drawPath((Path) localObject, localPaint1); localCanvas.restore(); c.g(paramVarArgs); } }
protected final int i(int paramInt, Object... paramVarArgs) { switch (paramInt) { } for (; ; ) { return 0; return 168; return 168; Canvas localCanvas = (Canvas) paramVarArgs[0]; paramVarArgs = (Looper) paramVarArgs[1]; Object localObject1 = c.d(paramVarArgs); Object localObject2 = c.c(paramVarArgs); Paint localPaint1 = c.g(paramVarArgs); localPaint1.setFlags(385); localPaint1.setStyle(Paint.Style.FILL); Paint localPaint2 = c.g(paramVarArgs); localPaint2.setFlags(385); localPaint2.setStyle(Paint.Style.STROKE); localPaint1.setColor(-16777216); localPaint2.setStrokeWidth(1.0F); localPaint2.setStrokeCap(Paint.Cap.BUTT); localPaint2.setStrokeJoin(Paint.Join.MITER); localPaint2.setStrokeMiter(4.0F); localPaint2.setPathEffect(null); c.a(localPaint2, paramVarArgs).setStrokeWidth(1.0F); localPaint1 = c.a(localPaint1, paramVarArgs); localPaint1.setColor(-9473160); localCanvas.save(); localObject2 = c.a((float[]) localObject2, 1.0F, 0.0F, 51.0F, 0.0F, 1.0F, 39.0F); ((Matrix) localObject1).reset(); ((Matrix) localObject1).setValues((float[]) localObject2); localCanvas.concat((Matrix) localObject1); localCanvas.save(); localObject1 = c.a(localPaint1, paramVarArgs); localObject2 = c.h(paramVarArgs); ((Path) localObject2).moveTo(31.624044F, 90.34997F); ((Path) localObject2) .cubicTo(32.383965F, 91.14044F, 33.629753F, 91.13373F, 34.386406F, 90.3389F); ((Path) localObject2).cubicTo(34.386406F, 90.3389F, 66.0F, 58.57656F, 66.0F, 33.461914F); ((Path) localObject2).cubicTo(66.0F, 14.90092F, 51.225395F, 0.0F, 33.47826F, 0.0F); ((Path) localObject2).cubicTo(14.774603F, 0.0F, 0.0F, 14.90092F, 0.0F, 33.461914F); ((Path) localObject2).cubicTo(0.0F, 58.57656F, 31.624044F, 90.34997F, 31.624044F, 90.34997F); ((Path) localObject2).close(); ((Path) localObject2).moveTo(33.0F, 44.30819F); ((Path) localObject2).cubicTo(39.07513F, 44.30819F, 44.0F, 39.348827F, 44.0F, 33.231144F); ((Path) localObject2).cubicTo(44.0F, 27.113459F, 39.07513F, 22.154095F, 33.0F, 22.154095F); ((Path) localObject2).cubicTo(26.924868F, 22.154095F, 22.0F, 27.113459F, 22.0F, 33.231144F); ((Path) localObject2).cubicTo(22.0F, 39.348827F, 26.924868F, 44.30819F, 33.0F, 44.30819F); ((Path) localObject2).close(); WeChatSVGRenderC2Java.setFillType((Path) localObject2, 2); localCanvas.drawPath((Path) localObject2, (Paint) localObject1); localCanvas.restore(); localCanvas.restore(); c.f(paramVarArgs); } }
private void createCompassRosePicture() { // Paint design of north triangle (it's common to paint north in red color) final Paint northPaint = new Paint(); northPaint.setColor(0xFFA00000); northPaint.setAntiAlias(true); northPaint.setStyle(Style.FILL); northPaint.setAlpha(220); // Paint design of south triangle (black) final Paint southPaint = new Paint(); southPaint.setColor(Color.BLACK); southPaint.setAntiAlias(true); southPaint.setStyle(Style.FILL); southPaint.setAlpha(220); // Create a little white dot in the middle of the compass rose final Paint centerPaint = new Paint(); centerPaint.setColor(Color.WHITE); centerPaint.setAntiAlias(true); centerPaint.setStyle(Style.FILL); centerPaint.setAlpha(220); // final int picBorderWidthAndHeight = (int) ((mCompassRadius + 5) * 2 * mScale); final int picBorderWidthAndHeight = (int) ((mCompassRadius + 5) * 2); final int center = picBorderWidthAndHeight / 2; final Canvas canvas = mCompassRose.beginRecording(picBorderWidthAndHeight, picBorderWidthAndHeight); // Blue triangle pointing north final Path pathNorth = new Path(); pathNorth.moveTo(center, center - (mCompassRadius - 3) * mScale); pathNorth.lineTo(center + 4 * mScale, center); pathNorth.lineTo(center - 4 * mScale, center); pathNorth.lineTo(center, center - (mCompassRadius - 3) * mScale); pathNorth.close(); canvas.drawPath(pathNorth, northPaint); // Red triangle pointing south final Path pathSouth = new Path(); pathSouth.moveTo(center, center + (mCompassRadius - 3) * mScale); pathSouth.lineTo(center + 4 * mScale, center); pathSouth.lineTo(center - 4 * mScale, center); pathSouth.lineTo(center, center + (mCompassRadius - 3) * mScale); pathSouth.close(); canvas.drawPath(pathSouth, southPaint); // Draw a little white dot in the middle canvas.drawCircle(center, center, 2, centerPaint); mCompassRose.endRecording(); }
private void drawBrightnessIndicator(Canvas canvas) { // get a representation of the height of the indicator within the bar float brightnessHeight = mNewColor[2] * mWheel.getHeight(); // Log.d(TAG, String.format("Brightness height: %f", brightnessHeight)); // convert the height to an absolute y position based on the bar's position float absoluteY = mWheelPosition.y + mWheel.getHeight() - brightnessHeight; // get the y value "above" the x axis for the x coordinate calculation // note: because of symmetry, the sign doesn't matter so we'll use the positive float heightAboveXAxis = Math.abs(brightnessHeight - (float) mRadius); // Log.d(TAG, String.format("Height above X: %f", heightAboveXAxis)); float leftEdgeRadius = (float) (mRadius + SPACE_BETWEEN_WHEEL_AND_BAR); float rightEdgeRadius = leftEdgeRadius + ARC_WIDTH; // get the x coordinate relative to the center of the wheel float leftXInCircle = (float) Math.sqrt(leftEdgeRadius * leftEdgeRadius - heightAboveXAxis * heightAboveXAxis); float rightXInCircle = (float) Math.sqrt(rightEdgeRadius * rightEdgeRadius - heightAboveXAxis * heightAboveXAxis); // get the absolute x and y coordinates of the left edge of the bar at the bar height float leftX = mWheelCenter.x + leftXInCircle; float rightX = mWheelCenter.x + rightXInCircle; float indicatorHeight = BRIGHTNESS_INDICATOR_SIZE / 2.0f; float indicatorWidth = BRIGHTNESS_INDICATOR_SIZE; Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStrokeWidth(1.0f); Path leftTrianglePath = new Path(); leftTrianglePath.moveTo(leftX, absoluteY - indicatorHeight); leftTrianglePath.lineTo(leftX + indicatorWidth, absoluteY); leftTrianglePath.lineTo(leftX, absoluteY + indicatorHeight); leftTrianglePath.close(); paint.setColor(Color.BLUE); paint.setStyle(Paint.Style.FILL); canvas.drawPath(leftTrianglePath, paint); paint.setColor(Color.WHITE); paint.setStyle(Paint.Style.STROKE); canvas.drawPath(leftTrianglePath, paint); Path rightTrianglePath = new Path(); rightTrianglePath.moveTo(rightX, absoluteY - indicatorHeight); rightTrianglePath.lineTo(rightX - indicatorWidth, absoluteY); rightTrianglePath.lineTo(rightX, absoluteY + indicatorHeight); rightTrianglePath.close(); paint.setColor(Color.BLUE); paint.setStyle(Paint.Style.FILL); canvas.drawPath(rightTrianglePath, paint); paint.setColor(Color.WHITE); paint.setStyle(Paint.Style.STROKE); canvas.drawPath(rightTrianglePath, paint); }
public void setWindSpeedDirection(int direction) { // ----Point for the triangle indicator------- Point a = new Point(x, y - (int) ((height / 2) - textSize)); Point b = new Point(x - (height / 17), y); Point c = new Point(x + (height / 17), y); Path path = new Path(); path.moveTo(a.x, a.y); path.lineTo(b.x, b.y); path.lineTo(c.x, c.y); path.lineTo(a.x, a.y); path.close(); // Red Brush for the painting Paint redBrush = new Paint(Paint.ANTI_ALIAS_FLAG); redBrush.setColor(Color.RED); redBrush.setStrokeWidth(3f); if (currentDegrees != direction) { // matrix.postRotate(currentDegrees++,x,y); mCanvas.rotate(currentDegrees++, x, y); } else { finishAnimation = true; mCanvas.rotate(direction, x, y); } mCanvas.drawPath(path, redBrush); mCanvas.restore(); }
private void drawIntoBitmap(int i) { Canvas c = new Canvas(mViewBitmap); // Paint p = new Paint(); Paint p = new Paint(Paint.ANTI_ALIAS_FLAG); if (mBlur) { if (mAlphaMark) { p.setAlpha(mBlurVal); } else { mAlphaMark = true; } } // p.setAntiAlias(true); c.save(); Path path = new Path(); path.moveTo(0, 0); path.arcTo( new RectF(-mBitmapViewWidth, -mBitmapViewWidth, mBitmapViewWidth, mBitmapViewWidth), 0, mAngle); // path.lineTo(0, 1); path.close(); c.clipPath(path); // RectF r = new RectF(0, 0, mBitmapViewWidth, mBitmapViewHeight); c.drawBitmap( mBitmap, new Rect(mCurX, mCurY, mRadius + mCurX, mBitmapNewHeight + mCurY), new RectF(0, 0, mBitmapViewWidth, mBitmapViewHeight), p); // mPaint.setTextSize(28); // mPaint.setColor(Color.RED); // c.drawText(debugString, 150, 50, mPaint); }
private void buildShadowCorners() { Object obj = new RectF(-mCornerRadius, -mCornerRadius, mCornerRadius, mCornerRadius); Object obj1 = new RectF(((RectF) (obj))); ((RectF) (obj1)).inset(-mShadowSize, -mShadowSize); float f; float f1; float f2; float f3; int i; int j; int k; if (mCornerShadowPath == null) { mCornerShadowPath = new Path(); } else { mCornerShadowPath.reset(); } mCornerShadowPath.setFillType(android.graphics.Path.FillType.EVEN_ODD); mCornerShadowPath.moveTo(-mCornerRadius, 0.0F); mCornerShadowPath.rLineTo(-mShadowSize, 0.0F); mCornerShadowPath.arcTo(((RectF) (obj1)), 180F, 90F, false); mCornerShadowPath.arcTo(((RectF) (obj)), 270F, -90F, false); mCornerShadowPath.close(); f = mCornerRadius / (mCornerRadius + mShadowSize); obj = mCornerShadowPaint; f1 = mCornerRadius; f2 = mShadowSize; i = mShadowStartColor; j = mShadowStartColor; k = mShadowEndColor; obj1 = android.graphics.Shader.TileMode.CLAMP; ((Paint) (obj)) .setShader( new RadialGradient( 0.0F, 0.0F, f1 + f2, new int[] {i, j, k}, new float[] {0.0F, f, 1.0F}, ((android.graphics.Shader.TileMode) (obj1)))); obj = mEdgeShadowPaint; f = -mCornerRadius; f1 = mShadowSize; f2 = -mCornerRadius; f3 = mShadowSize; i = mShadowStartColor; j = mShadowStartColor; k = mShadowEndColor; obj1 = android.graphics.Shader.TileMode.CLAMP; ((Paint) (obj)) .setShader( new LinearGradient( 0.0F, f + f1, 0.0F, f2 - f3, new int[] {i, j, k}, new float[] {0.0F, 0.5F, 1.0F}, ((android.graphics.Shader.TileMode) (obj1)))); mEdgeShadowPaint.setAntiAlias(false); }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); mPath.moveTo(-1 / 4F * vWidth, waveY); mPath.quadTo(ctrX, ctrY, vWidth + 1 / 4f, waveY); mPath.lineTo(vWidth + 1 / 4f, vHeight); mPath.lineTo(-1 / 4F * vWidth, vHeight); mPath.close(); canvas.drawPath(mPath, mPaint); if (ctrX >= vWidth + 0.25f * vWidth) { isInc = false; } else if (ctrX <= -0.25f * vWidth) { isInc = true; } ctrX = isInc ? ctrX + 20 : ctrX - 20; if (ctrY <= vHeight) { ctrY += 2; waveY += 2; } mPath.reset(); invalidate(); }
/** * Creates arrow icon that depends on ExpandDirection * * @param context context * @param width width of icon in pixels * @param height height of icon in pixels * @param color arrow color * @param expandDirection arrow direction * @return icon drawable */ private static Drawable createArrowIcon( Context context, int width, int height, int color, ExpandDirection expandDirection) { Bitmap canvasBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(canvasBitmap); Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setStrokeWidth(1); paint.setColor(color); paint.setAntiAlias(true); Path path = new Path(); path.setFillType(Path.FillType.EVEN_ODD); switch (expandDirection) { case UP: path.moveTo(0, (height / 3) * 2); path.lineTo(width, (height / 3) * 2); path.lineTo(width / 2, height / 3); path.lineTo(0, (height / 3) * 2); break; case DOWN: path.moveTo(0, height / 3); path.lineTo(width, height / 3); path.lineTo(width / 2, (height / 3) * 2); path.lineTo(0, height / 3); break; } path.close(); canvas.drawPath(path, paint); return new BitmapDrawable(context.getResources(), canvasBitmap); }
@Override public Path draw() { int squareWidth = pathHeight / 4; int middleSquare = squareWidth / 2; Point[] squarePoints = new Point[4]; initializePoints(squarePoints); squarePoints[0].set(center.x - middleSquare, center.y - middleSquare); squarePoints[1].set(center.x + middleSquare, squarePoints[0].y); squarePoints[2].set(squarePoints[1].x, center.y + middleSquare); squarePoints[3].set(squarePoints[0].x, squarePoints[2].y); Point[] starPoints = new Point[4]; initializePoints(starPoints); starPoints[0].set(maxBallSize, center.y); starPoints[1].set(center.x, maxBallSize); starPoints[2].set(pathWidth - maxBallSize, center.y); starPoints[3].set(center.x, pathHeight - maxBallSize); Path starPath = new Path(); starPath.moveTo(starPoints[0].x, starPoints[0].y); starPath.lineTo(squarePoints[0].x, squarePoints[0].y); for (int i = 1; i < 4; i++) { starPath.lineTo(starPoints[i].x, starPoints[i].y); starPath.lineTo(squarePoints[i].x, squarePoints[i].y); } starPath.close(); return starPath; }
@Override protected void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); if (mTabCount == 0) { return; } // under line Paint paint = new Paint(); paint.setColor(mUnderLineColor); RectF rectF = new RectF(0, getHeight() - mUnderLineHeight, getWidth(), getHeight()); canvas.drawRect(rectF, paint); // indicator line mPath.rewind(); float leftX = mIndicatorMarginTab + mLineMarginX; float rightX = leftX + mTabWidth - 2 * mIndicatorMarginTab; mPath.moveTo(leftX, mIndicatorTopY); mPath.lineTo(rightX, mIndicatorTopY); mPath.lineTo(rightX, mIndicatorBottomY); mPath.lineTo(leftX, mIndicatorBottomY); mPath.close(); canvas.drawPath(mPath, mPaintLine); }
public void addPathAndClear() { Path path = new Path(); int size = mPoints.size(); FileUtil.printToFile("\n<<<<<<添加一个热区>>>>>", "hotarea.txt"); for (int i = 0; i < size; i++) { Point p = mPoints.get(i); if (i == 0) { path.moveTo(p.x, p.y); FileUtil.printToFile( "p.moveTo(getGujia_width(" + df.format((float) p.x / (float) mWidth) + "f), getGujia_height(" + df.format((float) p.y / (float) mHeight) + "f));", "hotarea.txt"); } else { path.lineTo(p.x, p.y); FileUtil.printToFile( "p.lineTo(getGujia_width(" + df.format((float) p.x / (float) mWidth) + "f), getGujia_height(" + df.format((float) p.y / (float) mHeight) + "f));", "hotarea.txt"); } } path.close(); m_paths.add(path); Region region = new Region(); region.setPath(path, new Region(0, 0, mWidth, mHeight)); m_regions.add(region); startAddPoint(); }
@Override protected void drawCallout(Canvas canvas, NMapView mapView, boolean shadow, long when) { adjustTextBounds(mapView); stepAnimations(canvas, mapView, when); // Draw inner info window canvas.drawRoundRect(mTempRectF, CALLOUT_ROUND_RADIUS_X, CALLOUT_ROUND_RADIUS_Y, mInnerPaint); // Draw border for info window canvas.drawRoundRect(mTempRectF, CALLOUT_ROUND_RADIUS_X, CALLOUT_ROUND_RADIUS_Y, mBorderPaint); // Draw bottom tag if (CALLOUT_TAG_WIDTH > 0 && CALLOUT_TAG_HEIGHT > 0) { float x = mTempRectF.centerX(); float y = mTempRectF.bottom; Path path = mPath; path.reset(); path.moveTo(x - CALLOUT_TAG_WIDTH, y); path.lineTo(x, y + CALLOUT_TAG_HEIGHT); path.lineTo(x + CALLOUT_TAG_WIDTH, y); path.close(); canvas.drawPath(path, mInnerPaint); canvas.drawPath(path, mBorderPaint); } // Draw title canvas.drawText(mOverlayItem.getTitle(), mOffsetX, mOffsetY, mTextPaint); }
/** * 绘制图网络线 * * @param canvas 画布 * @param lineData 数据集类 * @param arrayDataX x坐标 * @param arrayDataY y坐标 */ private void drawDataPath( Canvas canvas, RadarData lineData, Float[] arrayDataX, Float[] arrayDataY) { float startX = 0.0f, startY = 0.0f; float initX = 0.0f, initY = 0.0f; Path pathArea = new Path(); for (int p = 0; p < arrayDataX.length; p++) { if (0 == p) { initX = startX = arrayDataX[p]; initY = startY = arrayDataY[p]; pathArea.moveTo(initX, initY); } else { pathArea.lineTo(arrayDataX[p], arrayDataY[p]); startX = arrayDataX[p]; startY = arrayDataY[p]; } // 绘制点及对应的标签 renderDotAndLabel(canvas, lineData, arrayDataX[p], arrayDataY[p], p); } // 收尾 pathArea.lineTo(initX, initY); pathArea.close(); lineData.getPlotLine().getLinePaint().setAlpha(mAreaAlpha); // lineData.getPlotLine().getLinePaint().setStyle(Style.STROKE); canvas.drawPath(pathArea, lineData.getPlotLine().getLinePaint()); }
private void drawIntoBitmap() { Paint p = new Paint(Paint.ANTI_ALIAS_FLAG); if (mAlpha) { if (!mBlur) { mViewBitmap.eraseColor(Color.TRANSPARENT); } } if (mBlur) { if (mAlphaMark) { p.setAlpha(mBlurVal); } else { mAlphaMark = true; } } Canvas c = new Canvas(mViewBitmap); c.save(); Path path = new Path(); path.moveTo(0, 0); path.arcTo( new RectF(-mBitmapViewWidth, -mBitmapViewWidth, mBitmapViewWidth, mBitmapViewWidth), 0, mAngle); // path.lineTo(0, 1); path.close(); c.clipPath(path); // c.drawRGB(0, 0, 0); // RectF r = new RectF(0, 0, mBitmapViewWidth, mBitmapViewHeight); c.drawBitmap( mBitmap, new Rect(mCurX, mCurY, mRadius + mCurX, mBitmapNewHeight + mCurY), new RectF(0, 0, mBitmapViewWidth, mBitmapViewHeight), p); }
/** * Draws a needle that is centered at the top or bottom of the compass. * * @param canvas the {@link Canvas} upon which to draw. * @param bottom true to draw the bottom needle, or false to draw the top needle. */ private void drawNeedle(Canvas canvas, boolean bottom) { float centerX = getWidth() / 2.0f; float origin; float sign; // Flip the vertical coordinates if we're drawing the bottom needle. if (bottom) { origin = getHeight(); sign = -1; } else { origin = 0; sign = 1; } float needleHalfWidth = NEEDLE_WIDTH / 2; mPath.reset(); mPath.moveTo(centerX - needleHalfWidth, origin); mPath.lineTo(centerX - needleHalfWidth, origin + sign * (NEEDLE_HEIGHT - 4)); mPath.lineTo(centerX, origin + sign * NEEDLE_HEIGHT); mPath.lineTo(centerX + needleHalfWidth, origin + sign * (NEEDLE_HEIGHT - 4)); mPath.lineTo(centerX + needleHalfWidth, origin); mPath.close(); canvas.drawPath(mPath, mPaint); }
public DrawView(Context context) { super(context); rect = new Rect(0, 0, 100, 100); rect1 = new Rect(0, 0, 500, 200); p = new Paint(Paint.ANTI_ALIAS_FLAG); picture = new Picture(); Canvas canvas = picture.beginRecording(300, 300); p.setColor(Color.GREEN); canvas.drawCircle(150, 100, 80, p); p.setColor(Color.BLUE); canvas.drawRect(20, 70, 150, 200, p); p.setColor(Color.RED); path = new Path(); path.moveTo(170, 80); path.lineTo(240, 210); path.lineTo(100, 210); path.close(); canvas.drawPath(path, p); picture.endRecording(); }
private void updatePath() { float radius = getWidth() / 20; float arrowHeight = getHeight() / 4; Rect rect = new Rect(2, 2, this.getWidth() - 4, this.getHeight() - 4); mPath = new Path(); mPath.moveTo(rect.left + radius, rect.top); mPath.lineTo(rect.right, rect.top); mPath.lineTo(rect.right, rect.bottom - arrowHeight); mPath.lineTo(rect.exactCenterX(), rect.bottom); mPath.lineTo(rect.left, rect.bottom - arrowHeight); mPath.lineTo(rect.left, rect.top); mPath.close(); int color = this.getContext().getResources().getColor(R.color.tag_unselected_outline); if (mIsActive) color = this.getContext().getResources().getColor(R.color.tag_selected_outline); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setColor(color); mPaint.setStyle(Paint.Style.FILL); mPaint.setStrokeWidth(0); mPaint.setStrokeJoin(Paint.Join.ROUND); // set the join to round you // want mPaint.setStrokeCap(Paint.Cap.ROUND); // set the paint cap to round too mPaint.setPathEffect(new CornerPathEffect(radius)); // set the path // effect when they color = this.getContext().getResources().getColor(R.color.tag_unselected); if (mIsActive) color = this.getContext().getResources().getColor(R.color.tag_selected); mShader = new LinearGradient(0, 0, 0, getHeight(), color, color, Shader.TileMode.CLAMP); }
private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) { if (mShowArrow) { if (mArrow == null) { mArrow = new Path(); mArrow.setFillType(Path.FillType.EVEN_ODD); } else { mArrow.reset(); } // Adjust the position of the triangle so that it is inset as // much as the arc, but also centered on the arc. float inset = (int) mStrokeInset / 2 * mArrowScale; float x = (float) (mRingCenterRadius * Math.cos(0) + bounds.exactCenterX()); float y = (float) (mRingCenterRadius * Math.sin(0) + bounds.exactCenterY()); // Update the path each time. This works around an issue in SKIA // where concatenating a rotation matrix to a scale matrix // ignored a starting negative rotation. This appears to have // been fixed as of API 21. mArrow.moveTo(0, 0); mArrow.lineTo(mArrowWidth * mArrowScale, 0); mArrow.lineTo((mArrowWidth * mArrowScale / 2), (mArrowHeight * mArrowScale)); mArrow.offset(x - inset, y); mArrow.close(); // draw a triangle mArrowPaint.setColor(mColors[mColorIndex]); c.rotate( startAngle + sweepAngle - ARROW_OFFSET_ANGLE, bounds.exactCenterX(), bounds.exactCenterY()); c.drawPath(mArrow, mArrowPaint); } }
private Path createFishPath(float fishCenterX, float fishCenterY) { Path path = new Path(); float fishHeadX = fishCenterX; float fishHeadY = fishCenterY - mFishHeight / 2.0f; // the head of the fish path.moveTo(fishHeadX, fishHeadY); // the left body of the fish path.quadTo( fishHeadX - mFishWidth * 0.333f, fishHeadY + mFishHeight * 0.222f, fishHeadX - mFishWidth * 0.333f, fishHeadY + mFishHeight * 0.444f); path.lineTo(fishHeadX - mFishWidth * 0.333f, fishHeadY + mFishHeight * 0.666f); path.lineTo(fishHeadX - mFishWidth * 0.5f, fishHeadY + mFishHeight * 0.8f); path.lineTo(fishHeadX - mFishWidth * 0.5f, fishHeadY + mFishHeight); // the tail of the fish path.lineTo(fishHeadX, fishHeadY + mFishHeight * 0.9f); // the right body of the fish path.lineTo(fishHeadX + mFishWidth * 0.5f, fishHeadY + mFishHeight); path.lineTo(fishHeadX + mFishWidth * 0.5f, fishHeadY + mFishHeight * 0.8f); path.lineTo(fishHeadX + mFishWidth * 0.333f, fishHeadY + mFishHeight * 0.666f); path.lineTo(fishHeadX + mFishWidth * 0.333f, fishHeadY + mFishHeight * 0.444f); path.quadTo( fishHeadX + mFishWidth * 0.333f, fishHeadY + mFishHeight * 0.222f, fishHeadX, fishHeadY); path.close(); return path; }
/** * @param canvas * @param _paint * @param integer * @auther Darly Fronch 2015 上午9:33:27 TODO开始绘画一个一个的图像,调用一次,绘制一个 */ private void paintView(ArrayList<Point> points, Canvas canvas, Paint _paint, int integer) { // TODO Auto-generated method stub if (points == null || canvas == null || _paint == null) { return; } switch (integer) { case 0: // 为体检 _paint.setColor(Color.YELLOW); break; case 1: // 已体检 _paint.setColor(Color.GREEN); break; case 2: // 下一项 try { Thread.sleep(100); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (cout < 100) { cout++; } else { cout = 0; } int alpa = cout % 3; switch (alpa) { case 0: _paint.setColor(getResources().getColor(R.color.color_1)); break; case 1: _paint.setColor(getResources().getColor(R.color.color_2)); break; case 2: _paint.setColor(getResources().getColor(R.color.color_3)); break; } break; default: _paint.setColor(Color.GREEN); break; } if (points != null && points.size() > 0) { /** * @auther Darly Fronch TODO 由于以前使用的是一个Path,考虑到使用同一个Paint进行渲染。但没有考虑到同一个Path * ,变更为各自的Path后。可以满足需求。进行不同的色彩渲染。 */ Path path = new Path(); path.moveTo(points.get(0).x, points.get(0).y); for (int i = 0, length = points.size(); i < length; i++) { path.lineTo(points.get(i).x, points.get(i).y); } path.close(); canvas.drawPath(path, _paint); } }
void drawPoly(int[] points, int ox, int oy, int line, int fill) { path = new Path(); path.moveTo(points[0] + ox, points[1] + oy); for (int i = 1; i < points.length / 2; i++) path.lineTo(points[2 * i] + ox, points[2 * i + 1] + oy); path.close(); gameView.drawPoly(path, line, fill); }
public void setWidth(float width, float height) { mPaperPath.moveTo(0.038f * width, 0.025f * height); mPaperPath.cubicTo( 0.038f * width, 0.025f * height, 0.993f * width, 0.024f * height, 0.993f * width, 0.024f * height); mPaperPath.cubicTo( 0.994f * width, 0.117f * height, 1.0f * width, 0.147f * height, 0.988f * width, 0.501f * height); mPaperPath.cubicTo( 0.977f * width, 0.851f * height, 0.953f * width, 0.888f * height, 0.948f * width, 0.947f * height); mPaperPath.cubicTo( 0.948f * width, 0.947f * height, 0.248f * width, 0.937f * height, 0.003f * width, 0.922f * height); mPaperPath.cubicTo( 0.003f * width, 0.922f * height, 0.023f * width, 0.797f * height, 0.031f * width, 0.529f * height); mPaperPath.cubicTo( 0.041f * width, 0.196f * height, 0.03f * width, 0.136f * height, 0.038f * width, 0.025f * height); mPaperPath.close(); mLinePath.moveTo(0.15f * width, 0.08f * height); mLinePath.lineTo(0.68f * width, 0.08f * height); mLinePath.moveTo(0.186f * width, 0.12f * height); mLinePath.lineTo(0.698f * width, 0.12f * height); mLinePath.close(); /* mLinePath.moveTo(0.334f * width, 0.82f * height); mLinePath.lineTo(0.85f * width, 0.82f * height); mLinePath.moveTo(0.32f * width, 0.86f * height); mLinePath.lineTo(0.832f * width, 0.86f * height);*/ mShadowPath.moveTo(0.03f * width, 0.03f * height); mShadowPath.lineTo(0.03f * width, 0.96f * height); mShadowPath.lineTo(0.98f * width, 0.96f * height); mShadowPath.lineTo(0.98f * width, 0.03f * height); mShadowPath.close(); }
private void drawLiftUp(Canvas canvas) { Path path = new Path(); path.moveTo(0, roundHeight); path.lineTo(0, 0); path.lineTo(roundWidth, 0); path.arcTo(new RectF(0, 0, roundWidth * 2, roundHeight * 2), -90, -90); path.close(); canvas.drawPath(path, paint); }
private void drawRightUp(Canvas canvas) { Path path = new Path(); path.moveTo(getWidth(), roundHeight); path.lineTo(getWidth(), 0); path.lineTo(getWidth() - roundWidth, 0); path.arcTo(new RectF(getWidth() - roundWidth * 2, 0, getWidth(), 0 + roundHeight * 2), -90, 90); path.close(); canvas.drawPath(path, paint); }
private Path makeSlice(float start, float end, int outer, int inner, Point center) { RectF bb = new RectF(center.x - outer, center.y - outer, center.x + outer, center.y + outer); RectF bbi = new RectF(center.x - inner, center.y - inner, center.x + inner, center.y + inner); Path path = new Path(); path.arcTo(bb, start, end - start, true); path.arcTo(bbi, end, start - end); path.close(); return path; }
private void drawLiftDown(Canvas canvas) { Path path = new Path(); path.moveTo(0, getHeight() - roundHeight); path.lineTo(0, getHeight()); path.lineTo(roundWidth, getHeight()); path.arcTo(new RectF(0, getHeight() - roundHeight * 2, 0 + roundWidth * 2, getWidth()), 90, 90); path.close(); canvas.drawPath(path, paint); }