Blog Archives

SVG Dice using D3

This is a javascript D3 function I wrote to create SVG dice images. function append_die(element,number,cx,cy,width,colour,dotcolour) { element.append(“rect”).attr(“x”, cx-width/2).attr(“y”, cy-width/2).attr(“width”, width).attr(“height”, width).attr(“rx”, width/6).attr(“ry”, width/6).attr(“fill”, colour); if (number == 1) { element.append(“circle”).attr(“cx”, cx).attr(“cy”, cy).attr(“r”, width/8).attr(“fill”, dotcolour); } if (number == 2) {

Tagged with: ,
Posted in D3, SVG