Hi,
I wrote a partial javascript workaround for the unimplemented 
normalizedPathSegList property :
http://jsfiddle.net/ybochatay/AtTND/3/ or https://gist.github.com/1297684
It's not the normalizedPathSegList property as described by the W3C but a 
function to convert paths with only M,L,C and Z segments.
You can set the degree of Bezier Curves to approximate arcs (1 will produce L 
segments, 2 Q, 3 C), and the defaultFlatness.
Regards,

Yannick Bochatay
http://ybochatay.fr

----- Mail original -----
De: "yannick bochatay" <[email protected]>
À: [email protected]
Envoyé: Mercredi 12 Octobre 2011 15:00:53
Objet: [svg-developers] normalizedPathSegList






Hi, 
I try to write a function to update points of a path from a transformation 
matrix. It's all ok except for elliptical arcs : 
I can't find the correct coefficients for r1 r2 and angle. 
Is it simplier to approximate arcs with bezier curves, like the 
normalizedPathSegList property would do (but not implemented yet) ? 
I wrote an example at http://jsfiddle.net/s32LX/, but I've put the code below 
anyway. 
Best regards, 

Yannick Bochatay 
http://ybochatay.fr 

SVGPathElement.prototype.mtx2attrs = function(mtx) { 

var seg,letter,point,pt={}, 
angle = Math.atan2(mtx.b, mtx.a), 
svg = this.ownerSVGElement, 
list = this.pathSegList, 
i=0, N = list.numberOfItems; 

/* this.rel2abs(); function that change relative paths to absolute */ 

for (;i<N;i++) { 
seg = list.getItem(i); 
letter = seg.pathSegTypeAsLetter; 

['','1','2'].forEach(function(ind) { 

if (seg['x'+ind] === undefined && seg['y'+ind] === undefined) { return; } 

if (seg['x'+ind] !== undefined) { pt['x'+ind] = seg['x'+ind]; } 
if (seg['y'+ind] !== undefined) { pt['y'+ind] = seg['y'+ind]; } 

var point = svg.createSVGPoint(); 
point.x = pt['x'+ind]; point.y = pt['y'+ind]; 
point = point.matrixTransform(mtx); 

seg['x'+ind] = point.x; 
seg['y'+ind] = point.y; 
}); 

if (angle!==0 && (letter === 'H' || letter === 'V')) { 
this.pathSegList.replaceItem( this.createSVGPathSegLinetoAbs(seg.x,seg.y) , i 
); 
} 
else if (letter === 'A') { 
/*what to do in that case ?? 
seg.r1 = ? 
seg.r2 = ? 
seg.angle+= angle ? 
*/ 
} 
} 
}; 

 


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

-----
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