项目:android-study
文件:PathEffectView.java
@Override protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//无效果
mEffects[0] = null;
//拐角处变得圆滑
mEffects[1] = new CornerPathEffect(30);
//线段上就会产生许多杂点
mEffects[2] = new discretePathEffect(3.0F,5.0F);
//绘制虚线
mEffects[3] = new DashPathEffect(new float[] { 20,10,5,10 },0);
Path path = new Path();
path.addRect(0,8,Path.Direction.ccw);
//设置点的图形,即方形点的虚线,圆形点的虚线
mEffects[4] = new PathDashPathEffect(path,12,PathDashPathEffect.Style.ROTATE);
//组合PathEffect
mEffects[5] = new ComposePathEffect(mEffects[3],mEffects[1]);
for (int i = 0; i < mEffects.length; i++) {
mPaint.setPathEffect(mEffects[i]);
canvas.drawPath(mPath,mPaint);
canvas.translate(0,200);
}
}
项目:drawa-android
文件:Fluffy.java
@Override
Paint initPaint() {
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.stroke);
paint.setstrokeJoin(Paint.Join.MITER);
paint.setstrokeCap(Paint.Cap.SQUARE);
paint.setstrokeMiter(0.2f);
paint.setPathEffect(new discretePathEffect(2,2));
return paint;
}
项目:binea_project_for_android
文件:PathEffectView.java
private void initPaint() {
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setStyle(Paint.Style.stroke);
mPaint.setstrokeWidth(5);
mPaint.setColor(Color.RED);
mPath = new Path();
mPath.moveto(0,0);
for(int i = 0;i<=30;i++){
mPath.lineto(i*35,(float)Math.random()*100);
}
mEffects = new PathEffect[7];
mEffects[0] = null;
mEffects[1] = new CornerPathEffect(10);
mEffects[2] = new discretePathEffect(3.0F,5.0F);
mEffects[3] = new DashPathEffect(new float[] { 20,mPhase);
Path path = new Path();
path.addRect(0,Path.Direction.ccw);
mEffects[4] = new PathDashPathEffect(path,mPhase,PathDashPathEffect.Style.ROTATE);
mEffects[5] = new ComposePathEffect(mEffects[2],mEffects[4]);
mEffects[6] = new SumPathEffect(mEffects[4],mEffects[3]);
}
项目:MISportsConnectWidget
文件:MISportsConnectView.java
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,watchBitmap.getWidth(),watchBitmap.getHeight(),matrix,true);
watchOffset = DensityUtils.sp2px(context,WATCH_OFFSET_DP);
fireworksCircle = new FireworksCircleGraphics(context);
animationThread = new AnimationThread();
animationThread.start();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。