소스 검색

fixed colors and index file for program to run

Michelle DiMarino 5 년 전
부모
커밋
81b1933ccc
3개의 변경된 파일21개의 추가작업 그리고 20개의 파일을 삭제
  1. 2
    2
      index.html
  2. 15
    14
      js/colors.js
  3. 4
    4
      js/index.js

+ 2
- 2
index.html 파일 보기

@@ -14,7 +14,7 @@
14 14
 
15 15
     <article>
16 16
 	    <h1>Instructions</h1>
17
-        <p>Your missioin is to debug js/colors.js. The javascript application depends on this file to feed it the color data to write to screen.</p>
17
+        <p>Your mission is to debug js/colors.js. The javascript application depends on this file to feed it the color data to write to screen.</p>
18 18
         <p>Use the developer tools in your browser to debug and fix the code.</p>
19 19
 	</article>
20 20
 
@@ -28,4 +28,4 @@
28 28
     <script type="text/javascript" src="js/colors.js"></script>
29 29
     <script type="text/javascript" src="js/index.js"></script>
30 30
 </body>
31
-</html>
31
+</html>

+ 15
- 14
js/colors.js 파일 보기

@@ -1,10 +1,10 @@
1
-var colorsArray : {
2
-    colors=[
1
+var colorsArray = {
2
+    "colors" :[
3 3
         {
4 4
             "name":"green",
5 5
             "red":"64",
6 6
             "green":"175",
7
-            "blue":"63",
7
+            "blue":"63"
8 8
         },
9 9
         {
10 10
             "name":"yellow",
@@ -13,21 +13,22 @@ var colorsArray : {
13 13
             "blue":"62"
14 14
         },
15 15
         {
16
-            name:"red",
17
-            red:"192",
18
-            green:"46",
19
-            blue:"35"
20
-        }
16
+            "name":"red",
17
+            "red":"192",
18
+            "green":"46",
19
+            "blue":"35"
20
+        },
21 21
         {
22 22
             "name":"blue",
23 23
             "red":"19",
24 24
             "green":"71",
25
-            "blue":"144",
25
+            "blue":"144"
26 26
         },
27 27
         {
28
-            "name"="orange",
29
-            "red"="253",
30
-            "green"="92",
31
-            "blue"="48"
32
-        },
28
+            "name":"orange",
29
+            "red":"253",
30
+            "green":"92",
31
+            "blue":"48"
32
+        }
33 33
     ]
34
+  }

+ 4
- 4
js/index.js 파일 보기

@@ -17,7 +17,7 @@ window.onload = function()
17 17
 	canvas.width = W;
18 18
 	canvas.height = H;
19 19
 
20
-	//console.log("my color request: "+colorsArray);
20
+	console.log("my color request: "+colorsArray);
21 21
 
22 22
 	/*===============Box class=================================*/
23 23
 	function Box(_x, _y)
@@ -35,9 +35,9 @@ window.onload = function()
35 35
 		this.height = 20;
36 36
 
37 37
 		//random colors for our box
38
-		/*this.r = Math.round(Math.random()*255);
38
+		this.r = Math.round(Math.random()*255);
39 39
 		this.g = Math.round(Math.random()*255);
40
-		this.b = Math.round(Math.random()*255);*/
40
+		this.b = Math.round(Math.random()*255);
41 41
 
42 42
 		this.randomColor = randomInt(0,colorsArray.colors.length-1);
43 43
 		this.r = colorsArray.colors[this.randomColor].red;
@@ -136,4 +136,4 @@ window.onload = function()
136 136
 	//set interval so we can draw then update our drawing
137 137
 	// every 30 milisecond
138 138
 	setInterval(draw,30);
139
-}
139
+}