Built with blockbuilder.org
forked from greenmna's block: The basics of Shapes in SVG
license: mit |
Built with blockbuilder.org
forked from greenmna's block: The basics of Shapes in SVG
<!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> | |
// Edit the code below to change me! | |
var svg = d3.select("body").append("svg") | |
.attr("width", 960) | |
.attr("height", 540) | |
svg.append("rect") | |
.attr("fill", "blue") | |
.attr("stroke", "black") | |
.attr("width", 50) | |
.attr("height", 100) | |
.attr("x", 200) | |
.attr("y", 400) | |
svg.append("rect") | |
.attr("fill", "red") | |
.attr("stroke", "black") | |
.attr("width", 50) | |
.attr("height", 100) | |
.attr("x", 300) | |
.attr("y", 400) | |
svg.append("rect") | |
.attr("fill", "white") | |
.attr("stroke", "black") | |
.attr("width", 50) | |
.attr("height", 100) | |
.attr("x", 250) | |
.attr("y", 400) | |
svg.append("rect") | |
.attr("fill", "white") | |
.attr("stroke", "black") | |
.attr("width", 150) | |
.attr("height", 100) | |
.attr("x", 100) | |
.attr("y", 200) | |
svg.append("circle") | |
.attr("r", 25) | |
.attr("cx", 175) | |
.attr("cy", 250) | |
.attr("fill", "red") | |
svg.append("rect") | |
.attr("fill", "cadetblue") | |
.attr("stroke", "black") | |
.attr("width", 150) | |
.attr("height", 100) | |
.attr("x", 400) | |
.attr("y", 200) | |
svg.append("rect") | |
.attr("fill", "yellow") | |
.attr("stroke", "black") | |
.attr("width", 150) | |
.attr("height", 40) | |
.attr("x", 400) | |
.attr("y", 230) | |
svg.append("polygon") | |
.attr("fill", "black") | |
.attr("width", 50) | |
.attr("height", 50) | |
.attr("points", "485,253 401,299 399,201") | |
</script> | |
</body> |