-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
106 lines (72 loc) · 2.35 KB
/
sketch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
var data;
var color;
var colorBar;
function setup() {
// var cnv = createCanvas(800, 700);
var jsonPath =
"https://gist.githubusercontent.com/jjdelc/1868136/raw/c9160b1e60bd8c10c03dbd1a61b704a8e977c46b/crayola.json";
loadJSON(jsonPath, dataIn);
noCanvas();
noLoop();
// $(".color").each(function() {
// $(this).click(function() {
// color = $(this).css('background-color');
// console.log(color);
// $('#current-color').css("background-color", color);
// $('#color-name').css("color", color);
// $('#color-name').text(data[i].name);
// });
// });
// color = colorId;
}
function dataIn(jsonData) {
console.log("got it");
data = jsonData;
// console.log(data);
var colorList = document.createElement('div');
colorList.id = "color-list";
var body = $('body');
colorBar = document.createElement('div');
colorBar.id = "color-bar";
$(body).append(colorBar);
$(body).append(colorList);
for (var i = 0; i < 60; i++) {
for (var b = 0; b < 100; b++) {
var number = 1 + Math.floor(Math.random() * 100);
var colorEntry = document.createElement('p');
colorEntry.id = "color-" + i + b;
colorEntry.className = "color";
// $(colorEntry).text(data[i].name);
$(colorEntry).css("background-color", data[number].hex);
// console.log(i);
$(colorList).append(colorEntry);
var hoverBox = document.createElement('div');
hoverBox.className = "hovered";
$(hoverBox).text("Name: " + data[number].name + " // Hex: " +
data[number].hex + " // RGB: " + data[number].rgb);
$(colorEntry).css("color", data[number].hex);
$(colorEntry).append(hoverBox);
}
}
$(".color").each(function() {
$(this).mouseenter(function() {
color = $(this).css('background-color');
// console.log(color);
var thisId = this.id;
thisId = thisId.slice(6);
// console.log(thisId);
$('#current-color').css("background-color", color);
$(colorBar).css("background-color", color);
$('#color-name').css("color", color);
// $('#color-name').text(data[thisId].name);
});
});
}
// var bytes = '{"name":"terricka", "counter":0}';
// var data = JSON.parse(bytes);
function draw() {
// background(80, 174, 207);
// console.log(data.name);
// console.log(data.counter);
// data.counter += 1;
}