How to position Path2D SVG element in canvas?
问题 I'm drawing a path2D SVG shape on canvas. The problem is that the moveTo function does not seem to work when using SVG data. The problem is illustrated in this codepen. https://codepen.io/grasmachien/pen/rNaJeBN const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); let p = new Path2D('M10 10 h 80 v 80 h -80 Z'); p.moveTo(100,100) ctx.fill(p); Is there a way to move the path without moving the canvas? 回答1: Use the transform to move the path Using