Last active
October 4, 2020 20:32
-
-
Save aaizemberg/cc59aafc7d0cb022dfeff2a14f9a5931 to your computer and use it in GitHub Desktop.
mosaico
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>mosaico - estrella de 8 puntas</title> | |
<style> | |
svg rect { | |
stroke: none; | |
fill: white; | |
} | |
svg rect:hover { | |
stroke: white; | |
fill: steelblue; | |
} | |
</style> | |
<script src="https://d3js.org/d3.v5.min.js"></script> | |
</head> | |
<body> | |
<script> | |
var s = 60, n = 10, w = n*s*1.4, h = n*s*1.4; | |
var svg = d3.select("body").append("svg").attr("width",w).attr("height",h).style("background","teal"); | |
function prototile(svg, x, y, s) { | |
svg.append("rect") | |
.attr("transform","translate(" + (s/2+((s*1.5)*x)) + " " + (s/2+((s*1.5)*y)) + ")" ) | |
.attr("width", s) | |
.attr("height", s); | |
svg.append("rect") | |
.attr("transform","translate(" + (s + (s*1.5)*x) + " "+(s/4+(s*1.5) *y)+") rotate(45)" ) | |
.attr("width", s) | |
.attr("height", s); | |
} | |
for (y = 0; y < n-1; y++) { | |
for (x = 0; x < n-1; x++) { | |
prototile(svg, x, y, s); | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment