Akilan
Akilan

Reputation: 934

canvas line glitch

when draw a line in canvas using path i getting little glitch as in picture below...i'm new to android development..i know i'm making some silly mistake i don't know what it is...if anyone hav an idea help me..thanks

enter image description here

enter image description here

my path code is

 path.moveTo((this.pos/2),0);
              path.lineTo((this.pos/2),25);
              path.lineTo(this.pos,25);
              path.close();
              canvas.drawPath(path, ppaint);

Upvotes: 2

Views: 241

Answers (2)

Dominique Fortin
Dominique Fortin

Reputation: 2238

You could try

ctx.beginPath();
ctx.moveTo((this.pos/2),0);
ctx.lineTo((this.pos/2),25);
ctx.lineTo(this.pos,25);
ctx.closePath();
ctx.strokeStyle = "Red";//border color here
ctx.stroke();
ctx.fillStyle = "blue";//fill color here
ctx.fill();

Upvotes: 0

Bill Mote
Bill Mote

Reputation: 12823

You can just use canvas.drawLine(this.pos/2, 25, this.pos, 25, ppaint). drawPath() is working as expected in your code ;)

Upvotes: 1

Related Questions