Skip to content

Commit

Permalink
Alerting user when background probably wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Archibald committed Jun 21, 2011
1 parent 99890d7 commit 35faa61
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
4 changes: 4 additions & 0 deletions www/assets/1/script/SpriteCanvas.js
Expand Up @@ -50,6 +50,10 @@ spriteCow.SpriteCanvas = (function() {
this._bgData = pixelArr;
};

SpriteCanvasProto.getBg = function() {
return this._bgData;
};

SpriteCanvasProto.trimBg = function(rect) {
var edgeBgResult;

Expand Down
35 changes: 28 additions & 7 deletions www/assets/1/script/Toolbar.js
Expand Up @@ -31,15 +31,36 @@ spriteCow.Toolbar = (function() {

var SpriteCowToolbarProto = SpriteCowToolbar.prototype = new spriteCow.MicroEvent;

SpriteCowToolbarProto.feedback = function(msg) {
SpriteCowToolbarProto.feedback = function(msg, severe) {
var $feedback = this._$feedback,
initialColor = '#555';

// opacity 0.999 to avoid antialiasing differences when 1
this._$feedback.stop(true, true).text(msg).css('opacity', 0.999).animate({
// should be using delay() here, but http://bugs.jquery.com/ticket/6150 makes it not work
// need to specify a dummy property to animate, cuh!
_:0
}, 3000).animate({
$feedback.transitionStop(true).text(msg).css({
opacity: 0.999,
color: initialColor
});

if (severe) {
$feedback.transition({
color: 'red'
}, {
duration: 3000
});
}
else {
$feedback.animate({
// should be using delay() here, but http://bugs.jquery.com/ticket/6150 makes it not work
// need to specify a dummy property to animate, cuh!
_:0
}, 3000);
}

$feedback.transition({
opacity: 0
}, 2000);
}, {
duration: 2000
});

return this;
};
Expand Down
9 changes: 9 additions & 0 deletions www/assets/1/script/base.js
Expand Up @@ -38,6 +38,15 @@
spriteCanvasView.bind('rectChange', function(rect) {
cssOutput.rect = rect;
cssOutput.update();
if (rect.width === spriteCanvas.canvas.width && rect.height === spriteCanvas.canvas.height) {
// if the rect is the same size as the whole canvas,
// it's probably because the background is set wrong
// let's be kind...
toolbar.feedback(
'Background set to: ' + colourBytesToCss( spriteCanvas.getBg() ),
true
);
}
});

spriteCanvasView.bind('bgColorHover', function(color) {
Expand Down
4 changes: 2 additions & 2 deletions www/assets/1/script/mainmin.js

Large diffs are not rendered by default.

0 comments on commit 35faa61

Please sign in to comment.