pixi-svg-graphics icon indicating copy to clipboard operation
pixi-svg-graphics copied to clipboard

parsing of Q (quadratic Bézier) command is missing from Path.

Open julapy opened this issue 8 years ago • 2 comments

came across a SVG which contained the Q command in the path data. had a look in the SVG 1.1 spec and it does support it, https://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands currently missing support for this case in pixi-svg-graphics

julapy avatar Feb 05 '17 09:02 julapy

i think this might do it,

	      case 'q':
	        for (var l = 0, llen = args.length; l < llen; l += 2) {
	          args[l] += offset.x
	          args[l + 1] += offset.y
	        }

	        this._graphics.bezierCurveTo(
	          lastCoord.x,
	          lastCoord.y,
	          args[0],
	          args[1],
	          args[2],
	          args[3]
	        )
	        lastCoord = { x: args[2], y: args[3] }
	        lastControl = { x: args[0], y: args[1] }
	        break

its not crashing, but haven't tested it properly yet. let me know if you see any obvious issues with the above.

julapy avatar Feb 05 '17 09:02 julapy

oops more like,

      case 'q':
        for (var l = 0, llen = args.length; l < llen; l += 2) {
          args[l] += offset.x
          args[l + 1] += offset.y
        }

        this._graphics.bezierCurveTo(
          args[0],
          args[1],
          args[0],
          args[1],
          args[2],
          args[3]
        )
        lastCoord = { x: args[2], y: args[3] }
        lastControl = { x: args[0], y: args[1] }
        break

julapy avatar Feb 05 '17 09:02 julapy