Skip to content

Instantly share code, notes, and snippets.

@bekatom
Created July 2, 2015 09:40
Show Gist options
  • Select an option

  • Save bekatom/e7078adf5f85e14a8c94 to your computer and use it in GitHub Desktop.

Select an option

Save bekatom/e7078adf5f85e14a8c94 to your computer and use it in GitHub Desktop.
<script src="https://cdnjs.cloudflare.com/ajax/libs/trianglify/0.2.1/trianglify.min.js"></script>
<style>
width:500px;
height:500px;
</style>
<div id="main" class="main">
<script>
function addTriangleTo(target) {
var dimensions = target.getClientRects()[0];
var pattern = Trianglify({
x_colors: 'Greens',
width: dimensions.width,
height: dimensions.height,
});
target.style['background-image'] = 'url(' + pattern.png() + ')';
}
addTriangleTo(document.getElementById('main'));
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment