Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/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
Dart 如何确保画布不会';在HDPI屏幕上看不清楚?_Dart - Fatal编程技术网

Dart 如何确保画布不会';在HDPI屏幕上看不清楚?

Dart 如何确保画布不会';在HDPI屏幕上看不清楚?,dart,Dart,如果我使用html画布,HDPI屏幕上的一切看起来都很模糊。如何修复(使用省道)?您基本上需要将画布放大两倍,然后重新缩放。在将任何内容绘制到画布之前,请运行以下函数: void fixHDPI(){ num ratio=window.devicePixelRatio; 如果(比率!=1){ num oldWidth=myCanvas.width,oldHeight=myCanvas.height; 我的画布 …宽度=(旧宽度*比率).round() …高度=(旧高度*比率).round() .

如果我使用html画布,HDPI屏幕上的一切看起来都很模糊。如何修复(使用省道)?

您基本上需要将画布放大两倍,然后重新缩放。在将任何内容绘制到画布之前,请运行以下函数:

void fixHDPI(){
num ratio=window.devicePixelRatio;
如果(比率!=1){
num oldWidth=myCanvas.width,oldHeight=myCanvas.height;
我的画布
…宽度=(旧宽度*比率).round()
…高度=(旧高度*比率).round()
..style.width=“${oldWidth}px”
..style.height=“${oldHeight}px”
..上下文2D.规模(比率、比率);
}
}