For this application, you will be creating a pixel painting game!
Please fork and clone this repository.
Please create the following files:
- index.html
- styles.css
- js/app.js
Create link tags for your CSS stylesheet and javascript file in your html document and ensure all files are connected.
-
Create a header containing the name of the application using a header tag.
-
Create a container for your entire application using a div tag and set the id attribute to
entireContainer. -
Within the
entireContainer, -
Create a container for your palets using a div tag and set the id attribute to
paletContainer. -
Create a container for your canvas using a div tag and set the id attribute to
canvasContainer. -
Within the
paletteContainer, -
Create 5 containers for colors using div tags
-
Set the class attribute on each color to
palette -
Set the id attribute on each pixel to a color name - The first palette would have the id
red, the second pixel would have the idpurple, and so on. -
Set an onclick method on each pixel to call the function
getBackgroundColor(). - Passthis.idwithin the function. -
Within the
canvasContainer, -
Create 5 pixels using div tags
-
Set the class attribute on each pixel to
canvas -
Set the id attribute on each pixel to
canvas#- The first pixel would have the idcanvas1, the second pixel would have the idcanvas2, and so on. -
Set an onclick method on each pixel to call the function
changeColorOnClick(). - Passthis.idwithin the function. -
Create a container using a div tag and set the id attribute to
selectedColorNameContainer. -
Within the
selectedColorNameContainer, -
Create a container using a div tag and set the id attribute to
selectedColorName.
Do not continue until you have finished Part I of both the Javascript and CSS portion.
-
Create a function called changeColorOnClick and set the parameter as
idName. -
Within the function changeColorOnClick,
-
Use the DOM method to reference an element by its ID to retrieve the background color of the element with id
selectedColorNameand store this in a variable calledoriginalElementColor -
Use the same DOM method as above, retrieve the background color of the element with the function parameter
idNameand set its value tooriginalElementColor. -
Create a function called getBackgroundColor and set the parameter as
idName. -
Within the function getBackgroundColor,
-
Use the DOM method to reference an element by its ID, pass the parameter
idNamewithin this method, and store this in a variable calledelement -
Store the value of the method
window.getComputedStyle(element,null).getPropertyValue("background-color")in a variable calledstyle. -
Use the DOM method to reference an element by its ID to retrieve the background color of the element with id
selectedColorNameand set its value tostyle
Do not continue until you have finished Part I of both the Javascript and CSS portion.
- Set the background color of each pixel within the
paletteContainerto it's respective color.
Good job on getting this far!
Extra Features:
- Erase
- Fill
- Templates
- Anything you can think of!