Skip to content

Commit 9dfb3d2

Browse files
committed
Finaliza projeto
1 parent 30b294c commit 9dfb3d2

File tree

3 files changed

+32
-163
lines changed

3 files changed

+32
-163
lines changed

trybe-projetos/pixels-art/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ <h1 id="title" class="main-font bg-title">PIXEL ART</h1>
8181
</main>
8282

8383
<footer>
84-
<H3 id="footer" class="main-font">Desenvolvido como projeto na <a href="https://www.betrybe.com/">TRYBE</a> por <a href="https://www.linkedin.com/in/dev-marcospaulo">Marcos Paulo!</a></H3>
84+
<H3 id="footer" class="main-font">Desenvolvido como projeto na <a href="https://www.betrybe.com/">TRYBE</a> por <a href="https://www.linkedin.com/in/dev-marcospaulo">Marcos Paulo</a>!</H3>
8585
</footer>
86-
<script src="refatorando.js"></script>
86+
<script src="script.js"></script>
8787
</body>
8888

8989
</html>

trybe-projetos/pixels-art/refatorando.js

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 30 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,19 @@
1-
//SELEÇÃO DO HTML.
2-
let selected = document.getElementsByClassName('selected')[0].classList[1];
3-
let colorStore = 'background-color: rgb(0, 0, 0)';
4-
5-
const title = document.getElementById('title');
6-
7-
const colorPalette = document.getElementById('color-palette');
8-
let colorRed = document.getElementsByClassName('color-red');
9-
let colorBlue = document.getElementsByClassName('color-blue');
10-
let colorGreen = document.getElementsByClassName('color-green');
11-
let color = document.getElementsByClassName('color');
12-
13-
const clearBoard = document.getElementById('clear-board');
1+
//SELEÇÃO HTML
142
const imputBoardSize = document.getElementById('board-size');
15-
const buttonGenerateBoard = document.getElementById('generate-board');
16-
17-
183
let pixelBoard = document.getElementById('pixel-board');
19-
let line = document.getElementsByClassName('line');
20-
const board1 = document.getElementsByClassName('board1');
21-
const board2 = document.getElementsByClassName('board2');
22-
const board3 = document.getElementsByClassName('board3');
23-
const board4 = document.getElementsByClassName('board4');
24-
const board5 = document.getElementsByClassName('board5');
25-
let pixel = document.getElementsByClassName('pixel');
26-
27-
//INICIA COM BACKGROUND-COLOR: BLACK;
28-
function colorize(paint) {
29-
let aux = paint.classList[1];
30-
paint.classList.replace(aux, selected);
31-
}
32-
33-
pixelBoard.addEventListener('click', function (event) {
34-
colorize(event.target);
35-
// console.log(event.target); //TESTAR SELEÇÃO
36-
})
37-
38-
//GERA CORES ALETORIAS NA PALETA DE CORES.
39-
function generateColor() {
40-
41-
const letters = '0123456789ABCDEF';
42-
let color = '#';
43-
44-
for (let e = 0; e < 6; e += 1) {
45-
color += letters[Math.floor(Math.random() * 16)];
46-
}
47-
48-
return color;
49-
50-
}
51-
52-
for (let f = 1; f < color.length; f += 1){
53-
let capatAux = 'background-color: ' + generateColor();
54-
color[f].setAttribute('style', capatAux);
55-
}
56-
57-
58-
//SELECIONA COR NA PALETA.
59-
function colorSelect(selection) {
60-
for (let i = 0; i < color.length; i += 1) {
61-
color[i].classList.remove('selected');
62-
if (selection === color[i]) {
63-
selection.classList.toggle('selected');
64-
selected = document.getElementsByClassName('selected')[0].classList[1];
65-
}
66-
}
67-
}
68-
69-
colorPalette.addEventListener('click', function (event) {
70-
let teste = window.getComputedStyle(event.target);
71-
let teste2 = teste.getPropertyValue('background-color');
72-
colorStore = teste2;
73-
colorSelect(event.target);
74-
console.log(colorStore);
75-
// console.log(color); //TESTAR SELEÇÃO
76-
// console.log(selected); //TESTAR SELEÇÃO
77-
})
78-
79-
//COLORE PIXEL.
80-
function colorize2(paint) {
81-
// let aux = window.getComputedStyle(paint);
82-
// let aux2 = aux.getPropertyValue('background-color');
83-
// paint.setAttribute('style', 'background-color' + aux2)
84-
// let aux = paint.classList[1];
85-
paint.setAttribute('style', 'background-color: ' + colorStore);
86-
}
87-
88-
pixelBoard.addEventListener('click', function (event) {
89-
colorize2(event.target);
90-
// console.log(event.target); //TESTAR SELEÇÃO
91-
})
92-
93-
//LIMPA PIXELS.
94-
clearBoard.addEventListener('click', function () {
95-
location.reload();
96-
});
4+
const buttonGenerateBoard = document.getElementById('generate-board');
5+
let paletteColor = document.getElementById('palette-color');
6+
let colorStore = 'background-color: rgb(0, 0, 0)';
7+
const buttonSelectColor = document.getElementById('select-color');
8+
const clearBoard = document.getElementById('clear-board');
979

9810
//MUNDA QUANTIDADE DE PIXEL PARA PINTAR.
9911
function sizeBoard() {
10012
let imputValue = imputBoardSize.value;
10113
if (imputValue < 5) {
10214
imputValue = 5;
103-
} else if (imputValue > 50) {
104-
imputValue = 50;
15+
} else if (imputValue > 30) {
16+
imputValue = 30;
10517
}
10618
for (let c = 0; c < imputValue; c += 1) {
10719
let newLine = document.createElement('div');
@@ -119,13 +31,33 @@ function sizeBoard() {
11931
}
12032
// console.log(pixelBoard); //TESTAR TAMANHO.
12133

122-
12334
buttonGenerateBoard.addEventListener('click', function () {
12435
if (imputBoardSize.value === '') {
125-
alert('Board inválido!');
36+
alert('Tamanho inválido!');
12637
} else {
12738
pixelBoard.innerHTML = '';
12839
sizeBoard();
12940
}
13041
})
13142

43+
//SELECIONA COR
44+
buttonSelectColor.addEventListener('click', function(event){
45+
let aux = paletteColor.value
46+
colorStore = aux;
47+
console.log(aux);
48+
console.log(colorStore);
49+
})
50+
51+
//COLORE PIXEL
52+
function colorize2(paint) {
53+
paint.setAttribute('style', 'background-color: ' + colorStore,);
54+
}
55+
56+
pixelBoard.addEventListener('click', function (event) {
57+
colorize2(event.target);
58+
})
59+
60+
//LIMPAR TELA.
61+
clearBoard.addEventListener('click', function () {
62+
location.reload();
63+
});

0 commit comments

Comments
 (0)