Skip to content

Commit ceeae2f

Browse files
committed
appearance improvements
1 parent 9f9e0f7 commit ceeae2f

File tree

3 files changed

+52
-26
lines changed

3 files changed

+52
-26
lines changed

index.html

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
<head>
44
<meta charset="utf-8">
55
<link rel="stylesheet" type="text/css" href = "styles.css">
6+
<link href="https://fonts.googleapis.com/css?family=VT323" rel="stylesheet">
67
<script src="script.js" type="text/javascript"></script>
78
<title>Pixel Art Maker</title>
89
</head>
910
<body>
10-
<div id="grid">
11-
</div>
12-
13-
<div id="palette">
11+
<h1>Pixel Art Maker</h1>
12+
<div id="container">
13+
<div id="grid">
14+
</div>
15+
<div id="palette">
16+
</div>
1417
</div>
1518
</body>
1619
</html>

script.js

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
document.addEventListener("DOMContentLoaded", function () {
22
let grid = document.getElementById("grid")
3-
let gridSize = 24
4-
let colorNames = ["red", "orange", "yellow", "green", "blue", "purple", "black", "white", "SaddleBrown"]
3+
let container = document.getElementById("container")
4+
let pixels = 24
5+
let colorNames = ["red", "orange", "yellow", "green", "blue", "purple", "black", "white", "gray", "SaddleBrown"]
56
let currentColor = ""
67
let cell, row, col, colorCell, indicator
78

9+
// pixels * width of each pixel (20px) + (pixels + 1) * border (1px) = total grid size
10+
grid.style.width = (pixels * 21 + 1) + "px"
11+
grid.style.height = (pixels * 21 + 1) + "px"
12+
container.style.width = (pixels * 21 + 50) + "px"
13+
814
function changeColor(event) {
915
event.target.style.backgroundColor = currentColor
1016
}
@@ -15,22 +21,21 @@ document.addEventListener("DOMContentLoaded", function () {
1521
}
1622

1723
function makeGrid() {
18-
for (let rows = 0; rows < gridSize; rows++) {
24+
for (let rows = 0; rows < pixels; rows++) {
1925
row = document.createElement("div")
2026
row.className = "row"
21-
// row.style.height = 100/gridSize + "%"
22-
for (let cols = 0; cols < gridSize; cols++) {
27+
28+
for (let cols = 0; cols < pixels; cols++) {
2329
cell = document.createElement("div")
2430
cell.className = "cell"
2531

26-
// if (rows === 0) {
27-
// cell.style.borderTop = "1px solid black"
28-
// }
29-
// if (cols === 0) {
30-
// cell.style.borderLeft = "1px solid black"
31-
// }
32+
if (rows === 0) {
33+
cell.style.borderTop = "1px solid black"
34+
}
35+
if (cols === 0) {
36+
cell.style.borderLeft = "1px solid black"
37+
}
3238

33-
// cell.style.width = 100/gridSize + "%"
3439
row.appendChild(cell)
3540
}
3641
grid.appendChild(row)
@@ -54,6 +59,5 @@ document.addEventListener("DOMContentLoaded", function () {
5459

5560
indicator = document.createElement("div")
5661
indicator.className = "indicator"
57-
indicator.textContent = "current color"
5862
palette.appendChild(indicator)
5963
})

styles.css

+28-9
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,48 @@
1+
h1 {
2+
font-family: 'VT323', monospace;
3+
text-align: center;
4+
}
5+
16
.row {
2-
height: 19px;
7+
height: 20px;
38
}
49

510
.cell {
611
display: inline-block;
712
height: 100%;
8-
width: 19px;
9-
border: 1px solid black;
13+
width: 20px;
14+
border-width: 0 1px 1px 0;
15+
border-style: solid;
1016
}
1117

1218
.color {
19+
border-radius: 50%;
1320
display: inline-block;
14-
height: 50px;
15-
width: 50px;
21+
height: 35px;
22+
width: 35px;
1623
border: 1px solid black;
24+
margin: 0 0 1px 3px;
1725
}
1826

1927
.indicator {
28+
border-radius: 50%;
2029
display: inline-block;
21-
height: 50px;
22-
width: 50px;
30+
height: 35px;
31+
width: 35px;
2332
border: 1px solid black;
33+
margin: 30px 0 0 3px;
34+
}
35+
36+
#container {
37+
margin: 0 auto;
2438
}
2539

2640
#grid {
27-
height: 525px;
28-
width: 525px;
41+
display: inline-block;
42+
}
43+
44+
#palette {
45+
display: inline-block;
46+
height: 400px;
47+
width: 40px;
2948
}

0 commit comments

Comments
 (0)