android.graphics.ComposePathEffect Java Examples
The following examples show how to use
android.graphics.ComposePathEffect.
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: Border.java From litho with Apache License 2.0 | 6 votes |
public Border build() { checkNotBuilt(); mResourceResolver = null; if (mNumPathEffects == MAX_PATH_EFFECTS) { mBorder.mPathEffect = new ComposePathEffect(mPathEffects[0], mPathEffects[1]); } else if (mNumPathEffects > 0) { mBorder.mPathEffect = mPathEffects[0]; } if (mBorder.mPathEffect != null && !Border.equalValues(mBorder.mEdgeWidths)) { throw new IllegalArgumentException( "Borders do not currently support different widths with a path effect"); } return mBorder; }
Example #2
Source File: BorderTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void testEffectSetting() { final ComponentContext c = new ComponentContext(getApplicationContext()); Border border = Border.create(c).dashEffect(new float[] {1f, 1f}, 0f).build(); assertThat(border.mPathEffect).isInstanceOf(DashPathEffect.class); border = Border.create(c).discreteEffect(1f, 0f).build(); assertThat(border.mPathEffect).isInstanceOf(DiscretePathEffect.class); border = Border.create(c) .pathDashEffect(new Path(), 0f, 0f, PathDashPathEffect.Style.ROTATE) .build(); assertThat(border.mPathEffect).isInstanceOf(PathDashPathEffect.class); border = Border.create(c).discreteEffect(1f, 1f).dashEffect(new float[] {1f, 2f}, 1f).build(); assertThat(border.mPathEffect).isInstanceOf(ComposePathEffect.class); }
Example #3
Source File: SmoothStrokeMode.java From cidrawing with Apache License 2.0 | 6 votes |
protected CiPaint assignPaint() { CiPaint paint = new CiPaint(drawingContext.getPaint()); paint.setStyle(Paint.Style.STROKE); paint.setAntiAlias(true); paint.setStrokeJoin(Paint.Join.ROUND); paint.setStrokeCap(Paint.Cap.ROUND); if (smoothRadius > 0) { CornerPathEffect effect = new CornerPathEffect(smoothRadius); if (paint.getPathEffect() == null) { paint.setPathEffect(effect); } else { ComposePathEffect composeEffect = new ComposePathEffect(paint.getPathEffect(), effect); paint.setPathEffect(composeEffect); } } return paint; }
Example #4
Source File: MISportsConnectView.java From MISportsConnectWidget with MIT License | 4 votes |
private void init(Context context) { mainTitlePaint = new Paint(); mainTitlePaint.setColor(ContextCompat.getColor(context, R.color.white)); mainTitlePaint.setTextAlign(Paint.Align.CENTER); mainTitlePaint.setTextSize(DensityUtils.sp2px(context, MAIN_TITLE_FONT_SIZE_SP)); mainTitleOffsetY = -(mainTitlePaint.getFontMetrics().ascent + mainTitlePaint.getFontMetrics().descent) / 2; mainTitlePaint.setAntiAlias(true); circleColor = ContextCompat.getColor(context, R.color.whiteTransparent); subTitlePaint = new Paint(); subTitlePaint.setColor(circleColor); subTitlePaint.setTextSize(DensityUtils.sp2px(context, SUB_TITLE_FONT_SIZE_SP)); subTitleOffsetY = DensityUtils.sp2px(context, SUB_TITLE_FONT_OFFSET_DP); subTitleSeparator = getResources().getString(R.string.sub_title_separator); subTitlePaint.setAntiAlias(true); bigCirclePaint = new Paint(); bigCirclePaint.setStrokeWidth(DensityUtils.dp2px(context, BIG_CIRCLE_SIZE)); bigCirclePaint.setStyle(Paint.Style.STROKE); bigCirclePaint.setAntiAlias(true); blurPaint = new Paint(bigCirclePaint); blurSize = DensityUtils.dp2px(context, CIRCLE_BLUR_SIZE); PathEffect pathEffect1 = new CornerPathEffect(DensityUtils.dp2px(getContext(), BIG_CIRCLE_SHAKE_RADIUS)); PathEffect pathEffect2 = new DiscretePathEffect(DensityUtils.dp2px(getContext(), BIG_CIRCLE_SHAKE_RADIUS), DensityUtils.dp2px(getContext(), BIG_CIRCLE_SHAKE_OFFSET)); PathEffect pathEffect = new ComposePathEffect(pathEffect1, pathEffect2); bigCirclePaint.setPathEffect(pathEffect); dottedCirclePaint = new Paint(); dottedCirclePaint.setStrokeWidth(DensityUtils.dp2px(context, DOTTED_CIRCLE_WIDTH)); dottedCirclePaint.setColor(ContextCompat.getColor(context, R.color.whiteTransparent)); dottedCirclePaint.setStyle(Paint.Style.STROKE); float gagPx = DensityUtils.dp2px(context, DOTTED_CIRCLE_GAG); dottedCirclePaint.setPathEffect(new DashPathEffect(new float[]{gagPx, gagPx}, 0)); dottedCirclePaint.setAntiAlias(true); solidCirclePaint = new Paint(); solidCirclePaint.setStrokeWidth(DensityUtils.dp2px(context, SOLID_CIRCLE_WIDTH)); solidCirclePaint.setColor(ContextCompat.getColor(context, R.color.white)); solidCirclePaint.setStyle(Paint.Style.STROKE); solidCirclePaint.setStrokeCap(Paint.Cap.ROUND); solidCirclePaint.setAntiAlias(true); dotPaint = new Paint(); dotPaint.setStrokeWidth(DensityUtils.dp2px(context, DOT_SIZE)); dotPaint.setStrokeCap(Paint.Cap.ROUND); dotPaint.setColor(ContextCompat.getColor(context, R.color.white)); dotPaint.setAntiAlias(true); backgroundBitmap = BitmapFactory.decodeResource(context.getResources(), R.mipmap.bg_step_law); // 设置手表 icon 的大小 watchBitmap = BitmapFactory.decodeResource(context.getResources(), R.mipmap.icon_headview_watch); float scale = DensityUtils.dp2px(context, WATCH_SIZE) / watchBitmap.getWidth(); Matrix matrix = new Matrix(); matrix.postScale(scale, scale); watchBitmap = Bitmap.createBitmap(watchBitmap, 0, 0, watchBitmap.getWidth(), watchBitmap.getHeight(), matrix, true); watchOffset = DensityUtils.sp2px(context, WATCH_OFFSET_DP); fireworksCircle = new FireworksCircleGraphics(context); animationThread = new AnimationThread(); animationThread.start(); }
Example #5
Source File: HollowTextActivity.java From android-graphics-demo with Apache License 2.0 | 4 votes |
private PathEffect getCornerDashPathEffect(int strokeWidth) { PathEffect dash = getDashPathEffect(strokeWidth); PathEffect corner = new CornerPathEffect(strokeWidth); return new ComposePathEffect(dash, corner); }