user2523199
user2523199

Reputation: 11

GWT Context2d lineWidth

Im trying to draw lines (GWT, Context2d) that are 1 pixel thick, code snippet below:

context.beginPath();
context.setStrokeStyle("rgb(255,0,0)");
context.setLineWidth(1f);
double x = 0;
double gridSize = 10.0f;
while (x < w){
    x += gridSize;
    context.moveTo(x, 0);
    context.lineTo(x, h);
}
context.stroke();

This code draws lines that are at least 2 pixel thick.
Any ideas?

Upvotes: 1

Views: 192

Answers (1)

fabfry
fabfry

Reputation: 140

Try to add 0.5 to your coordinates. Browsers apply antialiasing this may cause blurriness or "2 pixel thick lines".

Upvotes: 1

Related Questions