Kate Moore 7 lat temu
rodzic
commit
64636ba67e
2 zmienionych plików z 12 dodań i 13 usunięć
  1. 7
    8
      js/colors.js
  2. 5
    5
      js/index.js

+ 7
- 8
js/colors.js Wyświetl plik

1
-var colorsArray : {
2
-    colors=[
1
+var colorsArray =[
3
         {
2
         {
4
             "name":"green",
3
             "name":"green",
5
             "red":"64",
4
             "red":"64",
17
             red:"192",
16
             red:"192",
18
             green:"46",
17
             green:"46",
19
             blue:"35"
18
             blue:"35"
20
-        }
19
+        },
21
         {
20
         {
22
             "name":"blue",
21
             "name":"blue",
23
             "red":"19",
22
             "red":"19",
25
             "blue":"144",
24
             "blue":"144",
26
         },
25
         },
27
         {
26
         {
28
-            "name"="orange",
29
-            "red"="253",
30
-            "green"="92",
31
-            "blue"="48"
32
-        },
27
+            "name":"orange",
28
+            "red":"253",
29
+            "green":"92",
30
+            "blue":"48"
31
+        }
33
     ]
32
     ]

+ 5
- 5
js/index.js Wyświetl plik

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);
43
-		this.r = colorsArray.colors[this.randomColor].red;
44
-		this.g = colorsArray.colors[this.randomColor].green;
45
-		this.b = colorsArray.colors[this.randomColor].blue;
42
+		this.randomColor = randomInt(0,colorsArray.length-1);
43
+		this.r = colorsArray[this.randomColor].red;
44
+		this.g = colorsArray[this.randomColor].green;
45
+		this.b = colorsArray[this.randomColor].blue;
46
 
46
 
47
 		console.log(colorsArray);
47
 		console.log(colorsArray);
48
 
48
 
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
+}