Can anyone give me an example of these attributes in action: stroke-dasharray, stroke-linecap, stroke-linejoin i tried using them, but i don\'t quite understand the sente
Please note that this answer covers only stroke-dasharray
and is a supplement to answer by Phrogz.
Raphael does not provide a lot of freedom to set stroke-dasharray
as stated by user568458 and as I needed it to work like other svg creators I did a little tweak in raphael.js
to accommodate all possible stroke-dasharray
values.
addDashes = function (o, value, params) {
var nvalue = dasharray[Str(value).toLowerCase()];
if (nvalue!==undefined) {
var width = o.attrs["stroke-width"] || "1",
butt = {round: width, square: width, butt: 0}[o.attrs["stroke-linecap"] || params["stroke-linecap"]] || 0,
dashes = [],
i = nvalue.length;
while (i--) {
dashes[i] = nvalue[i] * width + ((i % 2) ? 1 : -1) * butt;
}
$(o.node, {"stroke-dasharray": dashes.join(",")});
}else{
$(o.node, {"stroke-dasharray": Str(value).toLowerCase()});
}
}
Replacing the previous code in the file just below where dasharray
object is defined.