Задать вопрос
@JyriG

Почему линии canvas/js нечеткие?

Нужно создать динамичную сетку координатов на js/canvas.

Такой код:
function draw() {

      var canvas = document.getElementById('canvas');
      if (canvas.getContext) {
        var context = canvas.getContext('2d');

        for(var x=0.5;x<500;x+=10) {
          context.moveTo(x,0);
          context.lineTo(x,500);
        }

        for(var y=0.5; y<500; y+=10) {
          context.moveTo(0,y);
          context.lineTo(500,y);

      }

      context.strokeStyle='grey';
      context.stroke();

  }
}

function showCoords(event) {
    var x = event.clientX - 10;
    var y = event.clientY - 10;
    var coords = "X coordinates: " + x + ", Y coordinates: " + y;
    document.getElementById('showCoords').innerHTML = coords;

  }

с щепоткой кода делает такой вот результат: 61de2b39c1648115799933.jpeg. Как сделать линии четкими? Библиотеки не используются.
  • Вопрос задан
  • 407 просмотров
Подписаться 2 2 комментария