๋ฐ์ํ
[์ถ์ฒ-์ ํ๋ธ ๋ ธ๋ง๋ ์ฝ๋ Nomad Coders]
controlํ๊ธฐ ์ํด์ ๋ ๊ฐ์ ๋ฒํผ์ด ํ์ํจ. fill, save.
์ถ๊ฐํ ๋ถ๋ถ โผ
<div class="controls__btns">
<button id="jsMode">Fill</button>
<button id="jsSave">Save</button>
</div>
์ ์ฒด ์ฝ๋ โผ
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="styles.css" />
<title>PaintJS</title>
</head>
<body>
<canvas id="jsCanvas" class="canvas"></canvas>
<div class="controls">
<div class="controls__btns">
<button id="jsMode">Fill</button>
<button id="jsSave">Save</button>
</div>
<div class="controls__colors" id="jsColors">
<div class="controls__color" style="background-color: black;"></div>
<div class="controls__color" style="background-color: white"></div>
<div class="controls__color" style="background-color: #ff3b3c"></div>
<div class="controls__color" style="background-color: #ff9500"></div>
<div class="controls__color" style="background-color: #ffcc00"></div>
<div class="controls__color" style="background-color: #4cd963"></div>
<div class="controls__color" style="background-color: #5ac8fa"></div>
<div class="controls__color" style="background-color: #0579ff"></div>
<div class="controls__color" style="background-color: #5856d6"></div>
</div>
</div>
<script src="app.js"></script>
</body>
</html>
styles.css๋ ์์ ํด์ค๋ค.
@import "reset.css";
body {
background-color: #f6f9fc;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 50px;
}
.canvas {
width: 700px;
height: 700px;
background-color: white;
border-radius: 15px;
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
}
.controls {
margin-top: 80px;
display: flex;
flex-direction: column;
align-items: center;
}
/* ์ถ๊ฐ ์์ ํ ๋ถ๋ถ */
.controls .controls__btns {
margin-bottom: 30px;
}
.controls__btns button {
all: unset;
cursor: pointer;
background-color: white;
padding: 5px 0px;
width: 80px;
text-align: center;
border-radius: 5px;
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
border: 2px solid rgba(0, 0, 0, 0.2);
color: rgba(0, 0, 0, 0.7);
text-transform: uppercase;
font-weight: 800;
font-size: 12px;
}
.controls__btns button:active{
transform: scale(0.98);
}
/* ↑ ์ด๊น์ง ์์ ํ ๋ถ๋ถ! */
.controls .controls__colors {
display: flex;
}
.controls__colors .controls__color {
width: 50px;
height: 50px;
border-radius: 25px;
cursor: pointer;
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
}
์ด์ button ์์ Range input์ ๋ฃ์ ๊ฒ์.
์ถ๊ฐํ ๋ถ๋ถ โผ
<div class="controls__range">
<input type="range" id="jsRange" />
</div>
์ ์ฒด ์ฝ๋ โผ
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="styles.css" />
<title>PaintJS</title>
</head>
<body>
<canvas id="jsCanvas" class="canvas"></canvas>
<div class="controls">
<div class="controls__range">
<input type="range" id="jsRange" />
</div>
<div class="controls__btns">
<button id="jsMode">Fill</button>
<button id="jsSave">Save</button>
</div>
<div class="controls__colors" id="jsColors">
<div class="controls__color" style="background-color: black;"></div>
<div class="controls__color" style="background-color: white"></div>
<div class="controls__color" style="background-color: #ff3b3c"></div>
<div class="controls__color" style="background-color: #ff9500"></div>
<div class="controls__color" style="background-color: #ffcc00"></div>
<div class="controls__color" style="background-color: #4cd963"></div>
<div class="controls__color" style="background-color: #5ac8fa"></div>
<div class="controls__color" style="background-color: #0579ff"></div>
<div class="controls__color" style="background-color: #5856d6"></div>
</div>
</div>
<script src="app.js"></script>
</body>
</html>
styles.css๋ ์์ ํ๋ค.
์ถ๊ฐํ ๋ถ๋ถ โผ
.controls .controls__range {
margin-bottom: 30px;
}
์ ์ฒด ์ฝ๋ โผ
@import "reset.css";
body {
background-color: #f6f9fc;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 50px;
}
.canvas {
width: 700px;
height: 700px;
background-color: white;
border-radius: 15px;
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
}
.controls {
margin-top: 80px;
display: flex;
flex-direction: column;
align-items: center;
}
.controls .controls__btns {
margin-bottom: 30px;
}
.controls__btns button {
all: unset;
cursor: pointer;
background-color: white;
padding: 5px 0px;
width: 80px;
text-align: center;
border-radius: 5px;
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
border: 2px solid rgba(0, 0, 0, 0.2);
color: rgba(0, 0, 0, 0.7);
text-transform: uppercase;
font-weight: 800;
font-size: 12px;
}
.controls__btns button:active{
transform: scale(0.98);
}
.controls .controls__colors {
display: flex;
}
.controls__colors .controls__color {
width: 50px;
height: 50px;
border-radius: 25px;
cursor: pointer;
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
}
.controls .controls__range {
margin-bottom: 30px;
}
์ ์ฉํด๋ณด๋ฉด์ ์์ ํ ๋ถ๋ถ์ index.html์์ ์์ ํด์ค๋ค.
์ถ๊ฐํ ๋ถ๋ถ โผ
<div class="controls__range">
<input type="range" id="jsRange" min="0.1" max="5" value="2.5" step="0.1" />
</div>
์ ์ฒด ์ฝ๋ โผ
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="styles.css" />
<title>PaintJS</title>
</head>
<body>
<canvas id="jsCanvas" class="canvas"></canvas>
<div class="controls">
<div class="controls__range">
<input type="range" id="jsRange" min="0.1" max="5" value="2.5" step="0.1" />
</div>
<div class="controls__btns">
<button id="jsMode">Fill</button>
<button id="jsSave">Save</button>
</div>
<div class="controls__colors" id="jsColors">
<div class="controls__color" style="background-color: black;"></div>
<div class="controls__color" style="background-color: white"></div>
<div class="controls__color" style="background-color: #ff3b3c"></div>
<div class="controls__color" style="background-color: #ff9500"></div>
<div class="controls__color" style="background-color: #ffcc00"></div>
<div class="controls__color" style="background-color: #4cd963"></div>
<div class="controls__color" style="background-color: #5ac8fa"></div>
<div class="controls__color" style="background-color: #0579ff"></div>
<div class="controls__color" style="background-color: #5856d6"></div>
</div>
</div>
<script src="app.js"></script>
</body>
</html>
๋ง์ง๋ง์ผ๋ก styles.css์ body ๋ถ๋ถ์ padding์ ์์ ํด์ค๋ค.
body {
background-color: #f6f9fc;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
padding: 50px 0px;
}
๋๊ผฌ์ค.... ์ฝ๋ฉ์๋๊ฐ ๋๋ฌด ๋นจ๋ผ์... ์ ์๋ ๊ฐ์๋ฅผ ๋ช๋ฒ์ด๊ณ ๋ค์ ๋๋ ค์ ๋ด
๋๋ค ํฌํ
๋ฐ์ํ
'JavaScript > Vanilla JS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐ๋๋ผJS๋ก ๊ทธ๋ฆผํ ๋ง๋ค๊ธฐ] 2D Context (0) | 2021.04.25 |
---|---|
[๋ฐ๋๋ผJS๋ก ๊ทธ๋ฆผํ ๋ง๋ค๊ธฐ] Canvas Events (2) | 2021.04.24 |
[๋ฐ๋๋ผJS๋ก ๊ทธ๋ฆผํ ๋ง๋ค๊ธฐ] Styles part One (0) | 2021.04.23 |
[๋ฐ๋๋ผJS๋ก ๊ทธ๋ฆผํ ๋ง๋ค๊ธฐ] Project Setup (0) | 2021.04.23 |
[๋ฐ๋๋ผJS๋ก ๊ทธ๋ฆผํ ๋ง๋ค๊ธฐ] Requirements (0) | 2021.04.23 |
๋๊ธ