Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noah Gregg and Marc Menard #92

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="pixel.css">
<title>Pixel Maker</title>
</head>
<body>
<h1> Noah and Marc's Pixel Emporium</h1>
<div id="box">

</div>

<div id="colorPalette">



<label for="favcolor">Select the color for your drawing:</label>
<input type="color" id="colorPicker" value="#ff0000">




</div>


<script type="text/javascript" defer src="pixel.js"></script>
</body>

</html>
36 changes: 36 additions & 0 deletions pixel.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#box {
margin: auto;
background-color: gray;
width: 1000px;
height: 1000px;
border: 1px solid black;

}

.pixels {
background-color: white;
width: 23px;
height: 23px;
border: 1px solid grey;
float: left;

}



#colorPalette {
margin: auto;
border: 3px solid black;
padding: 20px;
width: 100vw;
height: 5vw;



}






59 changes: 59 additions & 0 deletions pixel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
pixelFunc()
var color = "red"

function pixelFunc() {
let box = document.getElementById('box')
for (let i = 0; i < 1600; i++) {
let pixel = document.createElement('div');
box.appendChild(pixel)
pixel.classList.add("pixels");
}
var colorPalette = document.getElementById('colorPalette')
var palette = colorPalette.childNodes


var item1 = palette.item(1)
var colorPicker = document.getElementById('colorPicker')
colorPicker.addEventListener("input", watchColorPicker);
colorPicker.addEventListener("change", watchColorPicker);
function watchColorPicker(event) {

color = event.target.value;
};
}


let pixels = document.getElementsByClassName('pixels');
console.log(pixels);



for ( let i = 0; i < pixels.length; i++) {
pixels[i].addEventListener("mousedown", function(e) {
pixels[i].style.backgroundColor = color

});

}
// for ( let i = 0; i < pixels.length; i++) {



// pixels[i].addEventListener("mouseenter", function(e) {
// pixels[i].style.backgroundColor = color

// });

// }

//on mouse down, loop starts, on mouseenter loop continues, on mouseup, loop stops