Skip to content

Instantly share code, notes, and snippets.

@pronebird
Created April 14, 2015 09:57
Show Gist options
  • Save pronebird/7cbb4ca7d7d909efc560 to your computer and use it in GitHub Desktop.
Save pronebird/7cbb4ca7d7d909efc560 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/xovewu
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="https://raw.githubusercontent.com/konvajs/konva/master/konva.min.js"></script>
</head>
<body>
<div id="konva"></div>
<script id="jsbin-javascript">
// set pixel ratio
Konva.pixelRatio = window.devicePixelRatio;
var stage = new Konva.Stage({
container: 'konva',
width: 300,
height: 300
});
var layer = new Konva.Layer();
var button = new Konva.Group({
x: 50, y: 50,
width: 100,
height: 50,
draggable: true
});
var face = new Konva.Rect({
fill: 'red',
x: 0, y: 0,
width: 100,
height: 50
});
var text = new Konva.Text({
text: "Wrong button",
x: 15,
y: 20
});
button.add(face);
button.add(text);
// UNCOMMENT THIS TO SEE WHAT I MEAN
//button.cache();
layer.add(button);
stage.add(layer);
stage.draw();
</script>
<script id="jsbin-source-javascript" type="text/javascript">// set pixel ratio
Konva.pixelRatio = window.devicePixelRatio;
var stage = new Konva.Stage({
container: 'konva',
width: 300,
height: 300
});
var layer = new Konva.Layer();
var button = new Konva.Group({
x: 50, y: 50,
width: 100,
height: 50,
draggable: true
});
var face = new Konva.Rect({
fill: 'red',
x: 0, y: 0,
width: 100,
height: 50
});
var text = new Konva.Text({
text: "Wrong button",
x: 15,
y: 20
});
button.add(face);
button.add(text);
// UNCOMMENT THIS TO SEE WHAT I MEAN
//button.cache();
layer.add(button);
stage.add(layer);
stage.draw();
</script></body>
</html>
// set pixel ratio
Konva.pixelRatio = window.devicePixelRatio;
var stage = new Konva.Stage({
container: 'konva',
width: 300,
height: 300
});
var layer = new Konva.Layer();
var button = new Konva.Group({
x: 50, y: 50,
width: 100,
height: 50,
draggable: true
});
var face = new Konva.Rect({
fill: 'red',
x: 0, y: 0,
width: 100,
height: 50
});
var text = new Konva.Text({
text: "Wrong button",
x: 15,
y: 20
});
button.add(face);
button.add(text);
// UNCOMMENT THIS TO SEE WHAT I MEAN
//button.cache();
layer.add(button);
stage.add(layer);
stage.draw();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment