Permalink
Browse files

Some refactoring and renaming

  • Loading branch information...
1 parent 536c68d commit 48645b5cc5532bdf132759b5ec1205eea7cf956e @mrdoob mrdoob committed Mar 28, 2010
View
22 src/index.html
@@ -14,17 +14,17 @@
</style>
</head>
<body>
- <script type="text/javascript" src="js/styles/circles.js"></script>
- <script type="text/javascript" src="js/styles/chrome.js"></script>
- <script type="text/javascript" src="js/styles/fur.js"></script>
- <script type="text/javascript" src="js/styles/grid.js"></script>
- <script type="text/javascript" src="js/styles/longfur.js"></script>
- <script type="text/javascript" src="js/styles/ribbon.js"></script>
- <script type="text/javascript" src="js/styles/shaded.js"></script>
- <script type="text/javascript" src="js/styles/simple.js"></script>
- <script type="text/javascript" src="js/styles/sketchy.js"></script>
- <script type="text/javascript" src="js/styles/squares.js"></script>
- <script type="text/javascript" src="js/styles/web.js"></script>
+ <script type="text/javascript" src="js/brushes/circles.js"></script>
+ <script type="text/javascript" src="js/brushes/chrome.js"></script>
+ <script type="text/javascript" src="js/brushes/fur.js"></script>
+ <script type="text/javascript" src="js/brushes/grid.js"></script>
+ <script type="text/javascript" src="js/brushes/longfur.js"></script>
+ <script type="text/javascript" src="js/brushes/ribbon.js"></script>
+ <script type="text/javascript" src="js/brushes/shaded.js"></script>
+ <script type="text/javascript" src="js/brushes/simple.js"></script>
+ <script type="text/javascript" src="js/brushes/sketchy.js"></script>
+ <script type="text/javascript" src="js/brushes/squares.js"></script>
+ <script type="text/javascript" src="js/brushes/web.js"></script>
<script type="text/javascript" src="js/colorselector.js"></script>
<script type="text/javascript" src="js/palette.js"></script>
<script type="text/javascript" src="js/menu.js"></script>
View
0 src/js/styles/chrome.js → src/js/brushes/chrome.js
File renamed without changes.
View
0 src/js/styles/circles.js → src/js/brushes/circles.js
File renamed without changes.
View
0 src/js/styles/fur.js → src/js/brushes/fur.js
File renamed without changes.
View
0 src/js/styles/grid.js → src/js/brushes/grid.js
File renamed without changes.
View
0 src/js/styles/longfur.js → src/js/brushes/longfur.js
File renamed without changes.
View
0 src/js/styles/ribbon.js → src/js/brushes/ribbon.js
File renamed without changes.
View
0 src/js/styles/shaded.js → src/js/brushes/shaded.js
File renamed without changes.
View
0 src/js/styles/simple.js → src/js/brushes/simple.js
File renamed without changes.
View
0 src/js/styles/sketchy.js → src/js/brushes/sketchy.js
File renamed without changes.
View
0 src/js/styles/squares.js → src/js/brushes/squares.js
File renamed without changes.
View
0 src/js/styles/web.js → src/js/brushes/web.js
File renamed without changes.
View
41 src/js/main.js
@@ -1,5 +1,4 @@
-var i,
-style, STYLES = ["sketchy", "shaded", "chrome", "fur", "longfur", "web", "", "simple", "squares", "ribbon", "", "circles", "grid"],
+var i, brush, BRUSHES = ["sketchy", "shaded", "chrome", "fur", "longfur", "web", "", "simple", "squares", "ribbon", "", "circles", "grid"],
COLOR = [0, 0, 0], BACKGROUND_COLOR = [250, 250, 250],
SCREEN_WIDTH = window.innerWidth,
SCREEN_HEIGHT = window.innerHeight,
@@ -63,20 +62,20 @@ function init()
{
hash = window.location.hash.substr(1,window.location.hash.length);
- for (i = 0; i < STYLES.length; i++)
+ for (i = 0; i < BRUSHES.length; i++)
{
- if (hash == STYLES[i])
+ if (hash == BRUSHES[i])
{
- style = eval("new " + STYLES[i] + "(context)");
+ brush = eval("new " + BRUSHES[i] + "(context)");
menu.selector.selectedIndex = i;
break;
}
}
}
- if (!style)
+ if (!brush)
{
- style = eval("new " + STYLES[0] + "(context)");
+ brush = eval("new " + BRUSHES[0] + "(context)");
}
about = new About();
@@ -142,8 +141,8 @@ function onDocumentKeyDown( event )
altKeyIsDown = true;
break;
case 82: // r
- style.destroy();
- style = eval("new " + STYLES[menu.selector.selectedIndex] + "(context)");
+ brush.destroy();
+ brush = eval("new " + BRUSHES[menu.selector.selectedIndex] + "(context)");
break;
}
}
@@ -319,13 +318,13 @@ function onMenuBackgroundColor()
function onMenuSelectorChange()
{
- if (STYLES[menu.selector.selectedIndex] == "")
+ if (BRUSHES[menu.selector.selectedIndex] == "")
return;
- style.destroy();
- style = eval("new " + STYLES[menu.selector.selectedIndex] + "(context)");
+ brush.destroy();
+ brush = eval("new " + BRUSHES[menu.selector.selectedIndex] + "(context)");
- window.location.hash = STYLES[menu.selector.selectedIndex];
+ window.location.hash = BRUSHES[menu.selector.selectedIndex];
}
function onMenuMouseOver()
@@ -353,8 +352,8 @@ function onMenuClear()
{
context.clearRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
- style.destroy();
- style = eval("new " + STYLES[menu.selector.selectedIndex] + "(context)");
+ brush.destroy();
+ brush = eval("new " + BRUSHES[menu.selector.selectedIndex] + "(context)");
}
function onMenuAbout()
@@ -372,20 +371,20 @@ function onCanvasMouseDown( event )
{
cleanPopUps();
- style.strokeStart( event.clientX, event.clientY );
+ brush.strokeStart( event.clientX, event.clientY );
window.addEventListener('mousemove', onCanvasMouseMove, false);
window.addEventListener('mouseup', onCanvasMouseUp, false);
}
function onCanvasMouseMove( event )
{
- style.stroke( event.clientX, event.clientY );
+ brush.stroke( event.clientX, event.clientY );
}
function onCanvasMouseUp()
{
- style.strokeEnd();
+ brush.strokeEnd();
window.removeEventListener('mousemove', onCanvasMouseMove, false);
window.removeEventListener('mouseup', onCanvasMouseUp, false);
@@ -402,7 +401,7 @@ function onCanvasTouchStart( event )
{
event.preventDefault();
- style.strokeStart( event.touches[0].pageX, event.touches[0].pageY );
+ brush.strokeStart( event.touches[0].pageX, event.touches[0].pageY );
window.addEventListener('touchmove', onCanvasTouchMove, false);
window.addEventListener('touchend', onCanvasTouchEnd, false);
@@ -414,7 +413,7 @@ function onCanvasTouchMove( event )
if(event.touches.length == 1)
{
event.preventDefault();
- style.stroke( event.touches[0].pageX, event.touches[0].pageY );
+ brush.stroke( event.touches[0].pageX, event.touches[0].pageY );
}
}
@@ -424,7 +423,7 @@ function onCanvasTouchEnd( event )
{
event.preventDefault();
- style.strokeEnd();
+ brush.strokeEnd();
window.removeEventListener('touchmove', onCanvasTouchMove, false);
window.removeEventListener('touchend', onCanvasTouchEnd, false);
View
4 src/js/menu.js
@@ -50,11 +50,11 @@ Menu.prototype =
this.selector = document.createElement("select");
- for (i = 0; i < STYLES.length; i++)
+ for (i = 0; i < BRUSHES.length; i++)
{
option = document.createElement("option");
option.id = i;
- option.innerHTML = STYLES[i].toUpperCase();
+ option.innerHTML = BRUSHES[i].toUpperCase();
this.selector.appendChild(option);
}

0 comments on commit 48645b5

Please sign in to comment.