2016-07-08 24 views
0

bin sehr neu zu raphael js so und irgendwie in Eile zu finden, wie ich eine Poly-Form mit Dracula-Graph zeichnen kann. Dies wird in einem costum Renderer gehen wie:Eine unterschiedliche Knotenform auf Dracula-Graphen zeichnen?

var render = function(r, n) { 
     /* the Raphael set is obligatory, containing all you want to display */ 
     var set = r.set().push(
      /* custom objects go here */ 
      r.rect(n.point[0]-30, n.point[1]-13, 62, 86) 
       .attr({"fill": "#fa8", "stroke-width": 2, r : "9px"})) 
       .push(r.text(n.point[0], n.point[1] + 30, n.label) 
        .attr({"font-size":"20px"})); 
     /* custom tooltip attached to the set */ 
     set.items.forEach(
      function(el) { 
       el.tooltip(r.set().push(r.rect(0, 0, 30, 30) 
        .attr({"fill": "#fec", "stroke-width": 1, r : "9px"})))}); 
     return set; 
    }; 

Wenn jemand mit einem solchen würde gerne die Hilfe behandelt hat.

Antwort

0

Das ist gelöst! Gefunden auf Raphael JS durch Chris Wilson

var paper = Raphael(0, 0, 500, 500); 

function NGon(x, y, N, side, angle) { 
    paper.circle(x, y, 3).attr("fill", "black"); 

    var path = "", 
     c, temp_x, temp_y, theta; 

    for (c = 0; c <= N; c += 1) { 
     theta = (c + 0.5)/N * 2 * Math.PI; 
     temp_x = x + Math.cos(theta) * side; 
     temp_y = y + Math.sin(theta) * side; 
     path += (c === 0 ? "M" : "L") + temp_x + "," + temp_y; 
    } 
    return path; 
} 

paper.path(NGon(050, 50, 8, 40));