Reputation: 11
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
Reputation: 140
Try to add 0.5 to your coordinates. Browsers apply antialiasing this may cause blurriness or "2 pixel thick lines".
Upvotes: 1