Create your own pixel art maker
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pixel-art-maker/index.js

44 lines
1.4 KiB

7 years ago
// document.body.innerHTML = "Hello world!";
let main = document.createElement('div');
main.className = 'divContainer';
document.body.appendChild(main);
7 years ago
let className;
7 years ago
7 years ago
for(let i=0;i<50;i++) {
7 years ago
const rowDiv=document.createElement('div');
rowDiv.className = 'rowDivContainer';
7 years ago
main.appendChild(rowDiv);
7 years ago
for(let j=0;j<50;j++) {
7 years ago
const div=document.createElement('div');
div.className='divElem';
div.addEventListener("click",(e)=>{
e.target.className='colorChange';
7 years ago
if(typeof className !=='undefined'){
e.target.className=className;
e.target.style="border-radius:0"
}
7 years ago
});
rowDiv.appendChild(div);
}
}
7 years ago
const colorArray=['red','blue','green','black','purple','aqua','pink','lightcoral','gold',
'brown','blueviolet','olivedrab','blanchedalmond','darkorange','yellow','plum','cadetblue',
'paleturquoise','tomato','turquoise','peachpuff','silver','lightseagreen','slateblue',
'lavender','greenyellow','rebeccapurple'];
7 years ago
let palette = document.createElement('div');
palette.className = 'Pal';
document.body.appendChild(palette);
7 years ago
for(let i=0;i<33;i++) {
7 years ago
const color = document.createElement('div');
color.className = 'palColor'+i;
7 years ago
//color.style="background-color: blue"
7 years ago
palette.appendChild(color);
7 years ago
color.addEventListener("click",(e)=>{
className = e.target.className;
})
7 years ago
}