summaryrefslogtreecommitdiff
path: root/paint.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-09-16 12:00:59 +0200
committerjmoenig <jens@moenig.org>2013-09-16 12:00:59 +0200
commitaa0b54986303ff563d4465b94e163adbf26e9d6f (patch)
tree950e9bb4afabab387c7759adfd4e96564f67f07b /paint.js
parent72259dcae04ce307d639e811b01690d7cc133a93 (diff)
downloadsnap-yow-aa0b54986303ff563d4465b94e163adbf26e9d6f.tar.gz
snap-yow-aa0b54986303ff563d4465b94e163adbf26e9d6f.zip
Paint: Flood fill freeze fix
thanks for the contribution, Kartik!
Diffstat (limited to 'paint.js')
-rw-r--r--paint.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/paint.js b/paint.js
index 9841557..44585b2 100644
--- a/paint.js
+++ b/paint.js
@@ -49,6 +49,7 @@
May 14 - bugfixes, Snap integration (Jens)
May 16 - flat design adjustments (Jens)
July 12 - pipette tool, code formatting adjustments (Jens)
+ September 16 - flood fill freeze fix (Kartik)
*/
@@ -62,7 +63,7 @@
// Global stuff ////////////////////////////////////////////////////////
-modules.paint = '2013-July-13';
+modules.paint = '2013-September-16';
// Declarations
@@ -671,7 +672,23 @@ PaintCanvasMorph.prototype.floodfill = function (sourcepoint) {
p[1] === sourcecolor[1] &&
p[2] === sourcecolor[2] &&
p[3] === sourcecolor[3];
- };
+ };
+
+ // if already filled, abort
+ if (sourcecolor[3] === 0 &&
+ this.settings.primarycolor === "transparent") {
+ return;
+ }
+ if (sourcecolor[0] === this.settings.primarycolor.r &&
+ sourcecolor[1] === this.settings.primarycolor.g &&
+ sourcecolor[2] === this.settings.primarycolor.b &&
+ sourcecolor[3] === this.settings.primarycolor.a) {
+ return;
+ }
+ if (sourcecolor[3] === 0 && this.settings.primarycolor.a === 0) {
+ return;
+ }
+
while (stack.length > 0) {
currentpoint = stack.pop();
if (checkpoint(read(currentpoint))) {