Re: Request/proposal a SVG API for the canvas; var ctx = canvas.getcontext("svg");

On May 25, 2014, at 12:59 AM, Dirk Schulze <dschulze@adobe.com> wrote:
> On May 24, 2014, at 11:47 PM, Emanuel Allen <emanuelallen@hotmail.com> wrote:
>> AND SVG API CANVAS!!! I understand that it would be a process, but for the time being, how about transferring the data into canvas's native data, but still able to manipulate the image with SVG syntax. making it similar to typing the 2d context canvas as well.
> 
> It would be a lot easier to understand the proposal if you would add more details. From what I get, you want to use the Canvas API to create SVG documents.

Doing that, I think, would be more like
canvas.toDataURL(“image/svg+xml”);
Instead, it seems to me that he wants to use SVG commands to draw on the Canvas. If so, this is already possible indirectly.

var can      = document.querySelector('#my-canvas'),
    ctx      = can.getContext('2d'),
    loader   = new Image;                       // Not shown on page

loader.width  = can.width;
loader.height = can.height;
loader.onload = function(){
  ctx.drawImage( loader, 0, 0, loader.width, loader.height );
};
var svgAsXML = "<svg xmlns='http://www.w3.org/2000/svg' "
             + "width='"+can.width+"px' "
             + "height='"+can.height+"px'>"
             + …the rest of your code…
             + "</svg>";
loader.src = 'data:image/svg+xml,' + encodeURIComponent( svgAsXML );

http://stackoverflow.com/questions/5433806/convert-embedded-svg-to-png-in-place

Received on Tuesday, 27 May 2014 13:04:54 UTC