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

"New working pixel maker" #94

Open
wants to merge 1 commit 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
22 changes: 22 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>pixArt</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">

</head>
<body>

<div id="container"></div>
<div id="colorButtons">
<div id="redButton" class="button">Red</div>
<div id="yellowButton" class="button">Yellow</div>
<div id="blueButton" class="button">Blue</div>
<div id="greenButton" class="button">Green</div>
<div id="purpleButton" class="button">Purple</div>

<script type="text/javascript" src="index.js"></script>

</div>
</body>
<html>
68 changes: 68 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
function pixArt() {
var pixel = document.getElementById('container');
var rows = document.getElementsByClassName('rows');
var columns = document.getElementsByClassName('columns');
var colorButtons = document.getElementById('colorButtons')
var currentColor = "";



function makeRows(rowNum){
for (let i = 0; i < rowNum; i++) {
let rowDiv = document.createElement('div');
rowDiv.style.backgroundColor = 'white';

rowDiv.addEventListener("click",function(){
rowDiv.style.backgroundColor = currentColor});

rowDiv.addEventListener("mousedown",function(){
rowDiv.style.backgroundColor = currentColor
})
rowDiv.addEventListener("mouseenter",function(){
rowDiv.style.backgroundColor = currentColor
})
rowDiv.addEventListener("mouseup",function(){
rowDiv.style.backgroundColor = ""
})

pixel.appendChild(rowDiv).className = 'rows';

}
}


function buttonChange(){
var redHolder = document.getElementById("redButton")
var yellowHolder = document.getElementById("yellowButton")
var blueHolder = document.getElementById("blueButton")
var greenHolder = document.getElementById("greenButton")
var purpleHolder = document.getElementById("purpleButton")


redHolder.addEventListener("click", function() {
currentColor = "red"
})
yellowHolder.addEventListener("click", function() {
currentColor = "yellow"
})
blueHolder.addEventListener("click", function() {
currentColor = "blue"
})
greenHolder.addEventListener("click", function() {
currentColor = "green"
})
purpleHolder.addEventListener("click", function() {
currentColor = "purple"
})

}

buttonChange();
makeRows(144);
}

pixArt();

//make buttons the colors that they represent
//select an individual DIV
// create event listeners for on clicks on those DIV
8 changes: 8 additions & 0 deletions stylesheet.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.rows {
border-style: 5px solid black;
height: 50px;
width: 50px;
display: inline-block;
outline: 5px solid black;
outline-offset: -5px;
}