D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
35degrees
Full window
Github gist
clip path example
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } </style> </head> <body> <script> var holder = d3.select("body") // select the 'body' element .append("svg") // append an SVG element to the body .attr("width", 449) // make the SVG element 449 pixels wide .attr("height", 249); // make the SVG element 249 pixels high // draw a circle holder.append("clipPath") // define a clip path .attr("id", "ellipse-clip") // give the clipPath an ID .append("ellipse") // shape it as an ellipse .attr("cx", 175) // position the x-centre .attr("cy", 100) // position the y-centre .attr("rx", 100) // set the x radius .attr("ry", 50); holder.append("rect") .attr("x",175) .attr("y",100) .attr("clip-path","url(#ellipse-clip)") .attr("fill","SteelBlue") .attr("height",100) .attr("width",200) </script> </body>
https://d3js.org/d3.v4.min.js