Last active
October 5, 2018 02:44
-
-
Save quickgrid/84ed46eaa40a03fca78488a6a90e7ede to your computer and use it in GitHub Desktop.
Just a sample konva app to demonstrate kshapejs library.
This file contains hidden or 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"> | |
<title>Triangle Library Demo</title> | |
<style> | |
body { | |
margin: 0; | |
padding: 0; | |
overflow: hidden; | |
background-color: #F0F0F0; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="container"></div> | |
<script src="https://cdn.rawgit.com/konvajs/konva/0.11.1/konva.min.js"></script> | |
<script type="text/javascript" src="kshapejs.js"></script> | |
<script> | |
var width = window.innerWidth; | |
var height = window.innerHeight; | |
var stage = new Konva.Stage({ | |
container: 'container', | |
width: width, | |
height: height | |
}); | |
var shapesLayer = new Konva.Layer(); | |
var group = new Konva.Group({ | |
draggable: true, | |
x: 50, y: 50 | |
}); | |
var poly = []; | |
for( var i = 0; i < 10; i++ ){ | |
poly[i] = kshapejs.drawTriangle(i + 300 * Math.random(), i + 300 * Math.random(), i + 200 * Math.random(), 3); | |
poly[i].move({ | |
x: 50, y: 0 | |
}); | |
group.add(poly[i]); | |
} | |
group.on('mouseover', function() { | |
document.body.style.cursor = 'pointer'; | |
}); | |
group.on('mouseout', function() { | |
document.body.style.cursor = 'default'; | |
}); | |
shapesLayer.add(group); | |
stage.add(shapesLayer); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment