I wanted to use "/parrow" PostScript define, a line and an arc.
It turned out to be harder than thought to get things right, but now it works as it should.
Currently it is a hack, with all the calculations in modified "embedding_demo.2.js".
Later there will be a "/parrow" like definition in "ps.js" that will be easy to use.
Here again is single-face non-embedding from previous posting, with the new (blue) face traversal indicators
P.S:
As already said, not nice right now:
Code: Select all
...
ps.straight_line_drawing(G, coords, [], size, r, [], false);
function draw_vertex_edge_label(G, v, e, coords, l) {
var w = opposite(G, v, e);
var cx = (ps.scrx(coords[0][v]) + ps.scrx(coords[0][w])) / 2;
var cy = (ps.scry(coords[1][v]) + ps.scry(coords[1][w])) / 2;
var deg = Math.atan2(coords[1][v] - coords[1][w], coords[0][w] - coords[0][v]) * 180 / Math.PI;
v = w;
e = next_incident_edge(G, v, e);
w = opposite(G, v, e);
var deg2 = Math.atan2(coords[1][v] - coords[1][w], coords[0][w] - coords[0][v]) * 180 / Math.PI;
console.log("0 0 0 setrgbcolor");
console.log("12 " + ps.frm(deg) + " (" + l + ") " + ps.frm(cx) + " " + ps.frm(cy) + " txtdistdeg");
console.log("0 0 1 setrgbcolor");
deg2 += da;
deg -= da;
console.log("gsave " + ps.frm(ps.scrx(coords[0][v]) + r*Math.cos((deg - 180)/180*Math.PI)) + " " + ps.frm(ps.scry(coords[1][v]) + r * Math.sin((deg - 180)/180*Math.PI)) + " translate 0 0 moveto " + (deg - 180 + da) + " rotate " + r + " 0 lineto stroke grestore");
console.log("newpath " + ps.frm(ps.scrx(coords[0][v])) + " " + ps.frm(ps.scry(coords[1][v])) + " " + r + " " + ps.frm(deg2) + " " +ps.frm(deg -180) + " arc stroke");
console.log(ps.frm(2*r) + " 0 0 0 1 " + ps.frm(deg2 - da) + " " + ps.frm(ps.scrx(coords[0][v]) + r*Math.cos(deg2/180*Math.PI)) + " " + ps.frm(ps.scry(coords[1][v]) + r * Math.sin(deg2/180*Math.PI)) + " parrow");
}
r = 18;
last_face = -1;
cnt = -1;
pftv = planar_face_traversal_visitor();
pftv.begin_face = function () {
last_face += 1;
cnt = 0;
};
pftv.next_vertex_edge = function (v, e) {
draw_vertex_edge_label(G, v, e, coords, last_face + "_" + String.fromCharCode(97 + cnt));
cnt += 1;
};
planar_face_traversal(G, pftv);
console.log("0 0 0 setrgbcolor");
console.log("0 0 (is_embedding=" + is_embedding(G) + ",");
...