The standard in SVG is declarative. The standard in Canvas is functional (very 
similar to the Flash APIs). Here’s a good write-up comparing Flash to Canvas.[1]

I would like to present a unified API so SVG and Canvas could be swapped out 
for each other. So for SVG, my idea is to construct the markup using function 
calls and for Canvas to decompose the markup into function calls.

This would enable pathTo, lineTo, etc. as well as drawPath() for all targets. I 
also want to add rotate() translate() setMatrix(), etc to the unified API.

I’ll create this branch. I hope to have something early next week to inspect.

Harbs

[1]http://www.williammalone.com/articles/flash-vs-html5-canvas-drawing/
On Jul 21, 2016, at 8:44 PM, Alex Harui <aha...@adobe.com> wrote:

> 
> 
> On 7/21/16, 10:19 AM, "Harbs" <harbs.li...@gmail.com> wrote:
> 
>> Unless folks have a problem with it, I’m going to try and refactor some
>> naming. If what I do is too drastic, we can revert my changes…
>> 
>> I’ll try and keep my changes in clearly separate commits. I can do it on
>> a feature branch if folks prefer.
> 
> Well, I'm all for seeing what you are thinking about.  A branch, or even
> just a list of the proposed APIs in an email is fine if you want to get
> something for us to see without having to chase down all references to
> Graphics from the other code in the repo.
> 
> I haven't looked at Canvas yet, but I happened across [1] where a code
> snippet looks like:
> 
> var draw = SVG('drawing').size(800, 800).path("M75,0 L75,118.85 A30,30 0 0
> 0 640,660.15 L568.5690264688633,781.8607965826662 ").attr({ stroke:
> '#000', fill: 'none' });
> 
> 
> I haven't found an actual "curveTo" call on SVG.  Maybe I'm missing it, so
> I'm having trouble envisioning how much JS code will be written and run to
> emulate Flash graphics vs creating API that would support snippets like
> this that people might find on the web and try.
> 
> Thanks,
> -Alex
> 
> [1] 
> http://stackoverflow.com/questions/21706590/how-to-draw-arc-using-svg-js
> 
>> 
>> On Jul 21, 2016, at 7:21 PM, Alex Harui <aha...@adobe.com> wrote:
>> 
>>> 
>>> 
>>> On 7/21/16, 7:06 AM, "Harbs" <harbs.li...@gmail.com> wrote:
>>> 
>>>> For svg and canvas, the drawing commands map pretty cleanly to their
>>>> HTML
>>>> counterparts, so it would be pretty clean.
>>> 
>>> I haven't spent any serious time thinking about it.  Just quickly, I saw
>>> flash.display.Graphics.drawPath which seems quite different from SVG
>>> drawPath.  And that's the sort of thing I was referring to.  IMO, no
>>> need
>>> to require folks to use Vectors of ValueObjects to define the path, just
>>> let them use the encoded string format.  And if there are
>>> incompatibilities between the syntax used by Flex vs SVG, choose the SVG
>>> one and have the FlexJS implementation do the scanning of the path
>>> string.
>>> Don't have the JS implementation make the developer pay for the scan.
>>> 
>>> Again, just my 2 cents,
>>> -Alex
>>> 
>> 
> 

Reply via email to