Skip to content

Commit

Permalink
shorter timeout and combine blip
Browse files Browse the repository at this point in the history
  • Loading branch information
Forrest Oliphant committed Jun 28, 2012
1 parent c415ca5 commit 482ee29
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 32 deletions.
4 changes: 2 additions & 2 deletions circle.html
Expand Up @@ -95,7 +95,7 @@
context.lineWidth = _strokeWidth;
combine();
}
var combineWait = 1000/30;
var combineWait = 10;
var combineTimeout;
function combine(){
// Minimum time to do combine again, so that changing a few variables at the same time doesn't do multiple draws
Expand Down Expand Up @@ -156,7 +156,7 @@
}

// HACK send one 2s after load
setTimeout(combineDo, 2000);
setTimeout(combine, 2000);

Meemoo
.setInfo({
Expand Down
18 changes: 5 additions & 13 deletions combine.html
Expand Up @@ -54,8 +54,10 @@
addLayer(image, 7);
}
function addLayer(image, layernumber) {
if (canvas.width < image.width || canvas.height < image.height) {
if (canvas.width < image.width) {
canvas.width = image.width;
}
if (canvas.height < image.height) {
canvas.height = image.height;
}
if (!layers[layernumber]) {
Expand All @@ -69,27 +71,17 @@
thisCanvas.getContext("2d").putImageData(image, 0, 0);
combine();
}
var combineLast = new Date();
var combineWait = 1000/30;
var combineWait = 10;
var combineTimeout;
function combine(){
// Minimum time to do combine again, so that changing a few variables at the same time doesn't do multiple draws
if (combineTimeout) {
clearTimeout(combineTimeout);
// var d = new Date();
// if (d-combineLast > 100){
// // If tons of concurrent changes, still render occasionally
// combineDo();
// }
}
combineTimeout = setTimeout(combineDo, combineWait);
}
function combineDo(){
combineLast = new Date();
// Clear
if (_clearEvery) {
context.clearRect(0, 0, canvas.width, canvas.height);
}
context.clearRect(0, 0, canvas.width, canvas.height);
for (var i = 0; i < layers.length; i++) {
if (layers[i]) {
context.drawImage(layers[i], 0, 0);
Expand Down
4 changes: 2 additions & 2 deletions rectangle.html
Expand Up @@ -74,7 +74,7 @@
context.lineWidth = _strokeWidth;
combine();
}
var combineWait = 1000/30;
var combineWait = 10;
var combineTimeout;
function combine(){
// Minimum time to do combine again, so that changing a few variables at the same time doesn't do multiple draws
Expand Down Expand Up @@ -131,7 +131,7 @@
}

// HACK send one 2s after load
setTimeout(combineDo, 2000);
setTimeout(combine, 2000);


Meemoo
Expand Down
9 changes: 1 addition & 8 deletions text.html
Expand Up @@ -87,23 +87,16 @@
context.lineWidth = _strokewidth;
combine();
}
// var combineLast = new Date();
var combineWait = 1000/30;
var combineWait = 10;
var combineTimeout;
function combine(){
// Minimum time to do combine again, so that changing a few variables at the same time doesn't do multiple draws
if (combineTimeout) {
clearTimeout(combineTimeout);
// var d = new Date();
// if (d-combineLast > 100){
// // If tons of concurrent changes, still render occasionally
// combineDo();
// }
}
combineTimeout = setTimeout(combineDo, combineWait);
}
function combineDo(){
// combineLast = new Date();
// Clear
context.clearRect(0, 0, canvas.width, canvas.height);
if (_background) {
Expand Down
8 changes: 1 addition & 7 deletions transform.html
Expand Up @@ -70,18 +70,12 @@
_rotate = parseFloat(percent) * Math.PI * 2;
combine();
}
var combineLast = new Date();
var combineWait = 1000/30;
var combineWait = 10;
var combineTimeout;
function combine(){
// Minimum time to do combine again, so that changing a few variables at the same time doesn't do multiple draws
if (combineTimeout) {
clearTimeout(combineTimeout);
// var d = new Date();
// if (d-combineLast > 100){
// // If tons of concurrent changes, still render occasionally
// combineDo();
// }
}
combineTimeout = setTimeout(combineDo, combineWait);
}
Expand Down

0 comments on commit 482ee29

Please sign in to comment.