Reputation: 372
I have this code for drawpath and nothing shows up and I cant figure out why.
//i move the path's starting point somewhere up here to a point.
//get center x and y are the centers of a picture. it works when i
//do drawline and store the different starting points
//but i want it to look continuous not like a lot of different
//lines
path.lineTo(a.getCenterX(), a.getCenterY());
path.moveTo(a.getCenterX(), a.getCenterY());
p.setStrokeWidth(50);
p.setColor(Color.BLACK);
canvas.drawPath(path,p);
thanks in advance
Upvotes: 2
Views: 10059
Reputation: 9309
A new Paint instance only fills paths.
To stroke paths, set the Paint style:
paint.setStyle(Paint.Style.STROKE);
If the background you're painting on is black, change the color, so you can see the paint:
paint.setColor(Color.RED); // something other than the background color
Optional:
paint.setStrokeWidth(10); // makes the line thicker
Upvotes: 14
Reputation: 372
i had to add this to paint in order to make it work. dunno why.
mPaint.setDither(true);
mPaint.setColor(0xFFFFFF00);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(3);
Upvotes: 6
Reputation: 12375
I think the best way to solve your problem is by changing the code as follows:
private final int strokeWidth = 50;
path.lineTo(a.getCenterX() + strokewidth / 2, a.getCenterY() + strokeWidth / 2);
path.moveTo(a.getCenterX(), a.getCenterY());
p.setStrokeWidth(strokeWidth);
p.setColor(Color.BLACK);
canvas.drawPath(path,p);
You may have to play with this, but this should basically overlap the lines so it looks like they are continuous.
You will likely have to put a switch statement in for which direction you are drawing in, but that should be fairly trivial.
I hope this helps!
Upvotes: 0