Built with blockbuilder.org
Last active
December 13, 2016 12:58
-
-
Save GitNoise/604faf6435cd87e91f034e86423a2524 to your computer and use it in GitHub Desktop.
hexagon clip + blend
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
license: mit |
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> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://d3js.org/d3-scale.v1.min.js"></script> | |
<script src="//d3js.org/queue.v1.min.js"></script> | |
<style> | |
svg { | |
width:100%; | |
height:100%; | |
position:fixed; | |
top:0; | |
left:0; | |
bottom:0; | |
right:0; | |
} | |
body { | |
margin:0; | |
position:fixed; | |
top:0; | |
right:0; | |
bottom:0; | |
left:0; | |
} | |
.clippy { | |
clip-path: url(#clippys); | |
} | |
circle { | |
stroke: #fff; | |
stroke-width: 2; | |
} | |
</style> | |
</head> | |
<body> | |
<svg preserveAspectRatio="none"> | |
<defs> | |
<clipPath id="clippys" clipPathUnits="objectBoundingBox"> | |
<polygon points=".5 0, 1 .25, 1 .75, .5 1, 0 .75, 0 .25" /> | |
</clipPath> | |
</defs> | |
</svg> | |
<script> | |
var lightColor = d3.scaleOrdinal(d3.schemeCategory20c); | |
var breakLine = 5; | |
var svg = d3.select("svg"); | |
var row = 0; | |
for(j=1; j<40 | |
; j++) { | |
var g = svg.append("g") | |
g.append("image") | |
.attr("xlink:href", "https://placekitten.com/50/50?image=" + j%18) | |
.attr("x", 10) | |
.attr("y", 10) | |
.attr("width", 50) | |
.attr("height", 50) | |
.classed("clippy", true) | |
g.attr("transform","translate(" | |
+ (50*(j%breakLine) + (row%2 == 0 ? 25 : 0 )) + ", " | |
+ (38 * row) | |
+ ")") | |
row = j % breakLine == 0 ? row + 1 : row; | |
g.style("mix-blend-mode", "screen"); | |
} | |
d3.select("g") | |
svg.append("circle") | |
.attr("cx",300) | |
.attr("cy",110) | |
.attr("r", 100) | |
.style("fill", "#EF597B") | |
.style("mix-blend-mode", "screen") | |
svg.append("circle") | |
.attr("cx",250) | |
.attr("cy",200) | |
.attr("r", 100) | |
.style("fill", "#579eee") | |
.style("mix-blend-mode", "screen") | |
svg.append("circle") | |
.attr("cx",350) | |
.attr("cy",200) | |
.attr("r", 100) | |
.style("fill", "#c7f9c8") | |
.style("mix-blend-mode", "screen") | |
function rollover() { | |
svg.select("circle") | |
.transition() | |
.attr("transform", "translate(0)"); | |
} | |
rollover(); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment