Do you think it would be possible to make SVG go out with canvas too ?
For some uses, SVG is simpler. For others, canvas suits better.
Do you think one day, I will be able to code something like :
- Code: Select all
<svg>
<circle/>
<canvas/>
<rect/>
</svg>
?
maybe we should enclose <canvas> in a <foreignObject> (?)
It would be great I think.
edit : sorry I didn't read the sticky post. I'm reformulating and developing.
» What is the problem you are trying to solve?
SVG vs canvas duality. For some use cases, SVG is simpler. For others, canvas suits better. Usually declarative (svg) is more easily maintained, and it has the advantage of being scalable. Sometimes you don't need SVG and are happy to have a canvas that doesn't memorize the drawn objects.
And dynamically drawing on a canvas is sometimes less verbose.
But at the moment, you can't do both at a time.
» What is the feature you are suggesting to help solve it?
Provide a svg extension to include a <canvas> into a svg document.
- Code: Select all
<foreignObject width="100" height="50" requiredExtensions="http://spec.whatwg.org/SVGExtensions/Canvas">
<canvas id="aCanvas" width="100" height="50"></canvas>
</foreignObject>
» What is the processing model for that feature, including error handling?
The canvas will render at the layer of its foreignObject parent, taking the transforms and filters of its ancestors into account.
Any affecting function call to the canvas API will trigger the required redaw of the dirty region.
I don't think any of the canvas attributes should be animatable.
All DOMEvents to foreignObject will be forwared to the canvas.
All other mechanism are defined by the xml, dom specs.
» Why do you think browsers would implement this feature?
SVG already have the concept of canvas. I have a feeling that a html canvas and a svg canvas already share the same codebase for the implementors. The two are very similar I think.
» Why do you think authors would use this feature?
If they want to develop an online whiteboard for example. The whiteboard itself is a canvas. The controls, buttons, menus, dialogs, etc... will be programmed with clean declarative xml svgElements.
» What evidence is there that this feature is desparately needed?
Once some authors will have to reprogram their webapp from svg to canvas or from canvas to svg because they have misevaluated the consequences when starting, they will be desperate.

Although, you can already find some implementations of scripted svg2canvas or canvas2svg transformers on the web. Which clearly mean that some people hesitate between the two.
The first answer to this post is very informative.
Thanks Simon !
This request refers to the last line of that article.
--end of edit
Thanks.
David