PathDashPathEffect example - Hallo sahabat Teknologi Terbaru, Pada Artikel yang anda baca kali ini dengan judul PathDashPathEffect example, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.
Judul : PathDashPathEffect example
link : PathDashPathEffect example
PathDashPathEffect example
android.graphics.PathDashPathEffect dash the drawn path by stamping it with the specified shape.Example:
![]() |
PathDashPathEffect example |
Modify MyView.java from the post.
package com.example.androidview;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.graphics.PathDashPathEffect;
import android.util.AttributeSet;
import android.view.View;
public class MyView extends View {
Paint paint;
Path path;
public MyView(Context context) {
super(context);
init();
}
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public MyView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
paint = new Paint();
paint.setColor(Color.RED);
paint.setStrokeWidth(20);
paint.setStyle(Paint.Style.STROKE);
path = new Path();
Path pathShape = new Path();
pathShape.addCircle(10, 10, 10, Direction.CCW);
float advance = 30.0f;
float phase = 20.0f;
PathDashPathEffect.Style style = PathDashPathEffect.Style.ROTATE;
PathDashPathEffect pathDashPathEffect =
new PathDashPathEffect(pathShape, advance, phase, style);
paint.setPathEffect(pathDashPathEffect);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(Color.GRAY);
path.reset();
path.moveTo(50, 50);
path.lineTo(50, getHeight()-50);
path.lineTo(getWidth()-50, getHeight()-50);
path.lineTo(getWidth()-50, 50);
path.close();
canvas.drawPath(path, paint);
}
}
Demikianlah Artikel PathDashPathEffect example
Sekianlah artikel PathDashPathEffect example kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.
0 Response to "PathDashPathEffect example"
Post a Comment