Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java GWT上下文2D线宽_Java_Gwt - Fatal编程技术网

Java GWT上下文2D线宽

Java GWT上下文2D线宽,java,gwt,Java,Gwt,我正在尝试绘制1像素厚的线条(GWT、Context2d),代码片段如下: 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

我正在尝试绘制1像素厚的线条(GWT、Context2d),代码片段如下:

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();
context.beginPath();
设置行程方式(“rgb(255,0,0)”;
上下文。设置线宽(1f);
双x=0;
双网格尺寸=10.0f;
而(x
此代码绘制的线条至少有2像素厚。

有什么想法吗?

试着给你的坐标加上0.5。
浏览器应用抗锯齿这可能会导致模糊或“2像素厚的线条”。

尝试将0.5添加到坐标中。 浏览器应用抗锯齿这可能会导致模糊或“2像素厚的线条”