<!DOCTYPE html><html> <head> <title></title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> canvas{width: 1000px;height: 500px;} </style> </head> <body> <canvas id="canvas" width="1000" height="500" ></canvas> </body> <script> var canvas = document.getElementById('canvas'); var context = canvas.getContext('2d'); context.beginPath(); context.moveTo(100,200); context.lineTo(200,200); context.moveTo(100,300-0.5); context.lineTo(200,300-0.5); context.stroke(); </script></html>在偶然的情況下。我發(fā)現(xiàn)-0.5能實現(xiàn)我想要讓線條變細的樣式,lineWidth明明是設置線寬,但實際上是附帶了顏色深淺。最小只能到1.但是為什么我設置坐標減少0.5后線條反而變細了呢?不太懂。求解
關于很詭異的canvas線條粗細的問題
BIG陽
2018-12-19 18:09:07