Browse Source

fixed colors and index file for program to run

Michelle DiMarino 6 years ago
parent
commit
81b1933ccc
3 changed files with 21 additions and 20 deletions
  1. 2
    2
      index.html
  2. 15
    14
      js/colors.js
  3. 4
    4
      js/index.js

+ 2
- 2
index.html View File

14
 
14
 
15
     <article>
15
     <article>
16
 	    <h1>Instructions</h1>
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
         <p>Use the developer tools in your browser to debug and fix the code.</p>
18
         <p>Use the developer tools in your browser to debug and fix the code.</p>
19
 	</article>
19
 	</article>
20
 
20
 
28
     <script type="text/javascript" src="js/colors.js"></script>
28
     <script type="text/javascript" src="js/colors.js"></script>
29
     <script type="text/javascript" src="js/index.js"></script>
29
     <script type="text/javascript" src="js/index.js"></script>
30
 </body>
30
 </body>
31
-</html>
31
+</html>

+ 15
- 14
js/colors.js View File

1
-var colorsArray : {
2
-    colors=[
1
+var colorsArray = {
2
+    "colors" :[
3
         {
3
         {
4
             "name":"green",
4
             "name":"green",
5
             "red":"64",
5
             "red":"64",
6
             "green":"175",
6
             "green":"175",
7
-            "blue":"63",
7
+            "blue":"63"
8
         },
8
         },
9
         {
9
         {
10
             "name":"yellow",
10
             "name":"yellow",
13
             "blue":"62"
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
             "name":"blue",
22
             "name":"blue",
23
             "red":"19",
23
             "red":"19",
24
             "green":"71",
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 View File

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