In order to perform transform operations in script rather than doing it
declaratively (whence the stack of transforms can become gnarly), I was
thinking about ways to simplify the code (from the human rather than the
computational perspective). By such perspective, the minimum number of
statements is to be optimized rather than minimizing run-time - I know it is
a funny metric, but people have been looking at things like this since the
1970's believe it or not.

 

Anyhow, I wanted to develop a function which would take the d attribute of
paths or glyphs (of any sort):

 

d="M 1550 710.5 Q 1650 840 1610.5 920.5 Q 1580 1010 1130.5 970 Q 690 930 840
810 Q 990 690 1010.5 450.5 Q 1040 220 1190 190.5 Q 1340 170 1480.5 210 Q
1630 250 1540 420 Q 1450 590 1550 710.5 M 940.5 860.5 Q 610 1100 630.5 1170
Q 660 1240 770 1250.5 Q 880 1270 1110.5 1270 Q 1350 1270 1610 1300 Q 1870
1330 1920 1250.5 Q 1970 1180 1810 1060 Q 1650 940 1460.5 780.5 Q 1280 630
940.5 860.5 z"

 

Or

 

d="M50,100

A100,50 0 0 1 250,100

A80,40 0 0 1 90,100

A60,30 0 0 1 210,100

A40,20 0 0 1 130,100

A20,10 0 0 1 170,100"

 

and then separate the subcommands (A,M, Q, L, l, s, z, etc) from the
coordinates thusly

 

A=d.match(/regexp/g)

B=d.split(/regexp/g)

 

And then perform arithmetic on all i in A and then join everything back
together in one swell foop:

 

C=d.gaps(/regexp/g,/regexp2/g)  (where the mythical "gaps" method of the
array object would return an array of the number of regexp2-delimited items
between A's boundaries)

 

The properly defined "gaps" method would then allow something like

 

D=superJoin(A,B,C) ==d

And D=superjoin (A,arithmetic(B),C) == transform(d) 

 

As it is, I'm going to have to write loops to walk through the structure,
pushing operators, numbers and coordinates onto separate stacks and then to
loop through again to reconstitute the whole mess. Not a terrible thing, but
.. Such tedium!

 

Any ideas if such a construct has been posited before? It would be very
handy for SVG path processing.  

 

Cheers

David



[Non-text portions of this message have been removed]



------------------------------------

-----
To unsubscribe send a message to: [email protected]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
----Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to