W3C home > Mailing lists > Public > www-svg@w3.org > May 2014

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

From: Gavin Kistner <phrogz@me.com>
Date: Tue, 27 May 2014 07:03:47 -0600
Cc: Emanuel Allen <emanuelallen@hotmail.com>, "<www-svg@w3.org>" <www-svg@w3.org>
Message-id: <01A761F5-6121-46B3-93E3-5C7BE1C957DC@me.com>
To: Dirk Schulze <dschulze@adobe.com>
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
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 );

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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:54:53 UTC