Serialize p5 canvas to SVG in most recent release

Hello,

I've been exporting my canvas using runemadsen's example code here: https://github.com/runemadsen/p5-svg-test

I want to use the most recent release of p5.js but unfortunately this code does not work:

ctx.prototype.getSerializedSvg = function(fixNamedEntities) {
var serialized = new XMLSerializer().serializeToString(this.__root);

return serialized;
}

var p5SVG = (function(){

  p5.prototype.beginRecord = function () {
    this.orgDrawingContext = this.drawingContext;
    this.drawingContext = new C2S(this.drawingContext.canvas.clientWidth, this.drawingContext.canvas.clientHeight);
  };

  p5.prototype.endRecord = function () {
    document.body.innerHTML += 'Exported SVG' + this.drawingContext.getSerializedSvg(true) + '';
    this.drawingContext = this.orgDrawingContext;
  };

})();



returns serialized as empty when using p5.js v0.4.22

It works fine in version p5.js v0.3.2

Any idea what changed?

thanks!

Answers

Sign In or Register to comment.