Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daome
committed
Feb 20, 2012
1 parent
d08ceb5
commit 93ceb6c
Showing
8 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
div{ | ||
-moz-user-select: -moz-none; | ||
-khtml-user-select: none; | ||
-webkit-user-select: none; | ||
user-select: none; | ||
} | ||
|
||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
log = -> | ||
console.log arguments | ||
pixels = [] | ||
MAXSTACK = 0 | ||
isInCanvas = (ctx,pixel)-> | ||
result = ((0 <= pixel.x <= ctx.canvas.width) and (0 <= pixel.y <= ctx.canvas.height)) | ||
return result | ||
|
||
bucketFill = (ctx,pixel, colcible, colrep)-> | ||
#console.log("bucketFill",ctx,pixel.x,pixel.y,colcible,colrep) | ||
MAXSTACK+=1 | ||
#if MAXSTACK < 50000 then log MAXSTACK | ||
if !isInCanvas(ctx,pixel) then return null | ||
#if pixels.indexOf(pixel)!=-1 then return null | ||
if getColorAtPixel(ctx,pixel) == colcible | ||
ctx.fillStyle = colrep | ||
ctx.fillRect(pixel.x,pixel.y,1,1) | ||
pixels.push(pixel) | ||
left = {x:pixel.x,y:pixel.y-1} | ||
right = {x:pixel.x,y:pixel.y+1} | ||
up = {x:pixel.x+1,y:pixel.y} | ||
down = {x:pixel.x-1,y:pixel.y} | ||
bucketFill(ctx,left,colcible,colrep) unless (!isInCanvas(ctx,left) or getColorAtPixel(ctx,left)!=colcible) | ||
bucketFill(ctx,right,colcible,colrep) unless (!isInCanvas(ctx,right) or getColorAtPixel(ctx,right)!=colcible) | ||
bucketFill(ctx,up,colcible,colrep) unless (!isInCanvas(ctx,up) or getColorAtPixel(ctx,up)!=colcible) | ||
bucketFill(ctx,down,colcible,colrep) unless( !isInCanvas(clx,down) or getColorAtPixel(ctx,up)!=colCible) | ||
return | ||
|
||
getColorAtPixel=(ctx,pixel)-> | ||
imageData = ctx.getImageData(pixel.x,pixel.y,1,1) | ||
return rgbArrayToCssColorString(imageData.data) | ||
|
||
rgbArrayToCssColorString=(array)-> | ||
#log(["rgbArrayToCssColorString",array]) | ||
result = "#" | ||
result+=array[i] for i in [0..2] | ||
return result | ||
|
||
main=-> | ||
|
||
log("début du script") | ||
canvas = document.getElementById("canvas") | ||
ctx = canvas.getContext("2d") | ||
ctx.fillStyle = "#0FF" | ||
ctx.fillRect(10,10,40,40) | ||
penPosition = {x:1,y:1} | ||
fillColor = "#FF0000" | ||
colCible = getColorAtPixel(ctx,penPosition) | ||
try | ||
bucketFill(ctx,penPosition,colCible,fillColor) | ||
catch e | ||
log e,MAXSTACK | ||
log(colCible) | ||
log(MAXSTACK) | ||
window.onload=-> | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
var MAXSTACK, bucketFill, getColorAtPixel, isInCanvas, log, main, pixels, rgbArrayToCssColorString; | ||
|
||
log = function() { | ||
return console.log(arguments); | ||
}; | ||
|
||
pixels = []; | ||
|
||
MAXSTACK = 0; | ||
|
||
isInCanvas = function(ctx, pixel) { | ||
var result, _ref, _ref2; | ||
result = ((0 <= (_ref = pixel.x) && _ref <= ctx.canvas.width)) && ((0 <= (_ref2 = pixel.y) && _ref2 <= ctx.canvas.height)); | ||
return result; | ||
}; | ||
|
||
bucketFill = function(ctx, pixel, colcible, colrep) { | ||
var down, left, right, up; | ||
MAXSTACK += 1; | ||
if (!isInCanvas(ctx, pixel)) return null; | ||
if (getColorAtPixel(ctx, pixel) === colcible) { | ||
ctx.fillStyle = colrep; | ||
ctx.fillRect(pixel.x, pixel.y, 1, 1); | ||
pixels.push(pixel); | ||
left = { | ||
x: pixel.x, | ||
y: pixel.y - 1 | ||
}; | ||
right = { | ||
x: pixel.x, | ||
y: pixel.y + 1 | ||
}; | ||
up = { | ||
x: pixel.x + 1, | ||
y: pixel.y | ||
}; | ||
down = { | ||
x: pixel.x - 1, | ||
y: pixel.y | ||
}; | ||
if (!(!isInCanvas(ctx, left) || getColorAtPixel(ctx, left) !== colcible)) { | ||
bucketFill(ctx, left, colcible, colrep); | ||
} | ||
if (!(!isInCanvas(ctx, right) || getColorAtPixel(ctx, right) !== colcible)) { | ||
bucketFill(ctx, right, colcible, colrep); | ||
} | ||
if (!(!isInCanvas(ctx, up) || getColorAtPixel(ctx, up) !== colcible)) { | ||
bucketFill(ctx, up, colcible, colrep); | ||
} | ||
if (!(!isInCanvas(clx, down) || getColorAtPixel(ctx, up) !== colCible)) { | ||
bucketFill(ctx, down, colcible, colrep); | ||
} | ||
} | ||
}; | ||
|
||
getColorAtPixel = function(ctx, pixel) { | ||
var imageData; | ||
imageData = ctx.getImageData(pixel.x, pixel.y, 1, 1); | ||
return rgbArrayToCssColorString(imageData.data); | ||
}; | ||
|
||
rgbArrayToCssColorString = function(array) { | ||
var i, result; | ||
result = "#"; | ||
for (i = 0; i <= 2; i++) { | ||
result += array[i]; | ||
} | ||
return result; | ||
}; | ||
|
||
main = function() { | ||
var canvas, colCible, ctx, fillColor, penPosition; | ||
log("début du script"); | ||
canvas = document.getElementById("canvas"); | ||
ctx = canvas.getContext("2d"); | ||
ctx.fillStyle = "#0FF"; | ||
ctx.fillRect(10, 10, 40, 40); | ||
penPosition = { | ||
x: 1, | ||
y: 1 | ||
}; | ||
fillColor = "#FF0000"; | ||
colCible = getColorAtPixel(ctx, penPosition); | ||
try { | ||
bucketFill(ctx, penPosition, colCible, fillColor); | ||
} catch (e) { | ||
log(e, MAXSTACK); | ||
} | ||
log(colCible); | ||
return log(MAXSTACK); | ||
}; | ||
|
||
window.onload = function() { | ||
return main(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
[33mcommit 7cf0f7ad8d3a1ff5ae60ccb871acc24bdbf6018f[m | ||
Author: Daome <aikah@free.fr> | ||
Date: Sun Feb 19 19:30:00 2012 +0100 | ||
|
||
ajout undo redo | ||
|
||
[33mcommit e51d69f6265a68d3140f9fb2a710358328e1ab32[m | ||
Author: Daome <aikah@free.fr> | ||
Date: Sun Feb 19 13:35:36 2012 +0100 | ||
|
||
App.Utils.Iterator ajoute | ||
|
||
[33mcommit 10a9ac393ea5a3b824e92307217c6e1b16753064[m | ||
Author: Daome <aikah@free.fr> | ||
Date: Sun Feb 19 13:35:07 2012 +0100 | ||
|
||
App.Utils.Iterator ajout� | ||
|
||
[33mcommit d0043f187b3fbaff72213341410e1d1eac411de5[m | ||
Author: Daome <aikah@free.fr> | ||
Date: Sun Feb 19 02:59:21 2012 +0100 | ||
|
||
thickbox | ||
|
||
[33mcommit 949aa4300e0a4f0c8b0558b19c1253d9179baaab[m | ||
Author: Daome <aikah@free.fr> | ||
Date: Sat Feb 18 22:08:31 2012 +0100 | ||
|
||
deletion du manifeste | ||
|
||
[33mcommit 77f8b896c32690bd8cae25555d73db3b34afd0f5[m | ||
Author: Daome <aikah@free.fr> | ||
Date: Sat Feb 18 20:25:29 2012 +0100 | ||
|
||
modification css | ||
|
||
[33mcommit b2fc6e7286a932a50b4ebee472eec420aab61cd5[m | ||
Author: Daome <aikah@free.fr> | ||
Date: Sat Feb 18 17:55:41 2012 +0100 | ||
|
||
modifications html et css | ||
|
||
[33mcommit 9334267396c95121969da9e7e3434a4f006ad6f1[m | ||
Author: Daome <aikah@free.fr> | ||
Date: Sat Feb 18 16:34:59 2012 +0100 | ||
|
||
modifications html et css | ||
|
||
[33mcommit 23910a60871caca0fa2dd9059e51ef4c844b1143[m | ||
Author: Daome <aikah@free.fr> | ||
Date: Sat Feb 18 15:19:03 2012 +0100 | ||
|
||
modification main | ||
|
||
[33mcommit 18f0268cf7a5bfa85f0b9479073c311a64c4d0e3[m | ||
Author: Daome <aikah@free.fr> | ||
Date: Sat Feb 18 15:17:17 2012 +0100 | ||
|
||
ajout FactorSelector | ||
|
||
[33mcommit 8dea83ecca36a56f781cb3b37a5f5740930582f2[m | ||
Author: Daome <aikah@free.fr> | ||
Date: Sat Feb 18 11:49:47 2012 +0100 | ||
|
||
import initial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<title>Untitled Document</title> | ||
</head> | ||
<body> | ||
<canvas id='canvas' width="50" height='50'> | ||
canvas vide | ||
</canvas> | ||
<script type="text/javascript"> | ||
console.log(i) | ||
var i = 0 | ||
</script> | ||
<script type="text/javascript" src="js/test.js"></script> | ||
<style type="text/css"> | ||
canvas{ | ||
border:1px solid #999; | ||
margin:10px; | ||
} | ||
div{ | ||
font-color:#222; | ||
font-size:10px; | ||
} | ||
| ||
</style> | ||
</body> | ||
</html> |