Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

stroke-dasharray #37

Open
Thanarathanam opened this issue Mar 18, 2014 · 0 comments
Open

stroke-dasharray #37

Thanarathanam opened this issue Mar 18, 2014 · 0 comments

Comments

@Thanarathanam
Copy link

Stroke dash array attribute is different in raphael.js from normal svg.
In raphael js it is one of the following array [“”, “-”, “.”, “-.”, “-..”, “. ”, “- ”, “--”, “- .”, “--.”, “--..”] . But in normal svg it is a list of comma and/or white space separated s and s that specify the lengths of alternating dashes and gaps.

Refer : http://raphaeljs.com/reference.html#Element.attr
and https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray

so if we export svg it will not be correct in stroke dash array.

I suggest add the following case in switch present in 'tag' function (after line 102)

case 'stroke-dasharray':
var sw = attrs['stroke-width'] !== undefined ? attrs['stroke-width'] : 1 ;
switch(element){
case "" :
element = "0";
break;
case "-" :
element = (3_sw)+","+sw;
break;
case "." :
element = sw+","+sw;
break;
case "-." :
element = (3_sw)+","+sw+","+sw+","+sw;
break;
case "-.." :
element = (3_sw)+","+sw+","+sw+","+sw+","+sw+","+sw;
break;
case ". " :
element = sw+","+(3_sw);
break;
case "- " :
element = (4_sw)+","+(3_sw);
break;
case "--" :
element = (8_sw)+","+(3_sw);
break;
case "- ." :
element = (4_sw)+","+(3_sw)+","+sw+","+(3_sw);
break;
case "--." :
element = (8_sw)+","+(3_sw)+","+sw+","+(3_sw);
break;
case "--.." :
element = (8_sw)+","+(3_sw)+","+sw+","+(3_sw)+","+sw+","+(3_sw);
break;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant