Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fa60f0a
added link to hsl.html
chamannarved Aug 14, 2020
2b2982d
create hsl.html and add setup content
chamannarved Aug 14, 2020
45183ed
create hsl.js and add hsl syntex in comment
chamannarved Aug 14, 2020
c94ce86
create a getValues() function
chamannarved Aug 14, 2020
d4490b4
create a function getHueValues()
chamannarved Aug 15, 2020
4621010
create a function getAlphaValue()
chamannarved Aug 15, 2020
eadad8b
create array of color
chamannarved Aug 15, 2020
fd530f6
setup files added to final for hsl color
chamannarved Aug 15, 2020
de34604
hsl link added to nav links
chamannarved Aug 15, 2020
de57e9c
fix Multidimensional array bug
chamannarved Aug 15, 2020
cebea0f
fix Multidimensional array bug
chamannarved Aug 15, 2020
03017fe
select html elements to change
chamannarved Aug 15, 2020
9ba40a8
add event listener to btn
chamannarved Aug 15, 2020
e757577
add hard code for testing color format
chamannarved Aug 15, 2020
53382fe
create new function getRandomNumberHue()
chamannarved Aug 15, 2020
8e9dd3f
create new function getRandomNumberSat()
chamannarved Aug 15, 2020
e9ac495
create new function getRandomNumberLight()
chamannarved Aug 15, 2020
bbed6bc
create new function getRandomNumberAlpha()
chamannarved Aug 15, 2020
5ec41dc
remove testing code
chamannarved Aug 15, 2020
b582161
change color value and body color on click
chamannarved Aug 15, 2020
4532922
fix typo in title tag
chamannarved Aug 15, 2020
d254bba
added to setup rgb.htm and rgb.js
chamannarved Aug 15, 2020
162f368
add rgb link in nav
chamannarved Aug 15, 2020
d7c72e4
create a functoin for rgb values
chamannarved Aug 15, 2020
f23ec23
create a function for alpha values
chamannarved Aug 15, 2020
58c5534
create array of color values
chamannarved Aug 15, 2020
e726e1b
rgb setup files added to final
chamannarved Aug 15, 2020
a252121
select html elements
chamannarved Aug 15, 2020
85e5197
add event listener for btn
chamannarved Aug 15, 2020
0c1e8a0
add hard code for testing
chamannarved Aug 15, 2020
014b259
create new function getRandomNumber()
chamannarved Aug 15, 2020
c1dde8a
edit color array and direct use function
chamannarved Aug 15, 2020
ef41d0b
remove testing code
chamannarved Aug 15, 2020
6451887
change color value and body bg color on click
chamannarved Aug 15, 2020
fc51cf3
change title
chamannarved Aug 15, 2020
6f08233
add rgb link to nav in final
chamannarved Aug 15, 2020
dafb7c6
change color values function to array
chamannarved Aug 15, 2020
8bcf173
edit color array and direct use function
chamannarved Aug 15, 2020
0163ae4
remove getRandomNumberAlpha()
chamannarved Aug 15, 2020
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
2 changes: 2 additions & 0 deletions 2 1-color-flipper/final/hex.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ <h4>color flipper</h4>
<ul class="nav-links">
<li><a href="index.html">simple</a></li>
<li><a href="hex.html">hex</a></li>
<li><a href="hsl.html">hsl</a></li>
<li><a href="rgb.html">rgb</a></li>
</ul>
</div>
</nav>
Expand Down
39 changes: 39 additions & 0 deletions 39 1-color-flipper/final/hsl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Color Flipper || Hsl</title>

<!-- styles -->
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<nav>
<div class="nav-center">
<h4>color flipper</h4>
<ul class="nav-links">
<li><a href="index.html">simple</a></li>
<li><a href="hex.html">hex</a></li>
<li><a href="hsl.html">hsl</a></li>
<li><a href="rgb.html">rgb</a></li>
</ul>
</div>
</nav>
<main>
<div class="container">
<h2>
background color :
<span class="color">
#f1f5f8
</span>
</h2>
<div class="container">
<button class="btn btn-hero" id="btn">click me</button>
</div>
</div>
</main>
<!-- javascript -->
<script src="hsl.js"></script>
</body>
</html>
63 changes: 63 additions & 0 deletions 63 1-color-flipper/final/hsl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
hsl(hue,saturation,light,alpha)
hsl(0 - 360, 0 -100%,0 - 100%,0 - 1)

*/

// get value for saturation and light (0-100)
function getValues() {
let value = [];
for (let i = 0; i <= 100; i++) {
value.push(i);
}
return value;
}

//get values for hue (0 - 360)
function getHueValues() {
let value = [];
for (let i = 0; i <= 360; i++) {
value.push(i);
}
return value;
}

// get values for alpha
function getAlphaValues() {
return Math.random().toFixed(2);
}

// get all values in one array of color
const hsl = [getHueValues(), getValues(), getValues()];

const btn = document.getElementById("btn");
const color = document.querySelector(".color");

btn.addEventListener("click", function () {
// hslColor = hsl(222, 50%, 70%, 0.24);
let hslColor =
"hsl(" +
hsl[0][getRandomNumberHue()] +
"," +
hsl[1][getRandomNumberSat()] +
"%," +
hsl[2][getRandomNumberLight()] +
"%," +
getAlphaValues() +
")";

color.textContent = hslColor;
document.body.style.backgroundColor = hslColor;
});

function getRandomNumberHue() {
return Math.floor(Math.random() * hsl[0].length);
}

function getRandomNumberSat() {
return Math.floor(Math.random() * hsl[1].length);
}

function getRandomNumberLight() {
return Math.floor(Math.random() * hsl[2].length);
}
2 changes: 2 additions & 0 deletions 2 1-color-flipper/final/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ <h4>color flipper</h4>
<ul class="nav-links">
<li><a href="index.html">simple</a></li>
<li><a href="hex.html">hex</a></li>
<li><a href="hsl.html">hsl</a></li>
<li><a href="rgb.html">rgb</a></li>
</ul>
</div>
</nav>
Expand Down
39 changes: 39 additions & 0 deletions 39 1-color-flipper/final/rgb.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Color Flipper || rgb</title>

<!-- styles -->
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<nav>
<div class="nav-center">
<h4>color flipper</h4>
<ul class="nav-links">
<li><a href="index.html">simple</a></li>
<li><a href="hex.html">hex</a></li>
<li><a href="hsl.html">hsl</a></li>
<li><a href="rgb.html">rgb</a></li>
</ul>
</div>
</nav>
<main>
<div class="container">
<h2>
background color :
<span class="color">
#f1f5f8
</span>
</h2>
<div class="container">
<button class="btn btn-hero" id="btn">click me</button>
</div>
</div>
</main>
<!-- javascript -->
<script src="rgb.js"></script>
</body>
</html>
45 changes: 45 additions & 0 deletions 45 1-color-flipper/final/rgb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
rgb(red,green,blue,alpha)
rgb(0 - 255, 0 -255,0 - 255,0 - 1)

*/

// get values for red, green and blue (0-255)
function getValues() {
let value = [];
for (let i = 0; i <= 255; i++) {
value.push(i);
}
return value;
}

// get value for alpha
function getAlphaValues() {
return Math.random().toFixed(2);
}

// get all values in one array of color
const rgb = [getValues()];

const btn = document.getElementById("btn");
const color = document.querySelector(".color");

btn.addEventListener("click", function () {
let rgbColor =
"rgba(" +
rgb[0][getRandomNumber()] +
"," +
rgb[0][getRandomNumber()] +
"," +
rgb[0][getRandomNumber()] +
"," +
getAlphaValues() +
")";

color.textContent = rgbColor;
document.body.style.backgroundColor = rgbColor;
});

function getRandomNumber() {
return Math.floor(Math.random() * rgb[0].length);
}
2 changes: 2 additions & 0 deletions 2 1-color-flipper/setup/hex.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ <h4>color flipper</h4>
<ul class="nav-links">
<li><a href="index.html">simple</a></li>
<li><a href="hex.html">hex</a></li>
<li><a href="hsl.html">hsl</a></li>
<li><a href="rgb.html">rgb</a></li>
</ul>
</div>
</nav>
Expand Down
39 changes: 39 additions & 0 deletions 39 1-color-flipper/setup/hsl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Color Flipper || Hsl</title>

<!-- styles -->
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<nav>
<div class="nav-center">
<h4>color flipper</h4>
<ul class="nav-links">
<li><a href="index.html">simple</a></li>
<li><a href="hex.html">hex</a></li>
<li><a href="hsl.html">hsl</a></li>
<li><a href="rgb.html">rgb</a></li>
</ul>
</div>
</nav>
<main>
<div class="container">
<h2>
background color :
<span class="color">
#f1f5f8
</span>
</h2>
<div class="container">
<button class="btn btn-hero" id="btn">click me</button>
</div>
</div>
</main>
<!-- javascript -->
<script src="hsl.js"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions 31 1-color-flipper/setup/hsl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
hsl(hue,saturation,light,alpha)
hsl(0 - 360, 0 -100%,0 - 100%,0 - 1)

*/

// get value for saturation and light (0-100)
function getValues() {
let value = [];
for (let i = 0; i <= 100; i++) {
value.push(i);
}
return value;
}

//get values for hue (0 - 360)
function getHueValues() {
let value = [];
for (let i = 0; i <= 360; i++) {
value.push(i);
}
return value;
}

// get values for alpha
function getAlphaValues() {
return Math.random().toFixed(2);
}

// get all values in one array of color
const hsl = [getHueValues(), getValues(), getValues(), [getAlphaValues(), 1]];
39 changes: 39 additions & 0 deletions 39 1-color-flipper/setup/rgb.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Color Flipper || rgb</title>

<!-- styles -->
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<nav>
<div class="nav-center">
<h4>color flipper</h4>
<ul class="nav-links">
<li><a href="index.html">simple</a></li>
<li><a href="hex.html">hex</a></li>
<li><a href="hsl.html">hsl</a></li>
<li><a href="rgb.html">rgb</a></li>
</ul>
</div>
</nav>
<main>
<div class="container">
<h2>
background color :
<span class="color">
#f1f5f8
</span>
</h2>
<div class="container">
<button class="btn btn-hero" id="btn">click me</button>
</div>
</div>
</main>
<!-- javascript -->
<script src="rgb.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions 22 1-color-flipper/setup/rgb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
rgb(red,green,blue,alpha)
rgb(0 - 255, 0 -255,0 - 255,0 - 1)

*/

// get values for red, green and blue (0-255)
function getValues() {
let value = [];
for (let i = 0; i <= 255; i++) {
value.push(i);
}
return value;
}

// get value for alpha
function getAlphaValues() {
return Math.random().toFixed(2);
}

// get all values in one array of color
const rgb = [getValues(), getAlphaValues()];
Morty Proxy This is a proxified and sanitized view of the page, visit original site.