I want to create this in JavaScript: http://i.imgur.com/PYE3qFB.jpg
It's a visual representation of traffic flow through six nodes in a network. The thicker the line, the higher the traffic. The smaller node doesn't send anything at all.
I've managed to make the six nodes (although I have no idea if the code is horrible):
I'm struggling with the edges, though.. and, well, how to structure my project in general.. Is this simple enough to write in one class?Code:function draw() { var canvas = document.getElementById("canvas1"); var ctx = canvas.getContext("2d"); //circles in pentagon shape var numberOfSides = 5, size = 300, Xcenter = 500, Ycenter = 350; ctx.beginPath(); ctx.arc(Xcenter, Ycenter,30,0,Math.PI*2,true); ctx.stroke(); for (var i = 1; i <= numberOfSides;i += 1){ ctx.beginPath(); ctx.arc(Xcenter + size * Math.cos(i * 2 * Math.PI / numberOfSides),Ycenter + size * Math.sin(i * 2 * Math.PI / numberOfSides),50,0,Math.PI*2,true); ctx.stroke(); } }
I'm writing in notepad at the moment, but I have access to VS2012. Should I switch?
Should I use any frameworks? A friend of mine mentioned EaselJS.. Will that help?
Any tips and pointers are much appreciated![]()


Reply With Quote
Bookmarks