Slide 22
Slide 22 text
Bresenham Line Algorithm
canvas.addEventListener('pointermove', event => {
if (previousPoint) {
const currentPoint = { x: ~~event.offsetX, y: ~~event.offsetY };
for(const point of bresenhamLine(previousPoint.x, previousPoint.y,
currentPoint.x, currentPoint.y)) {
ctx.fillRect(point.x, point.y, 2, 2);
}
previousPoint = currentPoint;
}
});
canvas.addEventListener('pointerup', () => {
previousPoint = null;
});
PWA Bootcamp
Von 0 auf MS Paint
Paint
LAB