Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

normalizedPathSegList

65 views
Skip to first unread message

yan

unread,
Oct 12, 2011, 6:57:20 AM10/12/11
to
Hi,
Do you know if the normalizedPathSegList attribute of path elements
will soon be implemented in firefox ?
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 would do ?
I wrote an example at http://jsfiddle.net/s32LX/, but I join 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 ?
*/
}
}
};

Robert Longson

unread,
Oct 13, 2011, 4:13:25 PM10/13/11
to
On Oct 12, 11:57 am, yan <yannick.bocha...@free.fr> wrote:
> Hi,
> Do you know if the normalizedPathSegList attribute of path elements
> will soon be implemented in firefox ?

https://bugzilla.mozilla.org/show_bug.cgi?id=446654 has been around
for 3 years and nobody has stepped up to implement it. Why don't you?
Patches are always welcome.

Best regards

Robert.

yannick....@free.fr

unread,
Oct 19, 2011, 5:56:55 AM10/19/11
to Robert Longson, dev-te...@lists.mozilla.org
Hi,
I wrote a partial javascript workaround : 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.
I wish I could submit a patch, but I lack experience at this time.
Best regards,

Yannick Bochatay
http://ybochatay.fr

----- Mail original -----
De: "Robert Longson" <long...@gmail.com>
À: dev-te...@lists.mozilla.org
Envoyé: Vendredi 14 Octobre 2011 00:13:25
Objet: Re: normalizedPathSegList
_______________________________________________
dev-tech-svg mailing list
dev-te...@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-svg
0 new messages