Skip to content

Instantly share code, notes, and snippets.

@a3igner
Last active April 18, 2019 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a3igner/19cdfa5883d050f1740bb6be6536c14a to your computer and use it in GitHub Desktop.
Save a3igner/19cdfa5883d050f1740bb6be6536c14a to your computer and use it in GitHub Desktop.
SVG basics
license: mit
<!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; }
svg {
background : pink;
}
line {
stroke: red;
stroke-width: 5;
}
rect, circle, ellipse, polygon {
stroke: green;
stroke-width: 5;
stroke-opacity: .7;
fill: yellow;
fill-opacity:0.5;
}
text {
fill: green;
}
</style>
</head>
<body>
<svg width ="600" height = "300">
<line x1="0" y1="0" x2="100" y2="100" />
<rect x="120" y="120" width ="50" height="50"></rect>
<circle cx="200" cy="200" r="50"></circle>
<text x="300" y="220">SVG Basics</text>
<ellipse cx="300", cy="120" rx="90" ry="60"></ellipse>
<polygon points="50,100 150,100 100,175"></polygon>
<polygon points="230,300 442,300 531,175 479,120 70,60"></polygon>
</svg>
// <script>
// // Feel free to change or delete any of the code you see in this editor!
// var svg = d3.select("body").append("svg")
// .attr("width", 960)
// .attr("height", 500)
// svg.append("text")
// .text("Edit the code below to change me!")
// .attr("y", 200)
// .attr("x", 120)
// .attr("font-size", 36)
// .attr("font-family", "monospace")
//
// </script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment