Skip to content

Commit 75fbf22

Browse files
committed
Draw circles with <circle> rather than <path> to avoid rendering glitches
1 parent 7d6b429 commit 75fbf22

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ganja.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@
649649
var make_arrow_marker_def = (color) => {
650650
if (marker_defs[color]) return ''; marker_defs[color]=true;
651651
return `<defs>
652-
<marker id="marker-${color}" orient="auto" markerWidth="10" markerHeight="10" refX="9" refY="5"><path d="M 1 1 L 9 5 L 1 10" stroke-width="1" stroke="${color||'#888'}" fill="none"/></marker>
652+
<marker id="marker-${color}" orient="auto" markerWidth="10" markerHeight="10" refX="9" refY="5"><path d="M 1 0 L 9 5 L 1 10" stroke-width="1" stroke="${color||'#888'}" fill="none"/></marker>
653653
</defs>`;
654654
};
655655
@@ -693,10 +693,12 @@
693693
var loc=o.Div(cga2d_ni.LDot(o)); lx=sc*(-loc.e1); ly=sc*(loc.e2);
694694
var r2=o.Mul(o.Conjugate).s;
695695
var r = Math.sqrt(Math.abs(r2))*sc;
696-
return `${make_arrow_marker_def(color||'#888')}<path d="
696+
// draw the markers separately, to avoid a chrome rendering bug with <path> (gh-73)
697+
return `<CIRCLE onmousedown="this.parentElement.sel=${oidx}" cx="${lx}" cy="${ly}" r="${r}" stroke-width="${lineWidth*0.005}" fill="none" stroke="${color||'green'}" stroke-dasharray="${dash_for_r2(r2, r, lineWidth*0.020)}"/>
698+
${make_arrow_marker_def(color||'#888')}<path d="
697699
M ${lx - r} ${ly}
698700
a ${r} ${r} 0 0 ${+(direction.e12 < 0)} ${2*r} 0
699-
a ${r} ${r} 0 0 ${+(direction.e12 < 0)} ${-2*r} 0" marker-mid="url(#marker-${color||'#888'})" marker-end="url(#marker-${color||'#888'})" stroke-width="${lineWidth*0.005}" fill="none" stroke="${color||'green'}" stroke-dasharray="${dash_for_r2(r2, r, lineWidth*0.020)}"/>`;
701+
a ${r} ${r} 0 0 ${+(direction.e12 < 0)} ${-2*r} 0" marker-mid="url(#marker-${color||'#888'})" marker-end="url(#marker-${color||'#888'})" fill="none" stroke="none"/>`;
700702
} else if (!is_flat && !b0 && b1 && !b2) {
701703
// Point Pairs.
702704
lr=0; var ei=cga2d_ni,eo=cga2d_no, nix=o.Wedge(ei), sqr=o.LDot(o).s/nix.LDot(nix).s, r=Math.sqrt(Math.abs(sqr)), attitude=((ei.Wedge(eo)).LDot(nix)).Normalized.Mul(Element.Scalar(r)), pos=o.Div(nix); pos=pos.Div( pos.LDot(Element.Sub(ei)));

0 commit comments

Comments
 (0)