mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
update node version, cleanup
This commit is contained in:
parent
63f7936240
commit
8c475c0637
@ -1,6 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '6.0.0'
|
||||
- '8.0.0'
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
6031
test/lib/blanket.js
6031
test/lib/blanket.js
File diff suppressed because one or more lines are too long
@ -11,31 +11,13 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id='container'></div>
|
||||
<script src='http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/konva-v5.1.0.min.js'></script>
|
||||
<script src='http://code.jquery.com/jquery-1.11.0.min.js'></script>
|
||||
<script src='../../dist/konva-dev.js'></script>
|
||||
<script src='http://www.html5canvastutorials.com/lib/stats/stats.js'></script>
|
||||
<script defer='defer'>
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
if (!window.requestAnimationFrame) {
|
||||
window.requestAnimationFrame = function(callback) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
}
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
var width = $(window).width();
|
||||
var height = $(window).height();
|
||||
var width = window.innerWidth;
|
||||
var height = window.innerHeight;
|
||||
|
||||
var wabbitTexture;
|
||||
|
||||
@ -56,7 +38,6 @@
|
||||
var amount = 10;
|
||||
var counter;
|
||||
|
||||
function onReady() {
|
||||
var stage = new Konva.Stage({
|
||||
container: 'container',
|
||||
width: width - 10,
|
||||
@ -91,17 +72,17 @@
|
||||
container = stage;
|
||||
// stage.addChild(container);
|
||||
|
||||
$(stage.getContainer()).mousedown(function(){
|
||||
isAdding = true;
|
||||
stage.on('mousedown', function() {
|
||||
isAdding = true;
|
||||
});
|
||||
|
||||
$(stage.getContainer()).mouseup(function(){
|
||||
isAdding = false;
|
||||
|
||||
stage.on('mouseup', function() {
|
||||
isAdding = false;
|
||||
});
|
||||
|
||||
|
||||
document.addEventListener('touchstart', onTouchStart, true);
|
||||
document.addEventListener('touchend', onTouchEnd, true);
|
||||
}
|
||||
|
||||
function _handleTextureLoaded (event) {
|
||||
for (var i = 0; i < startBunnyCount; i++)
|
||||
@ -196,11 +177,9 @@
|
||||
|
||||
}
|
||||
layer.drawScene();
|
||||
requestAnimFrame(update);
|
||||
requestAnimationFrame(update);
|
||||
stats.end();
|
||||
}
|
||||
|
||||
$(document).ready(onReady);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
@ -1,209 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='container'></div>
|
||||
<script src='../konva.js'></script>
|
||||
<script src='webgl-2d.js'></script>
|
||||
<script src='konva.webgl.js'></script>
|
||||
<script src='http://code.jquery.com/jquery-1.11.0.min.js'></script>
|
||||
<script src='../lib/stats.js'></script>
|
||||
<script defer='defer'>
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
if (!window.requestAnimationFrame) {
|
||||
window.requestAnimationFrame = function(callback) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
}
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
var width = $(window).width();
|
||||
var height = $(window).height();
|
||||
|
||||
var wabbitTexture;
|
||||
|
||||
var bunnys = [];
|
||||
var gravity = 0.75;
|
||||
|
||||
var maxX = width - 10;
|
||||
var minX = 0;
|
||||
var maxY = height - 10;
|
||||
var minY = 0;
|
||||
|
||||
var startBunnyCount = 10;
|
||||
var isAdding = false;
|
||||
var count = 0;
|
||||
var container;
|
||||
var layer;
|
||||
var stats;
|
||||
var amount = 10;
|
||||
var counter;
|
||||
|
||||
function onReady() {
|
||||
var stage = new Konva.Stage({
|
||||
container: 'container',
|
||||
width: width - 10,
|
||||
height: height - 10,
|
||||
});
|
||||
layer = new Konva.FastLayer();
|
||||
stage.add(layer);
|
||||
stats = new Stats();
|
||||
|
||||
wabbitTexture = new Image();
|
||||
wabbitTexture.onload = function() {
|
||||
_handleTextureLoaded();
|
||||
};
|
||||
wabbitTexture.src = '../assets/bunny.png';
|
||||
|
||||
document.body.appendChild( stats.domElement );
|
||||
stats.domElement.style.position = 'absolute';
|
||||
stats.domElement.style.top = '0px';
|
||||
|
||||
window.requestAnimationFrame(update);
|
||||
|
||||
counter = document.createElement('div');
|
||||
counter.className = 'counter';
|
||||
counter.style.position = 'absolute';
|
||||
counter.style.top = '50px';
|
||||
|
||||
document.body.appendChild(counter);
|
||||
|
||||
count = startBunnyCount;
|
||||
counter.innerHTML = startBunnyCount + ' BUNNIES';
|
||||
|
||||
container = stage;
|
||||
// stage.addChild(container);
|
||||
|
||||
$(stage.getContainer()).mousedown(function(){
|
||||
isAdding = true;
|
||||
});
|
||||
|
||||
$(stage.getContainer()).mouseup(function(){
|
||||
isAdding = false;
|
||||
});
|
||||
|
||||
document.addEventListener('touchstart', onTouchStart, true);
|
||||
document.addEventListener('touchend', onTouchEnd, true);
|
||||
}
|
||||
|
||||
function _handleTextureLoaded (event) {
|
||||
for (var i = 0; i < startBunnyCount; i++)
|
||||
{
|
||||
var bunny = new Konva.Image({
|
||||
image: wabbitTexture,
|
||||
transformsEnabled: 'position',
|
||||
hitGraphEnabled: false,
|
||||
x : 10,
|
||||
y : 10
|
||||
});
|
||||
|
||||
|
||||
|
||||
bunny.speedX = Math.random() * 10;
|
||||
bunny.speedY = (Math.random() * 10) - 5;
|
||||
|
||||
bunnys.push(bunny);
|
||||
// bunny.cache();
|
||||
layer.add(bunny);
|
||||
bunny.cache();
|
||||
|
||||
layer.draw();
|
||||
}
|
||||
}
|
||||
|
||||
function onTouchStart(event){
|
||||
isAdding = true;
|
||||
}
|
||||
|
||||
function onTouchEnd(event){
|
||||
isAdding = false;
|
||||
}
|
||||
|
||||
function update(){
|
||||
stats.begin();
|
||||
if(isAdding) {
|
||||
// add 10 at a time :)
|
||||
|
||||
for (var i = 0; i < amount; i++)
|
||||
{
|
||||
var bunny = new Konva.Image({
|
||||
image: wabbitTexture,
|
||||
transformsEnabled: 'position',
|
||||
x : 0,
|
||||
y : 0
|
||||
});
|
||||
bunny.speedX = Math.random() * 10;
|
||||
bunny.speedY = (Math.random() * 10) - 5;
|
||||
// bunny.cache();
|
||||
bunnys.push(bunny);
|
||||
layer.add(bunny);
|
||||
bunny.cache();
|
||||
|
||||
|
||||
|
||||
count++;
|
||||
}
|
||||
counter.innerHTML = count + ' BUNNIES';
|
||||
}
|
||||
|
||||
for (var i = 0; i < bunnys.length; i++) {
|
||||
var bunny = bunnys[i];
|
||||
bunny.setX(bunny.getX() + bunny.speedX);
|
||||
bunny.setY(bunny.getY() + bunny.speedY);
|
||||
bunny.speedY += gravity;
|
||||
if (bunny.getX() > maxX - wabbitTexture.width)
|
||||
{
|
||||
bunny.speedX *= -1;
|
||||
bunny.setX(maxX - wabbitTexture.width);
|
||||
}
|
||||
else if (bunny.getX() < minX)
|
||||
{
|
||||
bunny.speedX *= -1;
|
||||
bunny.setX(minX);
|
||||
}
|
||||
|
||||
if (bunny.getY() > maxY - wabbitTexture.height)
|
||||
{
|
||||
bunny.speedY *= -0.85;
|
||||
bunny.setY(maxY - wabbitTexture.height);
|
||||
if (Math.random() > 0.5)
|
||||
{
|
||||
bunny.speedY -= Math.random() * 6;
|
||||
}
|
||||
}
|
||||
else if (bunny.getY() < minY)
|
||||
{
|
||||
bunny.speedY = 0;
|
||||
bunny.setY(minY);
|
||||
}
|
||||
|
||||
}
|
||||
layer.drawScene();
|
||||
requestAnimFrame(update);
|
||||
stats.end();
|
||||
}
|
||||
|
||||
$(document).ready(onReady);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,70 +1,74 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
canvas {
|
||||
border: 1px solid #9C9898;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
|
||||
<script src="../../dist/konva-dev.js"></script>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
<script>
|
||||
var stage = new Konva.Stage({
|
||||
container: 'container',
|
||||
width: 500,
|
||||
height: 250
|
||||
});
|
||||
var layer = new Konva.Layer();
|
||||
canvas {
|
||||
border: 1px solid #9C9898;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
for(var j =0; j < 20; j++) {
|
||||
layer.add(new Konva.Circle({
|
||||
x : stage.width() * Math.random(),
|
||||
y : stage.height() * Math.random(),
|
||||
radius : 50,
|
||||
stroke : 'black',
|
||||
fill : Konva.Util.getRandomColor(),
|
||||
strokeWidth : 5,
|
||||
draggable : true
|
||||
}));
|
||||
}
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
|
||||
stage.add(layer);
|
||||
var i, count = 500, start;
|
||||
<script src="../../dist/konva-dev.js"></script>
|
||||
|
||||
var start = Date.now();
|
||||
for(i = 0; i< count; i++) {
|
||||
layer.draw();
|
||||
}
|
||||
var defTime = Date.now() - start;
|
||||
<script>
|
||||
var stage = new Konva.Stage({
|
||||
container: 'container',
|
||||
width: 500,
|
||||
height: 250
|
||||
});
|
||||
var layer = new Konva.Layer();
|
||||
|
||||
layer.getHitCanvas().setPixelRatio(1);
|
||||
// layer.getCanvas().setPixelRatio(1);
|
||||
for (var j = 0; j < 20; j++) {
|
||||
layer.add(new Konva.Circle({
|
||||
x: stage.width() * Math.random(),
|
||||
y: stage.height() * Math.random(),
|
||||
radius: 50,
|
||||
stroke: 'black',
|
||||
fill: Konva.Util.getRandomColor(),
|
||||
strokeWidth: 5,
|
||||
draggable: true
|
||||
}));
|
||||
}
|
||||
|
||||
stage.add(layer);
|
||||
var i, count = 500, start;
|
||||
|
||||
var start = Date.now();
|
||||
for (i = 0; i < count; i++) {
|
||||
layer.draw();
|
||||
}
|
||||
var defTime = Date.now() - start;
|
||||
|
||||
start = Date.now();
|
||||
for(i = 0; i< count; i++) {
|
||||
layer.draw();
|
||||
}
|
||||
var time1 = Date.now() - start;
|
||||
layer.getHitCanvas().setPixelRatio(1);
|
||||
// layer.getCanvas().setPixelRatio(1);
|
||||
layer.draw();
|
||||
|
||||
layer.getHitCanvas().setPixelRatio(0.2);
|
||||
// layer.getCanvas().setPixelRatio(0.5);
|
||||
start = Date.now();
|
||||
for (i = 0; i < count; i++) {
|
||||
layer.draw();
|
||||
}
|
||||
var time1 = Date.now() - start;
|
||||
|
||||
layer.getHitCanvas().setPixelRatio(0.2);
|
||||
// layer.getCanvas().setPixelRatio(0.5);
|
||||
layer.draw();
|
||||
|
||||
start = Date.now();
|
||||
for (i = 0; i < count; i++) {
|
||||
layer.draw();
|
||||
}
|
||||
var time05 = Date.now() - start;
|
||||
console.log('def ' + defTime + ', 1 ration ' + time1 + ', 05 ration ' + time05)
|
||||
</script>
|
||||
</body>
|
||||
|
||||
start = Date.now();
|
||||
for(i = 0; i< count; i++) {
|
||||
layer.draw();
|
||||
}
|
||||
var time05 = Date.now() - start;
|
||||
alert('def ' + defTime + ', 1 ration ' + time1 + ', 05 ration ' + time05)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,23 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
canvas {
|
||||
border: 1px solid #9C9898;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
|
||||
<script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/konva-v5.0.1.js"></script>
|
||||
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
|
||||
<script src="../lib/stats.js"></script>
|
||||
<script src="common/random-squares.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,57 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
canvas {
|
||||
border: 1px solid #9C9898;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
|
||||
<script src="../../dist/konva-dev.js"></script>
|
||||
<script src="../lib/stats.js"></script>
|
||||
<script src="../setStats.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
var stage = new Konva.Stage({
|
||||
container: 'container',
|
||||
width: 500,
|
||||
height: 500
|
||||
});
|
||||
var layer = new Konva.Layer();
|
||||
|
||||
var star = new Konva.Star({
|
||||
x: 250,
|
||||
y: 250,
|
||||
innerRadius: 100,
|
||||
outerRadius: 200,
|
||||
numPoints: 500,
|
||||
fill: 'yellow',
|
||||
stroke: 'black',
|
||||
strokeWidth: 4,
|
||||
name: 'myCircle',
|
||||
draggable: true
|
||||
});
|
||||
|
||||
layer.add(star);
|
||||
stage.add(layer);
|
||||
|
||||
var anim = new Konva.Animation(function() {
|
||||
stats.begin();
|
||||
star.rotate(0.1);
|
||||
}, layer);
|
||||
|
||||
anim.start();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
@ -37,8 +37,6 @@
|
||||
<script src="../node_modules/chai/chai.js"></script>
|
||||
<script src="lib/stats.js"></script>
|
||||
|
||||
<!--<script src="lib/blanket.js"></script>-->
|
||||
|
||||
<!--CORE-->
|
||||
<script src="../src/Global.js" data-cover></script>
|
||||
<script src="../src/Util.js" data-cover></script>
|
||||
|
@ -700,7 +700,7 @@ suite('Caching', function() {
|
||||
cloneAndCompareLayer(layer, 150);
|
||||
});
|
||||
|
||||
test('test group with circle + buffer canvas usage', function() {
|
||||
test.only('test group with circle + buffer canvas usage', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
stage.add(layer);
|
||||
|
Loading…
Reference in New Issue
Block a user