Upload 8 files
Browse files- .gitattributes +1 -0
- 1.png +0 -0
- 2.png +3 -0
- 3.png +0 -0
- 4.png +0 -0
- filter.js +135 -0
- index.html +121 -19
- script.js +1120 -0
- style.css +290 -17
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
2.png filter=lfs diff=lfs merge=lfs -text
|
1.png
ADDED
![]() |
2.png
ADDED
![]() |
Git LFS Details
|
3.png
ADDED
![]() |
4.png
ADDED
![]() |
filter.js
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* ์ด๋ฏธ์ง ํํฐ ๊ธฐ๋ฅ์ ์ํ ์๋ฐ์คํฌ๋ฆฝํธ ํ์ผ
|
3 |
+
* ์ด๋ฏธ์ง ํํฐ ์ ์ฉ, ๊ด๋ฆฌ์ ๊ด๋ จ๋ ๋ชจ๋ ํจ์๋ฅผ ํฌํจ
|
4 |
+
*/
|
5 |
+
|
6 |
+
// ํํฐ ๊ธฐ๋ณธ๊ฐ
|
7 |
+
const DEFAULT_FILTERS = {
|
8 |
+
temperature: 0,
|
9 |
+
brightness: 100,
|
10 |
+
contrast: 100,
|
11 |
+
saturation: 100
|
12 |
+
};
|
13 |
+
|
14 |
+
/**
|
15 |
+
* ์ด๋ฏธ์ง ๋ฐ์ดํฐ์ ํํฐ ์ ์ฉ
|
16 |
+
* @param {ImageData} imageData - ์ด๋ฏธ์ง ๋ฐ์ดํฐ
|
17 |
+
* @param {Object} filters - ํํฐ ์ค์ (temperature, brightness, contrast, saturation)
|
18 |
+
* @returns {ImageData} - ํํฐ๊ฐ ์ ์ฉ๋ ์ด๋ฏธ์ง ๋ฐ์ดํฐ
|
19 |
+
*/
|
20 |
+
function applyFilters(imageData, filters) {
|
21 |
+
const {temperature, brightness, contrast, saturation} = filters;
|
22 |
+
|
23 |
+
const data = imageData.data;
|
24 |
+
|
25 |
+
// ์ด๋ฏธ์ง ๋ฐ์ดํฐ์ ๊ฐ ํฝ์
์ ํํฐ ์ ์ฉ
|
26 |
+
for (let i = 0; i < data.length; i += 4) {
|
27 |
+
// RGB ๊ฐ ์ถ์ถ
|
28 |
+
let r = data[i];
|
29 |
+
let g = data[i + 1];
|
30 |
+
let b = data[i + 2];
|
31 |
+
|
32 |
+
// ์์จ๋ ์ ์ฉ (๋นจ๊ฐ์/ํ๋์ ์กฐ์ )
|
33 |
+
if (temperature !== 0) {
|
34 |
+
const tempValue = temperature / 5; // ํจ๊ณผ ๊ฐ๋ ์กฐ์
|
35 |
+
if (tempValue > 0) {
|
36 |
+
// ๋ฐ๋ปํ ์์กฐ (๋ ๋นจ๊ฐ๊ฒ)
|
37 |
+
r = Math.min(255, r + tempValue);
|
38 |
+
b = Math.max(0, b - tempValue / 2);
|
39 |
+
} else {
|
40 |
+
// ์ฐจ๊ฐ์ด ์์กฐ (๋ ํ๋๊ฒ)
|
41 |
+
r = Math.max(0, r + tempValue);
|
42 |
+
b = Math.min(255, b - tempValue * 1.5);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
// ๋ฐ๊ธฐ ์ ์ฉ (๋ชจ๋ ์์ ์ฑ๋์ ๊ท ์ผํ๊ฒ ์ ์ฉ)
|
47 |
+
const brightnessMultiplier = brightness / 100;
|
48 |
+
r = Math.min(255, r * brightnessMultiplier);
|
49 |
+
g = Math.min(255, g * brightnessMultiplier);
|
50 |
+
b = Math.min(255, b * brightnessMultiplier);
|
51 |
+
|
52 |
+
// ๋๋น ์ ์ฉ
|
53 |
+
const contrastFactor = (contrast / 100);
|
54 |
+
r = Math.min(255, Math.max(0, (r - 128) * contrastFactor + 128));
|
55 |
+
g = Math.min(255, Math.max(0, (g - 128) * contrastFactor + 128));
|
56 |
+
b = Math.min(255, Math.max(0, (b - 128) * contrastFactor + 128));
|
57 |
+
|
58 |
+
// ์ฑ๋ ์ ์ฉ
|
59 |
+
const avg = (r + g + b) / 3;
|
60 |
+
const saturationMultiplier = saturation / 100;
|
61 |
+
r = Math.min(255, Math.max(0, avg + (r - avg) * saturationMultiplier));
|
62 |
+
g = Math.min(255, Math.max(0, avg + (g - avg) * saturationMultiplier));
|
63 |
+
b = Math.min(255, Math.max(0, avg + (b - avg) * saturationMultiplier));
|
64 |
+
|
65 |
+
// ๊ฐ ๋ค์ ์ ์ฅ
|
66 |
+
data[i] = Math.round(r);
|
67 |
+
data[i + 1] = Math.round(g);
|
68 |
+
data[i + 2] = Math.round(b);
|
69 |
+
}
|
70 |
+
|
71 |
+
return imageData;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* ์ด๋ฏธ์ง์ ํํฐ๋ฅผ ์ ์ฉํ์ฌ ์ ์บ๋ฒ์ค์ ๊ทธ๋ฆฌ๊ธฐ
|
76 |
+
* @param {HTMLImageElement} image - ์๋ณธ ์ด๋ฏธ์ง
|
77 |
+
* @param {Object} filters - ํํฐ ์ค์
|
78 |
+
* @returns {HTMLCanvasElement} - ํํฐ๊ฐ ์ ์ฉ๋ ์ด๋ฏธ์ง๊ฐ ๊ทธ๋ ค์ง ์บ๋ฒ์ค
|
79 |
+
*/
|
80 |
+
function createFilteredCanvas(image, filters) {
|
81 |
+
if (!image) return null;
|
82 |
+
|
83 |
+
const tempCanvas = document.createElement('canvas');
|
84 |
+
tempCanvas.width = image.width;
|
85 |
+
tempCanvas.height = image.height;
|
86 |
+
const tempCtx = tempCanvas.getContext('2d');
|
87 |
+
|
88 |
+
// ์๋ณธ ์ด๋ฏธ์ง ๊ทธ๋ฆฌ๊ธฐ
|
89 |
+
tempCtx.drawImage(image, 0, 0);
|
90 |
+
|
91 |
+
// ํํฐ ์ ์ฉ
|
92 |
+
const imageData = tempCtx.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
|
93 |
+
const filteredData = applyFilters(imageData, filters);
|
94 |
+
tempCtx.putImageData(filteredData, 0, 0);
|
95 |
+
|
96 |
+
return tempCanvas;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* ์ ํ๋ ๋ ์ด์ด์๋ง ํํฐ ์ ์ฉ
|
101 |
+
* @param {Array} overlays - ๋ ์ด์ด ๋ฐฐ์ด
|
102 |
+
* @param {number} activeOverlayIndex - ํ์ฌ ํ์ฑ ๋ ์ด์ด ์ธ๋ฑ์ค
|
103 |
+
* @param {Object} filterValues - ์ ์ฉํ ํํฐ ๊ฐ
|
104 |
+
*/
|
105 |
+
function applyFilterToLayer(overlays, activeOverlayIndex, filterValues) {
|
106 |
+
if (activeOverlayIndex >= 0 && activeOverlayIndex < overlays.length) {
|
107 |
+
// ํ์ฌ ์ ํ๋ ๋ ์ด์ด์๋ง ํํฐ ์ ์ฉ
|
108 |
+
overlays[activeOverlayIndex].filters = { ...filterValues };
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* ํํฐ ์ด๊ธฐํ
|
114 |
+
* @param {Array} overlays - ๋ ์ด์ด ๋ฐฐ์ด
|
115 |
+
* @param {number} activeOverlayIndex - ํ์ฌ ํ์ฑ ๋ ์ด์ด ์ธ๋ฑ์ค
|
116 |
+
* @returns {Object} - ์ด๊ธฐํ๋ ํํฐ ๊ฐ
|
117 |
+
*/
|
118 |
+
function resetFilters(overlays, activeOverlayIndex) {
|
119 |
+
// ํ์ฌ ๋ ์ด์ด์ ํํฐ๋ฅผ ์ด๊ธฐํ
|
120 |
+
if (activeOverlayIndex >= 0 && activeOverlayIndex < overlays.length) {
|
121 |
+
overlays[activeOverlayIndex].filters = { ...DEFAULT_FILTERS };
|
122 |
+
}
|
123 |
+
|
124 |
+
// ์ด๊ธฐ ํํฐ ๊ฐ ๋ฐํ
|
125 |
+
return { ...DEFAULT_FILTERS };
|
126 |
+
}
|
127 |
+
|
128 |
+
// filter.js์ ํจ์๋ฅผ ์ธ๋ถ์์ ์ฌ์ฉํ ์ ์๋๋ก ์ ์ญ์ผ๋ก ๋
ธ์ถ
|
129 |
+
window.ImageFilters = {
|
130 |
+
applyFilters,
|
131 |
+
createFilteredCanvas,
|
132 |
+
applyFilterToLayer,
|
133 |
+
resetFilters,
|
134 |
+
DEFAULT_FILTERS
|
135 |
+
};
|
index.html
CHANGED
@@ -1,19 +1,121 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="ko">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>์ด๋ฏธ์ง ๊ฒน์น๊ธฐ ํธ์ง๊ธฐ (์ฌ๋ฌ ์ด๋ฏธ์ง ์ง์)</title>
|
7 |
+
<link rel="stylesheet" href="style.css">
|
8 |
+
</head>
|
9 |
+
<body>
|
10 |
+
<div class="container">
|
11 |
+
<h1>์ด๋ฏธ์ง ๊ฒน์น๊ธฐ ํธ์ง๊ธฐ</h1>
|
12 |
+
<p>๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง ์์ ์ฌ๋ฌ ๊ฐ์ ๋ฐฐ๊ฒฝ ์ ๊ฑฐ๋ ์ด๋ฏธ์ง๋ฅผ ๋ฐฐ์นํ๊ณ ๊ฐ๊ฐ ์กฐ์ ํ ํ, ์กฐ์ ๋ ์ด๋ฏธ์ง๋ค๋ง PNG๋ก ์ถ์ถํฉ๋๋ค.</p>
|
13 |
+
|
14 |
+
<div class="upload-container">
|
15 |
+
<div class="upload-box">
|
16 |
+
<span class="upload-label">1. ์๋ณธ ์ด๋ฏธ์ง ์ ํ</span>
|
17 |
+
<input type="file" id="background-input" class="file-input" accept="image/*">
|
18 |
+
<label for="background-input" class="upload-button">์๋ณธ ์ด๋ฏธ์ง ์
๋ก๋</label>
|
19 |
+
</div>
|
20 |
+
<div class="upload-box">
|
21 |
+
<span class="upload-label">2. ๋ฐฐ๊ฒฝ ์ ๊ฑฐ๋ ์ด๋ฏธ์ง ์ ํ (์ถ์ถ๋ PNG, ์ฌ๋ฌ ๊ฐ ๊ฐ๋ฅ)</span>
|
22 |
+
<input type="file" id="overlay-input" class="file-input" accept="image/*">
|
23 |
+
<label for="overlay-input" class="upload-button">๊ฒน์น ์ด๋ฏธ์ง ์
๋ก๋</label>
|
24 |
+
</div>
|
25 |
+
</div>
|
26 |
+
|
27 |
+
<div class="control-panel">
|
28 |
+
<div class="control-group">
|
29 |
+
<h3>์์น ๋ฐ ํฌ๊ธฐ (์ ํ๋ ์ด๋ฏธ์ง)</h3>
|
30 |
+
<div class="slider-container">
|
31 |
+
<label for="scale-slider">ํฌ๊ธฐ:</label>
|
32 |
+
<input type="range" id="scale-slider" min="10" max="500" value="100" disabled>
|
33 |
+
<span id="scale-value" class="value-display">100%</span>
|
34 |
+
</div>
|
35 |
+
<div class="slider-container">
|
36 |
+
<label for="rotation-slider">ํ์ :</label>
|
37 |
+
<input type="range" id="rotation-slider" min="0" max="360" value="0" disabled>
|
38 |
+
<span id="rotation-value" class="value-display">0ยฐ</span>
|
39 |
+
</div>
|
40 |
+
</div>
|
41 |
+
|
42 |
+
<div class="control-group">
|
43 |
+
<h3>์์ ์ด๋ฏธ์ง ์ ํ</h3>
|
44 |
+
<div id="example-images-container" style="display: flex; justify-content: space-around; margin-top: 15px;">
|
45 |
+
<img src="1.png" alt="Example 1" class="example-img" data-filename="1.png" style="width: 160px; height: 160px; cursor: pointer; border: 1px solid #ccc;">
|
46 |
+
<img src="2.png" alt="Example 2" class="example-img" data-filename="2.png" style="width: 160px; height: 160px; cursor: pointer; border: 1px solid #ccc;">
|
47 |
+
<img src="3.png" alt="Example 3" class="example-img" data-filename="3.png" style="width: 160px; height: 160px; cursor: pointer; border: 1px solid #ccc;">
|
48 |
+
<img src="4.png" alt="Example 4" class="example-img" data-filename="4.png" style="width: 160px; height: 160px; cursor: pointer; border: 1px solid #ccc;">
|
49 |
+
</div>
|
50 |
+
</div>
|
51 |
+
<div class="control-group filter-panel">
|
52 |
+
</div>
|
53 |
+
|
54 |
+
|
55 |
+
<div class="control-group" id="layers-panel">
|
56 |
+
<h3>๋ ์ด์ด ๋ชฉ๋ก</h3>
|
57 |
+
<div class="layer-option">
|
58 |
+
</div>
|
59 |
+
<div id="layers-list" class="layers-list">
|
60 |
+
</div>
|
61 |
+
</div>
|
62 |
+
|
63 |
+
<div class="canvas-container">
|
64 |
+
<canvas id="canvas" width="800" height="600"></canvas>
|
65 |
+
</div>
|
66 |
+
|
67 |
+
<!-- ํํฐ ์ค์ ์น์
์ ์ด๋ฏธ์ง ์๋๋ก ์ด๋ -->
|
68 |
+
<div class="filter-panel">
|
69 |
+
<h3>ํํฐ ์ค์ (์ ํ ๋ ์ด์ด์ ์ ์ฉ)</h3>
|
70 |
+
|
71 |
+
<div class="filter-sliders">
|
72 |
+
<div class="filter-slider-container">
|
73 |
+
<label for="temperature-slider">์์จ๋:</label>
|
74 |
+
<input type="range" id="temperature-slider" min="-100" max="100" value="0" step="5" class="large-slider">
|
75 |
+
<span id="temperature-value" class="value-display">0</span>
|
76 |
+
</div>
|
77 |
+
|
78 |
+
<div class="filter-slider-container">
|
79 |
+
<label for="brightness-slider">๋ฐ๊ธฐ:</label>
|
80 |
+
<input type="range" id="brightness-slider" min="0" max="200" value="100" step="5" class="large-slider">
|
81 |
+
<span id="brightness-value" class="value-display">100%</span>
|
82 |
+
</div>
|
83 |
+
|
84 |
+
<div class="filter-slider-container">
|
85 |
+
<label for="contrast-slider">๋๋น:</label>
|
86 |
+
<input type="range" id="contrast-slider" min="50" max="150" value="100" step="5" class="large-slider">
|
87 |
+
<span id="contrast-value" class="value-display">100%</span>
|
88 |
+
</div>
|
89 |
+
|
90 |
+
<div class="filter-slider-container">
|
91 |
+
<label for="saturation-slider">์ฑ๋:</label>
|
92 |
+
<input type="range" id="saturation-slider" min="0" max="200" value="100" step="5" class="large-slider">
|
93 |
+
<span id="saturation-value" class="value-display">100%</span>
|
94 |
+
</div>
|
95 |
+
</div>
|
96 |
+
|
97 |
+
<div class="filter-buttons">
|
98 |
+
<button id="reset-filter-btn" class="danger-btn">ํํฐ ์ด๊ธฐํ</button>
|
99 |
+
</div>
|
100 |
+
</div>
|
101 |
+
|
102 |
+
<div class="button-container">
|
103 |
+
<button id="generate-btn" class="primary-btn" disabled>์ด๋ฏธ์ง ํฉ์น๊ธฐ</button>
|
104 |
+
<button id="reset-all-btn" class="danger-btn">์ฒ์๋ถํฐ</button>
|
105 |
+
<button id="download-btn" class="info-btn" disabled>๋ค์ด๋ก๋</button>
|
106 |
+
</div>
|
107 |
+
|
108 |
+
<div class="preview-container" id="preview-container">
|
109 |
+
<h3>ํฉ์ฑ๋ ์ด๋ฏธ์ง ๋ฏธ๋ฆฌ๋ณด๊ธฐ</h3>
|
110 |
+
<img id="preview-img" alt="ํฉ์ฑ ์ด๋ฏธ์ง ๋ฏธ๋ฆฌ๋ณด๊ธฐ">
|
111 |
+
</div>
|
112 |
+
|
113 |
+
</div>
|
114 |
+
|
115 |
+
</div>
|
116 |
+
|
117 |
+
<!-- ์คํฌ๋ฆฝํธ ํ์ผ ๋ก๋ -->
|
118 |
+
<script src="filter.js"></script>
|
119 |
+
<script src="script.js"></script>
|
120 |
+
</body>
|
121 |
+
</html>
|
script.js
ADDED
@@ -0,0 +1,1120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* ์ด๋ฏธ์ง ํฉ์ฑ ๋ฐ ํธ์ง ๊ธฐ๋ฅ์ ์ํ ์๋ฐ์คํฌ๋ฆฝํธ ํ์ผ
|
3 |
+
*/
|
4 |
+
|
5 |
+
// ์์ ๊ฐ์ ธ์ค๊ธฐ
|
6 |
+
const backgroundInput = document.getElementById('background-input');
|
7 |
+
const overlayInput = document.getElementById('overlay-input');
|
8 |
+
const canvas = document.getElementById('canvas');
|
9 |
+
const ctx = canvas.getContext('2d');
|
10 |
+
|
11 |
+
const scaleSlider = document.getElementById('scale-slider');
|
12 |
+
const scaleValue = document.getElementById('scale-value');
|
13 |
+
const rotationSlider = document.getElementById('rotation-slider');
|
14 |
+
const rotationValue = document.getElementById('rotation-value');
|
15 |
+
|
16 |
+
// ํํฐ ๊ด๋ จ ์์
|
17 |
+
const temperatureSlider = document.getElementById('temperature-slider');
|
18 |
+
const temperatureValue = document.getElementById('temperature-value');
|
19 |
+
const brightnessSlider = document.getElementById('brightness-slider');
|
20 |
+
const brightnessValue = document.getElementById('brightness-value');
|
21 |
+
const contrastSlider = document.getElementById('contrast-slider');
|
22 |
+
const contrastValue = document.getElementById('contrast-value');
|
23 |
+
const saturationSlider = document.getElementById('saturation-slider');
|
24 |
+
const saturationValue = document.getElementById('saturation-value');
|
25 |
+
const resetFilterBtn = document.getElementById('reset-filter-btn');
|
26 |
+
|
27 |
+
const generateBtn = document.getElementById('generate-btn');
|
28 |
+
const resetAllBtn = document.getElementById('reset-all-btn');
|
29 |
+
const downloadBtn = document.getElementById('download-btn');
|
30 |
+
|
31 |
+
const previewContainer = document.getElementById('preview-container');
|
32 |
+
const previewImg = document.getElementById('preview-img');
|
33 |
+
|
34 |
+
const layersList = document.getElementById('layers-list');
|
35 |
+
|
36 |
+
|
37 |
+
// ์บ๋ฒ์ค ๊ธฐ๋ณธ ํฌ๊ธฐ
|
38 |
+
const CANVAS_WIDTH = 800;
|
39 |
+
const CANVAS_HEIGHT = 600;
|
40 |
+
canvas.width = CANVAS_WIDTH;
|
41 |
+
canvas.height = CANVAS_HEIGHT;
|
42 |
+
|
43 |
+
// ์ ์ญ ๋ณ์
|
44 |
+
let backgroundImage = null;
|
45 |
+
let originalFormat = 'png'; // ๊ธฐ๋ณธ ํฌ๋งท์ PNG๋ก ์ค์
|
46 |
+
let canvasAdjustedHeight = CANVAS_HEIGHT; // ์ด๋ฏธ์ง ๋น์จ์ ๋ง๊ฒ ์กฐ์ ๋ ์บ๋ฒ์ค ๋์ด
|
47 |
+
|
48 |
+
// ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง ๊ทธ๋ฆฌ๊ธฐ ์์ฑ
|
49 |
+
let bgDrawProps = { x: 0, y: 0, width: CANVAS_WIDTH, height: CANVAS_HEIGHT };
|
50 |
+
|
51 |
+
// ์ฌ๋ฌ ๊ฐ์ ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง์ ๊ทธ ์์ฑ์ ์ ์ฅํ ๋ฐฐ์ด
|
52 |
+
let overlays = [];
|
53 |
+
// ํ์ฌ ์กฐ์ ์ค์ธ ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง์ ์ธ๋ฑ์ค (-1์ด๋ฉด ์ ํ๋์ง ์์)
|
54 |
+
let activeOverlayIndex = -1;
|
55 |
+
|
56 |
+
// ๋ง์ฐ์ค/ํฐ์น ์กฐ์ ๊ด๋ จ ์ํ
|
57 |
+
let isDragging = false;
|
58 |
+
let isRotating = false;
|
59 |
+
let isResizing = false;
|
60 |
+
let activeHandle = null;
|
61 |
+
|
62 |
+
// ์ด์ ๋ง์ฐ์ค/ํฐ์น ์ขํ
|
63 |
+
let lastX = 0;
|
64 |
+
let lastY = 0;
|
65 |
+
|
66 |
+
// ๋ฆฌ์ฌ์ด์ฆ ์์ ์ ํธ๋ค๊น์ง์ ๊ฑฐ๋ฆฌ (๋น๋ก ์ค์ผ์ผ๋ง์ ์ฌ์ฉ)
|
67 |
+
let resizeStartDistance = 0;
|
68 |
+
|
69 |
+
// ํธ๋ค ์ค์
|
70 |
+
const handleSize = 15;
|
71 |
+
const rotateHandleDistance = 30;
|
72 |
+
|
73 |
+
// ํด๋ฆญ ๊ฐ์ง ์ ์ฌ์ ๊ณต๊ฐ
|
74 |
+
const clickPadding = 5;
|
75 |
+
|
76 |
+
// ์บ๋ฒ์ค ์ด๊ธฐํ (ํฐ์ ๋ฐฐ๊ฒฝ)
|
77 |
+
function initCanvas() {
|
78 |
+
ctx.fillStyle = '#ffffff';
|
79 |
+
ctx.fillRect(0, 0, CANVAS_WIDTH, canvasAdjustedHeight);
|
80 |
+
updateLayersList();
|
81 |
+
}
|
82 |
+
|
83 |
+
function cropTransparentPixels(imageElement, alphaThreshold = 0) {
|
84 |
+
const tempCanvas = document.createElement('canvas');
|
85 |
+
tempCanvas.width = imageElement.naturalWidth || imageElement.width;
|
86 |
+
tempCanvas.height = imageElement.naturalHeight || imageElement.height;
|
87 |
+
const tempCtx = tempCanvas.getContext('2d');
|
88 |
+
tempCtx.drawImage(imageElement, 0, 0);
|
89 |
+
|
90 |
+
let imageData;
|
91 |
+
try {
|
92 |
+
imageData = tempCtx.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
|
93 |
+
} catch (e) {
|
94 |
+
console.error("Error getting ImageData (possibly due to CORS):", e);
|
95 |
+
// CORS ์ค๋ฅ ๋ฐ์ ์, ๋ณด์ ์ ์ฝ ์์ด ์ด๋ฏธ์ง ์ ์ฒด๋ฅผ ์ฌ์ฉํ๋ ๋์ฒด ๋ก์ง (๋ฐฐ๊ฒฝ ์ ๊ฑฐ ํจ๊ณผ๋ ์์ ์ ์์)
|
96 |
+
const fallbackCanvas = document.createElement('canvas');
|
97 |
+
fallbackCanvas.width = tempCanvas.width;
|
98 |
+
fallbackCanvas.height = tempCanvas.height;
|
99 |
+
const fallbackCtx = fallbackCanvas.getContext('2d');
|
100 |
+
fallbackCtx.drawImage(imageElement, 0, 0);
|
101 |
+
return fallbackCanvas;
|
102 |
+
}
|
103 |
+
|
104 |
+
const data = imageData.data;
|
105 |
+
let minX = tempCanvas.width, minY = tempCanvas.height, maxX = 0, maxY = 0;
|
106 |
+
let foundContent = false;
|
107 |
+
|
108 |
+
for (let y = 0; y < tempCanvas.height; y++) {
|
109 |
+
for (let x = 0; x < tempCanvas.width; x++) {
|
110 |
+
const alpha = data[(y * tempCanvas.width + x) * 4 + 3];
|
111 |
+
if (alpha > alphaThreshold) {
|
112 |
+
minX = Math.min(minX, x);
|
113 |
+
minY = Math.min(minY, y);
|
114 |
+
maxX = Math.max(maxX, x);
|
115 |
+
maxY = Math.max(maxY, y);
|
116 |
+
foundContent = true;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
if (!foundContent) {
|
122 |
+
// ๋ด์ฉ์ด ์๋ ๊ฒฝ์ฐ (์์ ํ ํฌ๋ช
ํ๊ฑฐ๋ ์ค๋ฅ)
|
123 |
+
const emptyCanvas = document.createElement('canvas');
|
124 |
+
emptyCanvas.width = imageElement.naturalWidth || 1;
|
125 |
+
emptyCanvas.height = imageElement.naturalHeight || 1;
|
126 |
+
return emptyCanvas;
|
127 |
+
}
|
128 |
+
|
129 |
+
const cropWidth = maxX - minX + 1;
|
130 |
+
const cropHeight = maxY - minY + 1;
|
131 |
+
|
132 |
+
const croppedCanvas = document.createElement('canvas');
|
133 |
+
croppedCanvas.width = cropWidth;
|
134 |
+
croppedCanvas.height = cropHeight;
|
135 |
+
const croppedCtx = croppedCanvas.getContext('2d');
|
136 |
+
|
137 |
+
// ์๋ผ๋ธ ์์ญ๋ง ์ ์บ๋ฒ์ค์ ๊ทธ๋ฆฝ๋๋ค.
|
138 |
+
croppedCtx.drawImage(tempCanvas, minX, minY, cropWidth, cropHeight, 0, 0, cropWidth, cropHeight);
|
139 |
+
|
140 |
+
return croppedCanvas;
|
141 |
+
}
|
142 |
+
|
143 |
+
// ํ์ผ ๋๋ Blob ๊ฐ์ฒด๋ฅผ ๋ฐ์ ์ด๋ฏธ์ง๋ฅผ ๋ก๋ํ๊ณ ์บ๋ฒ์ค์ ์ถ๊ฐํ๋ ํจ์
|
144 |
+
function loadImage(fileOrBlob, type) {
|
145 |
+
if (!fileOrBlob) return;
|
146 |
+
|
147 |
+
let fileExtension = 'png'; // ๊ธฐ๋ณธ๊ฐ
|
148 |
+
let isBlob = fileOrBlob instanceof Blob;
|
149 |
+
let fileName = 'unknown';
|
150 |
+
|
151 |
+
if (!isBlob && fileOrBlob.name) {
|
152 |
+
fileExtension = fileOrBlob.name.split('.').pop().toLowerCase();
|
153 |
+
fileName = fileOrBlob.name;
|
154 |
+
} else if (isBlob && fileOrBlob.type) {
|
155 |
+
fileExtension = fileOrBlob.type.split('/')[1] ? fileOrBlob.type.split('/')[1].toLowerCase() : 'png';
|
156 |
+
fileName = 'processed_image.' + fileExtension; // Blob์ ๊ฒฝ์ฐ ํ์ผ ์ด๋ฆ ์์ ์ง์
|
157 |
+
}
|
158 |
+
|
159 |
+
|
160 |
+
if (type === 'background' && !isBlob && ['jpg', 'jpeg', 'png', 'gif', 'webp'].includes(fileExtension)) {
|
161 |
+
originalFormat = fileExtension;
|
162 |
+
}
|
163 |
+
|
164 |
+
const reader = new FileReader();
|
165 |
+
reader.onload = function(event) {
|
166 |
+
const img = new Image();
|
167 |
+
img.onload = function() {
|
168 |
+
if (type === 'background') {
|
169 |
+
backgroundImage = img;
|
170 |
+
const aspectRatio = img.width / img.height;
|
171 |
+
bgDrawProps.width = CANVAS_WIDTH;
|
172 |
+
bgDrawProps.height = CANVAS_WIDTH / aspectRatio;
|
173 |
+
bgDrawProps.x = 0;
|
174 |
+
bgDrawProps.y = 0;
|
175 |
+
canvasAdjustedHeight = bgDrawProps.height;
|
176 |
+
canvas.height = canvasAdjustedHeight;
|
177 |
+
canvas.style.height = 'auto'; // ์บ๋ฒ์ค wrapper๊ฐ ์๋ canvas ์์ฒด์ style
|
178 |
+
} else if (type === 'overlay') {
|
179 |
+
let imageToUse = img;
|
180 |
+
|
181 |
+
// PNG ๋๋ ํฌ๋ช
๋๊ฐ ์๋ ์ด๋ฏธ์ง ํ์์ ๊ฒฝ์ฐ์๋ง ํฌ๋ช
ํฝ์
์๋ฅด๊ธฐ ์๋
|
182 |
+
// ์์ ์ด๋ฏธ์ง๋ ๋ฐฐ๊ฒฝ ์ ๊ฑฐ๊ฐ ์๋ฃ๋ ์ด๋ฏธ์ง๋ผ๊ณ ๊ฐ์ ํ๊ฑฐ๋,
|
183 |
+
// ์ฌ๊ธฐ์์ cropTransparentPixels๋ฅผ ์ ์ฉํฉ๋๋ค.
|
184 |
+
// ์ค์ ๋ณต์กํ ๋ฐฐ๊ฒฝ ์ ๊ฑฐ ๋ก์ง์ ์ด ๋ถ๋ถ์ด ์๋ ๋ณ๋์ ํจ์์์ ๊ตฌํ๋์ด์ผ ํฉ๋๋ค.
|
185 |
+
if (fileExtension === 'png' || fileExtension === 'webp' || fileExtension === 'gif' || (isBlob && fileOrBlob.type === 'image/png')) {
|
186 |
+
try {
|
187 |
+
// cropTransparentPixels๋ ํฌ๋ช
์์ญ์ ์๋ฅด๋ ๊ธฐ๋ฅ์
๋๋ค.
|
188 |
+
// ๋ง์ฝ ์์ ์ด๋ฏธ์ง๊ฐ ์ด๋ฏธ ๋ฐฐ๊ฒฝ ์ ๊ฑฐ๋ ์ด๋ฏธ์ง๋ผ๋ฉด ์ด ํจ์๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
|
189 |
+
// ์ผ๋ฐ ์ด๋ฏธ์ง์ ๋ฐฐ๊ฒฝ์ ์ ๊ฑฐํ๋ ค๋ฉด ๋ค๋ฅธ ์๊ณ ๋ฆฌ์ฆ์ด ํ์ํฉ๋๋ค.
|
190 |
+
const croppedImageCanvas = cropTransparentPixels(img);
|
191 |
+
if (croppedImageCanvas.width > 0 && croppedImageCanvas.height > 0) {
|
192 |
+
imageToUse = croppedImageCanvas;
|
193 |
+
} else {
|
194 |
+
// ์๋ผ๋ผ ์์ญ์ด ์์ผ๋ฉด ์๋ณธ ์ฌ์ฉ ๋๋ ๋น ์ด๋ฏธ์ง ์ฒ๋ฆฌ
|
195 |
+
console.warn("No non-transparent pixels found, using original or empty.");
|
196 |
+
// imageToUse = img; // ์๋ณธ ์ด๋ฏธ์ง ์ฌ์ฉ
|
197 |
+
const emptyCanvas = document.createElement('canvas');
|
198 |
+
emptyCanvas.width = img.naturalWidth || 1;
|
199 |
+
emptyCanvas.height = img.naturalHeight || 1;
|
200 |
+
imageToUse = emptyCanvas; // ๋๋ ๋น ์บ๋ฒ์ค ์ฌ์ฉ
|
201 |
+
}
|
202 |
+
} catch (e) {
|
203 |
+
console.error("Error during image cropping/processing, using original:", e);
|
204 |
+
imageToUse = img; // ์ค๋ฅ ๋ฐ์ ์ ์๋ณธ ์ฌ์ฉ
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
|
209 |
+
const newOverlay = {
|
210 |
+
image: imageToUse,
|
211 |
+
// ์บ๋ฒ์ค ์ค์์ ๋ฐฐ์น
|
212 |
+
x: CANVAS_WIDTH / 2,
|
213 |
+
y: canvasAdjustedHeight / 2,
|
214 |
+
scale: 1,
|
215 |
+
rotation: 0,
|
216 |
+
filters: { ...ImageFilters.DEFAULT_FILTERS }
|
217 |
+
};
|
218 |
+
|
219 |
+
// ์ด๋ฏธ์ง๊ฐ ์บ๋ฒ์ค๋ณด๋ค ํฌ๋ฉด ์ด๊ธฐ ์ค์ผ์ผ ์กฐ์
|
220 |
+
const initialScaleRatio = Math.min(CANVAS_WIDTH / newOverlay.image.width, canvasAdjustedHeight / newOverlay.image.height);
|
221 |
+
if (initialScaleRatio < 1) {
|
222 |
+
newOverlay.scale = initialScaleRatio * 0.9; // ์ฝ๊ฐ ๋ ์๊ฒ ์์
|
223 |
+
}
|
224 |
+
|
225 |
+
overlays.push(newOverlay);
|
226 |
+
activeOverlayIndex = overlays.length - 1; // ์๋ก ์ถ๊ฐ๋ ๋ ์ด์ด๋ฅผ ํ์ฑํ
|
227 |
+
updateControlPanel();
|
228 |
+
updateLayersList();
|
229 |
+
}
|
230 |
+
drawCanvas();
|
231 |
+
};
|
232 |
+
img.onerror = function() {
|
233 |
+
console.error("Error loading image from reader result for:", fileName);
|
234 |
+
alert("์ด๋ฏธ์ง๋ฅผ ๋ก๋ํ๋ ๋ฐ ์คํจํ์ต๋๋ค. ํ์ผ์ด ์ ํจํ์ง ํ์ธํด์ฃผ์ธ์.");
|
235 |
+
};
|
236 |
+
img.src = event.target.result;
|
237 |
+
};
|
238 |
+
reader.readAsDataURL(fileOrBlob); // File ๋๋ Blob์์ Data URL ์ฝ๊ธฐ
|
239 |
+
}
|
240 |
+
|
241 |
+
|
242 |
+
function updateControlPanel() {
|
243 |
+
const isActive = activeOverlayIndex >= 0;
|
244 |
+
const activeOverlay = isActive ? overlays[activeOverlayIndex] : null;
|
245 |
+
|
246 |
+
// ์ค๋ฒ๋ ์ด๊ฐ ์ ํ๋์ง ์์์ ๋ ์ปจํธ๋กค ๋นํ์ฑํ
|
247 |
+
scaleSlider.disabled = !isActive;
|
248 |
+
rotationSlider.disabled = !isActive;
|
249 |
+
temperatureSlider.disabled = !isActive;
|
250 |
+
brightnessSlider.disabled = !isActive;
|
251 |
+
contrastSlider.disabled = !isActive;
|
252 |
+
saturationSlider.disabled = !isActive;
|
253 |
+
resetFilterBtn.disabled = !isActive;
|
254 |
+
|
255 |
+
|
256 |
+
if (isActive) {
|
257 |
+
scaleSlider.value = Math.round(activeOverlay.scale * 100);
|
258 |
+
scaleValue.textContent = scaleSlider.value + '%';
|
259 |
+
rotationSlider.value = Math.round(activeOverlay.rotation);
|
260 |
+
rotationValue.textContent = rotationSlider.value + 'ยฐ';
|
261 |
+
|
262 |
+
temperatureSlider.value = activeOverlay.filters.temperature;
|
263 |
+
temperatureValue.textContent = activeOverlay.filters.temperature;
|
264 |
+
brightnessSlider.value = activeOverlay.filters.brightness;
|
265 |
+
brightnessValue.textContent = activeOverlay.filters.brightness + '%';
|
266 |
+
contrastSlider.value = activeOverlay.filters.contrast;
|
267 |
+
contrastValue.textContent = activeOverlay.filters.contrast + '%';
|
268 |
+
saturationSlider.value = activeOverlay.filters.saturation;
|
269 |
+
saturationValue.textContent = activeOverlay.filters.saturation + '%';
|
270 |
+
} else {
|
271 |
+
// ์ค๋ฒ๋ ์ด๊ฐ ์ ํ๋์ง ์์ผ๋ฉด ๊ธฐ๋ณธ๊ฐ์ผ๋ก ํ์
|
272 |
+
scaleSlider.value = 100;
|
273 |
+
scaleValue.textContent = '100%';
|
274 |
+
rotationSlider.value = 0;
|
275 |
+
rotationValue.textContent = '0ยฐ';
|
276 |
+
|
277 |
+
temperatureSlider.value = 0;
|
278 |
+
temperatureValue.textContent = '0';
|
279 |
+
brightnessSlider.value = 100;
|
280 |
+
brightnessValue.textContent = '100%';
|
281 |
+
contrastSlider.value = 100;
|
282 |
+
contrastValue.textContent = '100%';
|
283 |
+
saturationSlider.value = 100;
|
284 |
+
saturationValue.textContent = '100%';
|
285 |
+
}
|
286 |
+
|
287 |
+
// ์ค๋ฒ๋ ์ด๊ฐ ํ๋๋ผ๋ ์์ ๋๋ง ์์ฑ/๋ค์ด๋ก๋ ๋ฒํผ ํ์ฑํ
|
288 |
+
generateBtn.disabled = overlays.length === 0;
|
289 |
+
downloadBtn.disabled = overlays.length === 0;
|
290 |
+
|
291 |
+
// ์ค๋ฒ๋ ์ด๊ฐ ์์ผ๋ฉด ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์์ญ ์จ๊น
|
292 |
+
if (overlays.length === 0) {
|
293 |
+
previewContainer.style.display = 'none';
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
function updateLayersList() {
|
298 |
+
if (!layersList) return; // layersList ์์๊ฐ ์์ผ๋ฉด ํจ์ ์ข
๋ฃ
|
299 |
+
layersList.innerHTML = ''; // ๋ชฉ๋ก ์ด๊ธฐํ
|
300 |
+
|
301 |
+
if (overlays.length === 0) {
|
302 |
+
const emptyMsg = document.createElement('div');
|
303 |
+
emptyMsg.style.padding = '8px';
|
304 |
+
emptyMsg.style.textAlign = 'center';
|
305 |
+
emptyMsg.style.color = '#777';
|
306 |
+
emptyMsg.textContent = '๋ ์ด์ด๊ฐ ์์ต๋๋ค';
|
307 |
+
layersList.appendChild(emptyMsg);
|
308 |
+
return;
|
309 |
+
}
|
310 |
+
|
311 |
+
// ๋ ์ด์ด ๋ชฉ๋ก์ ์ญ์์ผ๋ก ํ์ (๊ฐ์ฅ ์์ ์๋ ๋ ์ด์ด๊ฐ ๋ชฉ๋ก์ ์๋์ ์ค๋๋ก)
|
312 |
+
for (let i = overlays.length - 1; i >= 0; i--) {
|
313 |
+
const layerItem = document.createElement('div');
|
314 |
+
layerItem.className = 'layer-item';
|
315 |
+
if (i === activeOverlayIndex) {
|
316 |
+
layerItem.classList.add('active'); // ํ์ฑ ๋ ์ด์ด ํ์
|
317 |
+
}
|
318 |
+
|
319 |
+
const layerName = document.createElement('span');
|
320 |
+
layerName.className = 'layer-name';
|
321 |
+
layerName.textContent = `๋ ์ด์ด ${i + 1}`; // ๋ ์ด์ด ๋ฒํธ ํ์ (1๋ถํฐ ์์)
|
322 |
+
|
323 |
+
const layerControls = document.createElement('div');
|
324 |
+
layerControls.className = 'layer-controls';
|
325 |
+
|
326 |
+
// ์๋ก ์ด๋ ๋ฒํผ (๋งจ ์ ๋ ์ด์ด ์ ์ธ)
|
327 |
+
if (i < overlays.length - 1) {
|
328 |
+
const upButton = document.createElement('button');
|
329 |
+
upButton.className = 'layer-button';
|
330 |
+
upButton.textContent = 'โ';
|
331 |
+
upButton.title = '์๋ก ์ด๋';
|
332 |
+
upButton.addEventListener('click', (e) => { e.stopPropagation(); moveLayerUp(i); }); // ์ด๋ฒคํธ ๋ฒ๋ธ๋ง ๋ฐฉ์ง
|
333 |
+
layerControls.appendChild(upButton);
|
334 |
+
}
|
335 |
+
|
336 |
+
// ์๋๋ก ์ด๋ ๋ฒํผ (๋งจ ์๋ ๋ ์ด์ด ์ ์ธ)
|
337 |
+
if (i > 0) {
|
338 |
+
const downButton = document.createElement('button');
|
339 |
+
downButton.className = 'layer-button';
|
340 |
+
downButton.textContent = 'โ';
|
341 |
+
downButton.title = '์๋๋ก ์ด๋';
|
342 |
+
downButton.addEventListener('click', (e) => { e.stopPropagation(); moveLayerDown(i); }); // ์ด๋ฒคํธ ๋ฒ๋ธ๋ง ๋ฐฉ์ง
|
343 |
+
layerControls.appendChild(downButton);
|
344 |
+
}
|
345 |
+
|
346 |
+
|
347 |
+
// ๋ ์ด์ด ํญ๋ชฉ ํด๋ฆญ ์ ํด๋น ๋ ์ด์ด ํ์ฑํ
|
348 |
+
layerItem.addEventListener('click', function() {
|
349 |
+
activeOverlayIndex = i;
|
350 |
+
updateControlPanel(); // ์ปจํธ๋กค ํจ๋ ์
๋ฐ์ดํธ
|
351 |
+
updateLayersList(); // ๋ ์ด์ด ๋ชฉ๋ก ์๊ฐ์ ์
๋ฐ์ดํธ
|
352 |
+
drawCanvas(); // ์บ๋ฒ์ค ๋ค์ ๊ทธ๋ฆฌ๊ธฐ (ํ์ฑ ๋ ์ด์ด ํธ๋ค ํ์)
|
353 |
+
});
|
354 |
+
|
355 |
+
layerItem.appendChild(layerName);
|
356 |
+
layerItem.appendChild(layerControls);
|
357 |
+
|
358 |
+
layersList.appendChild(layerItem);
|
359 |
+
}
|
360 |
+
}
|
361 |
+
|
362 |
+
// ๋ ์ด์ด ์๋ก ์ด๋
|
363 |
+
function moveLayerUp(index) {
|
364 |
+
if (index < overlays.length - 1) {
|
365 |
+
// ํ์ฌ ๋ ์ด์ด์ ๋ฐ๋ก ์ ๋ ์ด์ด์ ์์น๋ฅผ ๋ฐ๊ฟ๋๋ค.
|
366 |
+
const temp = overlays[index];
|
367 |
+
overlays[index] = overlays[index + 1];
|
368 |
+
overlays[index + 1] = temp;
|
369 |
+
|
370 |
+
// ํ์ฑ ๋ ์ด์ด์ ์ธ๋ฑ์ค๋ ์กฐ์ ํฉ๋๋ค.
|
371 |
+
if (activeOverlayIndex === index) activeOverlayIndex = index + 1;
|
372 |
+
else if (activeOverlayIndex === index + 1) activeOverlayIndex = index;
|
373 |
+
|
374 |
+
updateLayersList(); // ๋ชฉ๋ก ์
๋ฐ์ดํธ
|
375 |
+
drawCanvas(); // ์บ๋ฒ์ค ๋ค์ ๊ทธ๋ฆฌ๊ธฐ
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
// ๋ ์ด์ด ์๋๋ก ์ด๋
|
380 |
+
function moveLayerDown(index) {
|
381 |
+
if (index > 0) {
|
382 |
+
// ํ์ฌ ๋ ์ด์ด์ ๋ฐ๋ก ์๋ ๋ ์ด์ด์ ์์น๋ฅผ ๋ฐ๊ฟ๋๋ค.
|
383 |
+
const temp = overlays[index];
|
384 |
+
overlays[index] = overlays[index - 1];
|
385 |
+
overlays[index - 1] = temp;
|
386 |
+
|
387 |
+
// ํ์ฑ ๋ ์ด์ด์ ์ธ๋ฑ์ค๋ ์กฐ์ ํฉ๋๋ค.
|
388 |
+
if (activeOverlayIndex === index) activeOverlayIndex = index - 1;
|
389 |
+
else if (activeOverlayIndex === index - 1) activeOverlayIndex = index;
|
390 |
+
|
391 |
+
|
392 |
+
updateLayersList(); // ๋ชฉ๋ก ์
๋ฐ์ดํธ
|
393 |
+
drawCanvas(); // ์บ๋ฒ์ค ๋ค์ ๊ทธ๋ฆฌ๊ธฐ
|
394 |
+
}
|
395 |
+
}
|
396 |
+
|
397 |
+
|
398 |
+
function drawCanvas() {
|
399 |
+
// ์บ๋ฒ์ค ์ ์ฒด ์ง์ฐ๊ธฐ
|
400 |
+
ctx.clearRect(0, 0, CANVAS_WIDTH, canvasAdjustedHeight);
|
401 |
+
|
402 |
+
// ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง ๊ทธ๋ฆฌ๊ธฐ (์๋ค๋ฉด)
|
403 |
+
if (backgroundImage) {
|
404 |
+
ctx.drawImage(backgroundImage, 0, 0, backgroundImage.width, backgroundImage.height, bgDrawProps.x, bgDrawProps.y, bgDrawProps.width, bgDrawProps.height);
|
405 |
+
} else {
|
406 |
+
// ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง๊ฐ ์์ผ๋ฉด ํฐ์ ๋ฐฐ๊ฒฝ ์ฑ์ฐ๊ธฐ
|
407 |
+
ctx.fillStyle = '#ffffff';
|
408 |
+
ctx.fillRect(0, 0, CANVAS_WIDTH, canvasAdjustedHeight);
|
409 |
+
}
|
410 |
+
|
411 |
+
// ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง๋ค ๊ทธ๋ฆฌ๊ธฐ (๋ ์ด์ด ์์๋๋ก)
|
412 |
+
overlays.forEach((overlay, index) => {
|
413 |
+
// ์ด๋ฏธ์ง๊ฐ ์ ํจํ์ง ์์ผ๋ฉด ๊ฑด๋๋๋๋ค.
|
414 |
+
if (!overlay.image || overlay.image.width === 0 || overlay.image.height === 0) return;
|
415 |
+
|
416 |
+
// ํํฐ ์ ์ฉ๋ ์ด๋ฏธ์ง ์บ๋ฒ์ค ์์ฑ (filter.js์ ํจ์ ์ฌ์ฉ)
|
417 |
+
const filteredCanvas = ImageFilters.createFilteredCanvas(overlay.image, overlay.filters);
|
418 |
+
|
419 |
+
|
420 |
+
ctx.save(); // ํ์ฌ ์บ๋ฒ์ค ์ํ ์ ์ฅ
|
421 |
+
|
422 |
+
// ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง์ ์ค์ฌ์ ๊ธฐ์ค์ผ๋ก ๋ณํ ์ ์ฉ
|
423 |
+
ctx.translate(overlay.x, overlay.y); // ์์น ์ด๋
|
424 |
+
ctx.rotate(overlay.rotation * Math.PI / 180); // ํ์ (๋ผ๋์์ผ๋ก ๋ณํ)
|
425 |
+
ctx.scale(overlay.scale, overlay.scale); // ํฌ๊ธฐ ์กฐ์
|
426 |
+
|
427 |
+
// ์ด๋ฏธ์ง๋ฅผ ์ค์ฌ ๊ธฐ์ค์ผ๋ก ๊ทธ๋ฆฝ๋๋ค. (translate์์ ์ด๋ํ์ผ๋ฏ๋ก -width/2, -height/2)
|
428 |
+
ctx.drawImage(filteredCanvas, -overlay.image.width / 2, -overlay.image.height / 2);
|
429 |
+
|
430 |
+
ctx.restore(); // ์ด์ ์บ๋ฒ์ค ์ํ ๋ณต์ (๋ณํ ์ํ ์ด๊ธฐํ)
|
431 |
+
|
432 |
+
// ํ์ฌ ํ์ฑ ๋ ์ด์ด์๋ง ๋ณํ ํธ๋ค ๊ทธ๋ฆฌ๊ธฐ
|
433 |
+
if (index === activeOverlayIndex) {
|
434 |
+
drawTransformHandles(overlay);
|
435 |
+
}
|
436 |
+
});
|
437 |
+
}
|
438 |
+
|
439 |
+
// ๋ณํ ํธ๋ค ๊ทธ๋ฆฌ๊ธฐ
|
440 |
+
function drawTransformHandles(activeOverlay) {
|
441 |
+
// ํ์ฑ ์ค๋ฒ๋ ์ด๋ ์ด๋ฏธ์ง๊ฐ ์ ํจํ์ง ์์ผ๋ฉด ๊ทธ๋ฆฌ์ง ์์ต๋๋ค.
|
442 |
+
if (!activeOverlay || !activeOverlay.image || activeOverlay.image.width === 0 || activeOverlay.image.height === 0) return;
|
443 |
+
|
444 |
+
const currentWidth = activeOverlay.image.width * activeOverlay.scale;
|
445 |
+
const currentHeight = activeOverlay.image.height * activeOverlay.scale;
|
446 |
+
const halfWidth = currentWidth / 2;
|
447 |
+
const halfHeight = currentHeight / 2;
|
448 |
+
|
449 |
+
const angle = activeOverlay.rotation * Math.PI / 180; // ํ์ฌ ํ์ ๊ฐ๋ (๋ผ๋์)
|
450 |
+
|
451 |
+
// ์ฝ๋ ํธ๋ค ์์น (ํ์ ๋์ง ์์ ์ํ ๊ธฐ์ค)
|
452 |
+
const handles = {
|
453 |
+
'tl': { x: -halfWidth, y: -halfHeight, cursor: 'nwse-resize' }, // Top-Left
|
454 |
+
'tr': { x: halfWidth, y: -halfHeight, cursor: 'nesw-resize' }, // Top-Right
|
455 |
+
'br': { x: halfWidth, y: halfHeight, cursor: 'nwse-resize' }, // Bottom-Right
|
456 |
+
'bl': { x: -halfWidth, y: halfHeight, cursor: 'nesw-resize' } // Bottom-Left
|
457 |
+
};
|
458 |
+
|
459 |
+
// ํ์ ํธ๋ค ์์น (์ด๋ฏธ์ง ์๋จ ์ค์์์ ํ์ ๊ฑฐ๋ฆฌ๋งํผ ๋จ์ด์ง ์์น)
|
460 |
+
const rotateHandlePos = { x: 0, y: -halfHeight - rotateHandleDistance };
|
461 |
+
|
462 |
+
|
463 |
+
ctx.save(); // ํ์ฌ ์บ๋ฒ์ค ์ํ ์ ์ฅ
|
464 |
+
|
465 |
+
// ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง์ ์ค์ฌ ์์น๋ก ์ด๋ ํ ํ์
|
466 |
+
ctx.translate(activeOverlay.x, activeOverlay.y);
|
467 |
+
ctx.rotate(angle);
|
468 |
+
|
469 |
+
// ์ฝ๋ ํธ๋ค ๊ทธ๋ฆฌ๊ธฐ
|
470 |
+
const cornerHandleColor = '#e74c3c'; // ๋นจ๊ฐ์
|
471 |
+
for (const [, handle] of Object.entries(handles)) {
|
472 |
+
ctx.beginPath();
|
473 |
+
// ํธ๋ค ์์น์ ์ฌ๊ฐํ ๊ทธ๋ฆฌ๊ธฐ (ํธ๋ค ํฌ๊ธฐ์ ์ ๋ฐ๋งํผ ๋นผ์ ์ค์์ ์์น)
|
474 |
+
ctx.rect(handle.x - handleSize / 2, handle.y - handleSize / 2, handleSize, handleSize);
|
475 |
+
ctx.fillStyle = cornerHandleColor;
|
476 |
+
ctx.fill();
|
477 |
+
}
|
478 |
+
|
479 |
+
// ํ์ ํธ๋ค ์ฐ๊ฒฐ ์ ๊ทธ๋ฆฌ๊ธฐ
|
480 |
+
ctx.beginPath();
|
481 |
+
ctx.moveTo(0, -halfHeight); // ์ด๋ฏธ์ง ์๋จ ์ค์
|
482 |
+
ctx.lineTo(rotateHandlePos.x, rotateHandlePos.y); // ํ์ ํธ๋ค ์์น
|
483 |
+
ctx.strokeStyle = '#3498db'; // ํ๋์
|
484 |
+
ctx.lineWidth = 2;
|
485 |
+
ctx.stroke();
|
486 |
+
|
487 |
+
// ํ์ ํธ๋ค ์ ๊ทธ๋ฆฌ๊ธฐ
|
488 |
+
ctx.beginPath();
|
489 |
+
ctx.arc(rotateHandlePos.x, rotateHandlePos.y, handleSize / 2, 0, Math.PI * 2); // ํ์ ํธ๋ค ์์น์ ์ ๊ทธ๋ฆฌ๊ธฐ
|
490 |
+
ctx.fillStyle = '#3498db'; // ํ๋์
|
491 |
+
ctx.fill();
|
492 |
+
|
493 |
+
ctx.restore(); // ์ด์ ์บ๋ฒ์ค ์ํ ๋ณต์
|
494 |
+
}
|
495 |
+
|
496 |
+
|
497 |
+
// ์ฃผ์ด์ง ์บ๋ฒ์ค ์ขํ์์ ์ด๋ค ํธ๋ค์ด ์๋์ง ํ์ธ
|
498 |
+
function getHandleAtPosition(canvasX, canvasY, activeOverlay) {
|
499 |
+
// ํ์ฑ ์ค๋ฒ๋ ์ด๋ ์ด๋ฏธ์ง๊ฐ ์ ํจํ์ง ์์ผ๋ฉด ํธ๋ค ์์
|
500 |
+
if (!activeOverlay || !activeOverlay.image || activeOverlay.image.width === 0 || activeOverlay.image.height === 0) return null;
|
501 |
+
|
502 |
+
const currentWidth = activeOverlay.image.width * activeOverlay.scale;
|
503 |
+
const currentHeight = activeOverlay.image.height * activeOverlay.scale;
|
504 |
+
const halfWidth = currentWidth / 2;
|
505 |
+
const halfHeight = currentHeight / 2;
|
506 |
+
|
507 |
+
// ๋ง์ฐ์ค/ํฐ์น ์ขํ๋ฅผ ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง์ ์ค์ฌ์ ๊ธฐ์ค์ผ๋ก ํ๊ณ ํ์ ์ ๋๋๋ฆฝ๋๋ค.
|
508 |
+
const dx = canvasX - activeOverlay.x;
|
509 |
+
const dy = canvasY - activeOverlay.y;
|
510 |
+
const angle = -activeOverlay.rotation * Math.PI / 180; // ํ์ ์ ๋๋๋ฆฌ๋ ๊ฐ๋
|
511 |
+
const cos = Math.cos(angle);
|
512 |
+
const sin = Math.sin(angle);
|
513 |
+
|
514 |
+
// ํ์ ๋ ์ขํ
|
515 |
+
const rotatedX = dx * cos - dy * sin;
|
516 |
+
const rotatedY = dx * sin + dy * cos;
|
517 |
+
|
518 |
+
|
519 |
+
// ์ฝ๋ ํธ๋ค ์์น (ํ์ ๋์ง ์์ ์ํ ๊ธฐ์ค)
|
520 |
+
const handles = {
|
521 |
+
'tl': { x: -halfWidth, y: -halfHeight, cursor: 'nwse-resize' },
|
522 |
+
'tr': { x: halfWidth, y: -halfHeight, cursor: 'nesw-resize' },
|
523 |
+
'br': { x: halfWidth, y: halfHeight, cursor: 'nwse-resize' },
|
524 |
+
'bl': { x: -halfWidth, y: halfHeight, cursor: 'nesw-resize' }
|
525 |
+
};
|
526 |
+
|
527 |
+
// ๊ฐ ์ฝ๋ ํธ๋ค ๊ทผ์ฒ์ ํด๋ฆญ/ํฐ์นํ๋์ง ํ์ธ
|
528 |
+
for (const [key, handle] of Object.entries(handles)) {
|
529 |
+
const dist = Math.sqrt(Math.pow(rotatedX - handle.x, 2) + Math.pow(rotatedY - handle.y, 2));
|
530 |
+
// ํด๋ฆญ ํจ๋ฉ์ ๋ํ์ฌ ํด๋ฆญ/ํฐ์น ์์ญ์ ์ฝ๊ฐ ๋๊ฒ ์ก์ต๋๋ค.
|
531 |
+
if (dist <= handleSize / 2 + clickPadding) {
|
532 |
+
return { id: key, cursor: handle.cursor }; // ํด๋น ํธ๋ค์ ID์ ์ปค์ ๋ชจ์ ๋ฐํ
|
533 |
+
}
|
534 |
+
}
|
535 |
+
|
536 |
+
// ํ์ ํธ๋ค ์์น (ํ์ ๋์ง ์์ ์ํ ๊ธฐ์ค)
|
537 |
+
const rotateHandlePos = { x: 0, y: -halfHeight - rotateHandleDistance };
|
538 |
+
const rotateDist = Math.sqrt(Math.pow(rotatedX - rotateHandlePos.x, 2) + Math.pow(rotatedY - rotateHandlePos.y, 2));
|
539 |
+
|
540 |
+
// ํ์ ํธ๋ค ๊ทผ์ฒ์ ํด๋ฆญ/ํฐ์นํ๋์ง ํ์ธ
|
541 |
+
if (rotateDist <= handleSize / 2 + clickPadding) {
|
542 |
+
return { id: 'rotate', cursor: 'grab' }; // ํ์ ํธ๋ค ID์ ์ปค์ ๋ชจ์ ๋ฐํ
|
543 |
+
}
|
544 |
+
|
545 |
+
return null; // ์ด๋ค ํธ๋ค๋ ํด๋ฆญ/ํฐ์น๋์ง ์์
|
546 |
+
}
|
547 |
+
|
548 |
+
|
549 |
+
// ์ฃผ์ด์ง ์บ๋ฒ์ค ์ขํ๊ฐ ํน์ ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง ์์ญ ์์ ์๋์ง ํ์ธ
|
550 |
+
function isOverOverlayImage(canvasX, canvasY, overlay) {
|
551 |
+
// ์ค๋ฒ๋ ์ด๋ ์ด๋ฏธ์ง๊ฐ ์ ํจํ์ง ์์ผ๋ฉด false ๋ฐํ
|
552 |
+
if (!overlay || !overlay.image || overlay.image.width === 0 || overlay.image.height === 0) return false;
|
553 |
+
|
554 |
+
const currentWidth = overlay.image.width * overlay.scale;
|
555 |
+
const currentHeight = overlay.image.height * overlay.scale;
|
556 |
+
const halfWidth = currentWidth / 2;
|
557 |
+
const halfHeight = currentHeight / 2;
|
558 |
+
|
559 |
+
// ๋ง์ฐ์ค/ํฐ์น ์ขํ๋ฅผ ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง์ ์ค์ฌ์ ๊ธฐ์ค์ผ๋ก ํ๊ณ ํ์ ์ ๋๋๋ฆฝ๋๋ค.
|
560 |
+
const dx = canvasX - overlay.x;
|
561 |
+
const dy = canvasY - overlay.y;
|
562 |
+
const angle = -overlay.rotation * Math.PI / 180; // ํ์ ์ ๋๋๋ฆฌ๋ ๊ฐ๋
|
563 |
+
const cos = Math.cos(angle);
|
564 |
+
const sin = Math.sin(angle);
|
565 |
+
|
566 |
+
// ํ์ ๋ ์ขํ
|
567 |
+
const rotatedX = dx * cos - dy * sin;
|
568 |
+
const rotatedY = dx * sin + dy * cos;
|
569 |
+
|
570 |
+
// ํ์ ๋ ์ขํ๊ฐ ์ด๋ฏธ์ง ๊ฒฝ๊ณ ๋ด์ ์๋์ง ํ์ธ (ํด๋ฆญ ํจ๋ฉ ์ ์ฉ)
|
571 |
+
return (rotatedX >= -halfWidth - clickPadding && rotatedX <= halfWidth + clickPadding &&
|
572 |
+
rotatedY >= -halfHeight - clickPadding && rotatedY <= halfHeight + clickPadding);
|
573 |
+
}
|
574 |
+
|
575 |
+
|
576 |
+
// ๋ง์ฐ์ค ์ปค์ ๋ชจ์ ์
๋ฐ์ดํธ
|
577 |
+
function updateCursor(canvasX, canvasY) {
|
578 |
+
// ๋๋๊ทธ, ํ์ , ๋ฆฌ์ฌ์ด์ฆ ์ค์๋ ์ปค์ ๋ชจ์์ ๋ณ๊ฒฝํ์ง ์์ต๋๋ค.
|
579 |
+
if (isDragging || isRotating || isResizing) return;
|
580 |
+
|
581 |
+
let cursor = 'default'; // ๊ธฐ๋ณธ ์ปค์ ๋ชจ์
|
582 |
+
let handled = false; // ํธ๋ค์ด๋ ์ด๋ฏธ์ง ์์ ์๋์ง ์ฌ๋ถ
|
583 |
+
|
584 |
+
// ํ์ฑ ๋ ์ด์ด๊ฐ ์๋ค๋ฉด ํธ๋ค ์์ ์๋์ง ๋จผ์ ํ์ธ
|
585 |
+
if (activeOverlayIndex >= 0) {
|
586 |
+
const activeOverlay = overlays[activeOverlayIndex];
|
587 |
+
const handle = getHandleAtPosition(canvasX, canvasY, activeOverlay);
|
588 |
+
if (handle) {
|
589 |
+
cursor = handle.cursor; // ํธ๋ค์ ๋ง๋ ์ปค์ ๋ชจ์ ์ค์
|
590 |
+
handled = true;
|
591 |
+
}
|
592 |
+
}
|
593 |
+
|
594 |
+
// ํธ๋ค ์์ ์์ง ์๋ค๋ฉด, ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง ์์ ์๋์ง ํ์ธ (๊ฐ์ฅ ์์ ์๋ ๋ ์ด์ด๋ถํฐ)
|
595 |
+
if (!handled) {
|
596 |
+
for (let i = overlays.length - 1; i >= 0; i--) {
|
597 |
+
if (isOverOverlayImage(canvasX, canvasY, overlays[i])) {
|
598 |
+
cursor = 'move'; // ์ด๋ ์ปค์ ์ค์
|
599 |
+
handled = true;
|
600 |
+
break; // ํ๋๋ผ๋ ๋ฐ๊ฒฌํ๋ฉด ์ค์ง
|
601 |
+
}
|
602 |
+
}
|
603 |
+
}
|
604 |
+
|
605 |
+
canvas.style.cursor = cursor; // ์บ๋ฒ์ค ์ปค์ ๋ชจ์ ์ ์ฉ
|
606 |
+
}
|
607 |
+
|
608 |
+
|
609 |
+
// ํฉ์ฑ๋ ์ต์ข
์ด๋ฏธ์ง ์์ฑ
|
610 |
+
function generateMergedImage() {
|
611 |
+
// ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง๊ฐ ์์ผ๋ฉด ์์ฑํ ์ ์์ต๋๋ค.
|
612 |
+
if (overlays.length === 0) {
|
613 |
+
alert('ํฉ์ฑํ ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง๊ฐ ์์ต๋๋ค.');
|
614 |
+
return null;
|
615 |
+
}
|
616 |
+
|
617 |
+
// ๊ฒฐ๊ณผ๋ฅผ ๊ทธ๋ฆด ์ ์บ๋ฒ์ค ์์ฑ
|
618 |
+
const resultCanvas = document.createElement('canvas');
|
619 |
+
resultCanvas.width = CANVAS_WIDTH;
|
620 |
+
resultCanvas.height = canvasAdjustedHeight;
|
621 |
+
const resultCtx = resultCanvas.getContext('2d');
|
622 |
+
|
623 |
+
// ์บ๋ฒ์ค ์ด๊ธฐํ (๋ฐฐ๊ฒฝ ์ฑ์ฐ๊ธฐ)
|
624 |
+
resultCtx.clearRect(0, 0, resultCanvas.width, resultCanvas.height);
|
625 |
+
if (backgroundImage) {
|
626 |
+
resultCtx.drawImage(backgroundImage, 0, 0, backgroundImage.width, backgroundImage.height, bgDrawProps.x, bgDrawProps.y, bgDrawProps.width, bgDrawProps.height);
|
627 |
+
} else {
|
628 |
+
resultCtx.fillStyle = '#ffffff';
|
629 |
+
resultCtx.fillRect(0, 0, CANVAS_WIDTH, canvasAdjustedHeight);
|
630 |
+
}
|
631 |
+
|
632 |
+
// ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง๋ค์ ์์๋๋ก ๊ทธ๋ฆฝ๋๋ค.
|
633 |
+
overlays.forEach(overlay => {
|
634 |
+
if (!overlay.image || overlay.image.width === 0 || overlay.image.height === 0) return;
|
635 |
+
|
636 |
+
// ํํฐ ์ ์ฉ๋ ์ด๋ฏธ์ง ์บ๋ฒ์ค ์์ฑ
|
637 |
+
const filteredCanvas = ImageFilters.createFilteredCanvas(overlay.image, overlay.filters);
|
638 |
+
|
639 |
+
resultCtx.save(); // ํ์ฌ ์ํ ์ ์ฅ
|
640 |
+
|
641 |
+
// ์ค๋ฒ๋ ์ด ์์น, ํ์ , ์ค์ผ์ผ ์ ์ฉ
|
642 |
+
resultCtx.translate(overlay.x, overlay.y);
|
643 |
+
resultCtx.rotate(overlay.rotation * Math.PI / 180);
|
644 |
+
resultCtx.scale(overlay.scale, overlay.scale);
|
645 |
+
|
646 |
+
// ์ด๋ฏธ์ง๋ฅผ ์ค์ฌ ๊ธฐ์ค์ผ๋ก ๊ทธ๋ฆฝ๋๋ค.
|
647 |
+
resultCtx.drawImage(filteredCanvas, -overlay.image.width / 2, -overlay.image.height / 2);
|
648 |
+
|
649 |
+
resultCtx.restore(); // ์ํ ๋ณต์
|
650 |
+
});
|
651 |
+
|
652 |
+
// ๋ฏธ๋ฆฌ๋ณด๊ธฐ์ ๊ฒฐ๊ณผ ์ด๋ฏธ์ง ํ์
|
653 |
+
previewImg.src = resultCanvas.toDataURL(`image/${originalFormat === 'jpg' ? 'jpeg' : originalFormat}`);
|
654 |
+
previewContainer.style.display = 'flex'; // ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์ปจํ
์ด๋ ๋ณด์ด๊ฒ ํจ
|
655 |
+
|
656 |
+
return resultCanvas; // ๊ฒฐ๊ณผ ์บ๋ฒ์ค ๋ฐํ
|
657 |
+
}
|
658 |
+
|
659 |
+
// ์ ํ๋ ๋ ์ด์ด ์ญ์
|
660 |
+
function deleteSelectedLayer() {
|
661 |
+
if (activeOverlayIndex >= 0) {
|
662 |
+
// ํด๋น ์ธ๋ฑ์ค์ ๋ ์ด์ด ์ญ์
|
663 |
+
overlays.splice(activeOverlayIndex, 1);
|
664 |
+
activeOverlayIndex = -1; // ํ์ฑ ๋ ์ด์ด ์์์ผ๋ก ์ค์
|
665 |
+
|
666 |
+
updateControlPanel(); // ์ปจํธ๋กค ํจ๋ ์
๋ฐ์ดํธ
|
667 |
+
updateLayersList(); // ๋ ์ด์ด ๋ชฉ๋ก ์
๋ฐ์ดํธ
|
668 |
+
drawCanvas(); // ์บ๋ฒ์ค ๋ค์ ๊ทธ๋ฆฌ๊ธฐ
|
669 |
+
|
670 |
+
// ๋ชจ๋ ์ค๋ฒ๋ ์ด๊ฐ ์ญ์ ๋๋ฉด ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์จ๊น
|
671 |
+
if (overlays.length === 0) {
|
672 |
+
previewContainer.style.display = 'none';
|
673 |
+
}
|
674 |
+
// else {
|
675 |
+
// // ์ญ์ ํ ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์
๋ฐ์ดํธ (์ ํ ์ฌํญ)
|
676 |
+
// generateMergedImage();
|
677 |
+
// }
|
678 |
+
}
|
679 |
+
}
|
680 |
+
|
681 |
+
// ๋ง์ฐ์ค/ํฐ์น ์ด๋ฒคํธ์ ํด๋ผ์ด์ธํธ ์ขํ๋ฅผ ์บ๋ฒ์ค ์ขํ๋ก ๋ณํ
|
682 |
+
function getCanvasCoordinates(clientX, clientY) {
|
683 |
+
const rect = canvas.getBoundingClientRect(); // ์บ๋ฒ์ค์ ํ๋ฉด์ ์์น์ ํฌ๊ธฐ
|
684 |
+
const scaleX = canvas.width / rect.width; // ๊ฐ๋ก ์ค์ผ์ผ ๋น์จ
|
685 |
+
const scaleY = canvas.height / rect.height; // ์ธ๋ก ์ค์ผ์ผ ๋น์จ
|
686 |
+
|
687 |
+
// ํด๋ผ์ด์ธํธ ์ขํ๋ฅผ ์บ๋ฒ์ค ๋ด๋ถ ์ขํ๋ก ๋ณํ
|
688 |
+
const x = (clientX - rect.left) * scaleX;
|
689 |
+
const y = (clientY - rect.top) * scaleY;
|
690 |
+
|
691 |
+
return { x, y };
|
692 |
+
}
|
693 |
+
|
694 |
+
|
695 |
+
// ํ์ฌ ํํฐ ๊ฐ์ ํ์ฑ ๋ ์ด์ด์ ์ ์ฉํ๊ณ ์บ๋ฒ์ค ๋ค์ ๊ทธ๋ฆฌ๊ธฐ
|
696 |
+
function applyCurrentFilters() {
|
697 |
+
if (activeOverlayIndex < 0) return; // ํ์ฑ ๋ ์ด์ด๊ฐ ์์ผ๋ฉด ์ ์ฉํ์ง ์์
|
698 |
+
|
699 |
+
const filterValues = {
|
700 |
+
temperature: parseInt(temperatureSlider.value),
|
701 |
+
brightness: parseInt(brightnessSlider.value),
|
702 |
+
contrast: parseInt(contrastSlider.value),
|
703 |
+
saturation: parseInt(saturationSlider.value)
|
704 |
+
};
|
705 |
+
|
706 |
+
// filter.js์ applyFilterToLayer ํจ์ ํธ์ถ
|
707 |
+
ImageFilters.applyFilterToLayer(overlays, activeOverlayIndex, filterValues);
|
708 |
+
|
709 |
+
drawCanvas(); // ๋ณ๊ฒฝ ์ฌํญ์ ๋ฐ์ํ์ฌ ์บ๋ฒ์ค ๋ค์ ๊ทธ๏ฟฝ๏ฟฝ๊ธฐ
|
710 |
+
}
|
711 |
+
|
712 |
+
|
713 |
+
// --- ์ด๋ฒคํธ ๋ฆฌ์ค๋ ---
|
714 |
+
|
715 |
+
// DOMContentLoaded ์ด๋ฒคํธ: ๋ฌธ์ ๋ก๋ ํ ์ด๊ธฐํ ๋ฐ ์ด๋ฒคํธ ๋ฆฌ์ค๋ ์ค์
|
716 |
+
document.addEventListener('DOMContentLoaded', () => {
|
717 |
+
|
718 |
+
// ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง ์
๋ก๋ ์ด๋ฒคํธ ๋ฆฌ์ค๋
|
719 |
+
backgroundInput.addEventListener('change', function(e) {
|
720 |
+
if (e.target.files.length > 0) {
|
721 |
+
loadImage(e.target.files[0], 'background');
|
722 |
+
}
|
723 |
+
});
|
724 |
+
|
725 |
+
// ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง ์
๋ก๋ ์ด๋ฒคํธ ๋ฆฌ์ค๋
|
726 |
+
overlayInput.addEventListener('change', function(e) {
|
727 |
+
if (e.target.files.length > 0) {
|
728 |
+
loadImage(e.target.files[0], 'overlay');
|
729 |
+
this.value = ''; // ํ์ผ ์ ํ ํ input ๊ฐ ์ด๊ธฐํ (๊ฐ์ ํ์ผ ๋ค์ ์ ํ ๊ฐ๋ฅํ๊ฒ)
|
730 |
+
}
|
731 |
+
});
|
732 |
+
|
733 |
+
// ์์ ์ด๋ฏธ์ง ํด๋ฆญ ์ด๋ฒคํธ ๋ฆฌ์ค๋ ์ค์
|
734 |
+
const exampleImagesContainer = document.getElementById('example-images-container'); // ์์ ์ด๋ฏธ์ง ์ปจํ
์ด๋ ID
|
735 |
+
if (exampleImagesContainer) {
|
736 |
+
exampleImagesContainer.querySelectorAll('.example-img').forEach(img => {
|
737 |
+
img.addEventListener('click', function() {
|
738 |
+
const imageUrl = this.src;
|
739 |
+
const fileName = this.getAttribute('data-filename') || 'example_image.png';
|
740 |
+
|
741 |
+
// ์์ ์ด๋ฏธ์ง ๋ก๋
|
742 |
+
const exampleImgElement = new Image();
|
743 |
+
exampleImgElement.crossOrigin = 'anonymous'; // CORS ๋ฌธ์ ๋ฐฉ์ง๋ฅผ ์ํด ํ์ํ ์ ์์ต๋๋ค.
|
744 |
+
exampleImgElement.onload = function() {
|
745 |
+
// TODO: ์ฌ๊ธฐ์์ ๋ฐฐ๊ฒฝ ์ ๊ฑฐ ๋ก์ง์ ์คํํฉ๋๋ค.
|
746 |
+
// ์ ๊ณต๋ cropTransparentPixels ํจ์๋ ํฌ๋ช
์์ญ์ ์๋ฅด๋ ๋ฐ ์ฌ์ฉ๋ ์ ์์ต๋๋ค.
|
747 |
+
// ๋ง์ฝ ์์ ์ด๋ฏธ์ง๊ฐ ์ด๋ฏธ ๋ฐฐ๊ฒฝ ์ ๊ฑฐ๋ ์ด๋ฏธ์ง๋ผ๋ฉด ์ด ํจ์๋ฅผ ์ฌ์ฉํด๋ ๋ฉ๋๋ค.
|
748 |
+
// ์ผ๋ฐ ์ด๋ฏธ์ง์ ๋ณต์กํ ๋ฐฐ๊ฒฝ์ ์ ๊ฑฐํ๋ ค๋ฉด ๋ณ๋์ ๊ณ ๊ธ ์ด๋ฏธ์ง ์ฒ๋ฆฌ ๋ก์ง์ด๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ํ์ํฉ๋๋ค.
|
749 |
+
|
750 |
+
let processedImageSource = exampleImgElement; // ๊ธฐ๋ณธ์ ์ผ๋ก๋ ์๋ณธ ์ด๋ฏธ์ง ์ฌ์ฉ
|
751 |
+
|
752 |
+
try {
|
753 |
+
// ํฌ๋ช
ํฝ์
์๋ฅด๊ธฐ ์๋ (๋ฐฐ๊ฒฝ ์ ๊ฑฐ๋ ์ด๋ฏธ์ง์ ์ ์ฉ)
|
754 |
+
const croppedCanvas = cropTransparentPixels(exampleImgElement);
|
755 |
+
if (croppedCanvas.width > 0 && croppedCanvas.height > 0) {
|
756 |
+
processedImageSource = croppedCanvas;
|
757 |
+
} else {
|
758 |
+
console.warn("cropTransparentPixels resulted in empty canvas, using original image.");
|
759 |
+
processedImageSource = exampleImgElement;
|
760 |
+
}
|
761 |
+
} catch (e) {
|
762 |
+
console.error("Error during cropTransparentPixels, using original image:", e);
|
763 |
+
processedImageSource = exampleImgElement;
|
764 |
+
}
|
765 |
+
|
766 |
+
|
767 |
+
// ์ฒ๋ฆฌ๋ ์ด๋ฏธ์ง๋ฅผ Blob์ผ๋ก ๋ณํ
|
768 |
+
// cropTransparentPixels๊ฐ ์บ๋ฒ์ค๋ฅผ ๋ฐํํ๋ฏ๋ก toBlob ์ฌ์ฉ
|
769 |
+
const canvasToProcess = processedImageSource instanceof HTMLCanvasElement ? processedImageSource : null;
|
770 |
+
|
771 |
+
if (canvasToProcess) {
|
772 |
+
canvasToProcess.toBlob(function(blob) {
|
773 |
+
if (blob) {
|
774 |
+
// Blob์ ์ฌ์ฉํ์ฌ loadImage ํจ์ ํธ์ถ (loadImage ํจ์๊ฐ Blob์ ์ฒ๋ฆฌํ๋๋ก ์์ ๋จ)
|
775 |
+
loadImage(blob, 'overlay');
|
776 |
+
} else {
|
777 |
+
console.error("Failed to create blob from processed canvas.");
|
778 |
+
alert("์ด๋ฏธ์ง ์ฒ๋ฆฌ์ ์คํจํ์ต๋๋ค.");
|
779 |
+
}
|
780 |
+
}, 'image/png'); // ๋ฐฐ๊ฒฝ ์ ๊ฑฐ ์ ํฌ๋ช
๋๋ฅผ ์ํด PNG ํฌ๋งท ๊ถ์ฅ
|
781 |
+
} else if (processedImageSource instanceof HTMLImageElement) {
|
782 |
+
// Canvas๊ฐ ์๋ Image ์์์ธ ๊ฒฝ์ฐ (e.g., cropTransparentPixels ์ค๋ฅ ์)
|
783 |
+
// Data URL๋ก ๋ณํํ์ฌ Blob ์์ฑ ํ loadImage ํธ์ถ
|
784 |
+
const tempCanvas = document.createElement('canvas');
|
785 |
+
tempCanvas.width = processedImageSource.width;
|
786 |
+
tempCanvas.height = processedImageSource.height;
|
787 |
+
const tempCtx = tempCanvas.getContext('2d');
|
788 |
+
tempCtx.drawImage(processedImageSource, 0, 0);
|
789 |
+
tempCanvas.toBlob(function(blob) {
|
790 |
+
if (blob) {
|
791 |
+
loadImage(blob, 'overlay');
|
792 |
+
} else {
|
793 |
+
console.error("Failed to create blob from fallback image.");
|
794 |
+
alert("์ด๋ฏธ์ง ์ฒ๋ฆฌ์ ์คํจํ์ต๋๋ค.");
|
795 |
+
}
|
796 |
+
}, 'image/png');
|
797 |
+
} else {
|
798 |
+
console.error("Processed image source is neither Canvas nor Image.");
|
799 |
+
alert("์ด๋ฏธ์ง ์ฒ๋ฆฌ์ ์คํจํ์ต๋๋ค.");
|
800 |
+
}
|
801 |
+
|
802 |
+
};
|
803 |
+
exampleImgElement.onerror = function() {
|
804 |
+
console.error("Error loading example image:", imageUrl);
|
805 |
+
alert("์์ ์ด๋ฏธ์ง๋ฅผ ๋ก๋ํ๋ ๋ฐ ์คํจํ์ต๋๋ค.");
|
806 |
+
};
|
807 |
+
exampleImgElement.src = imageUrl; // ์์ ์ด๋ฏธ์ง ๋ก๋ ์์
|
808 |
+
});
|
809 |
+
});
|
810 |
+
}
|
811 |
+
|
812 |
+
|
813 |
+
// Delete ํค ๋๋ ์ ๋ ์ ํ๋ ๋ ์ด์ด ์ญ์
|
814 |
+
document.addEventListener('keydown', function(e) {
|
815 |
+
// Ctrl ๋๋ Cmd ํค์ ํจ๊ป ๋๋ ธ์ ๋๋ง ๋์ํ๋๋ก ์กฐ๊ฑด ์ถ๊ฐ (์ค์ ๋ฐฉ์ง)
|
816 |
+
if (e.key === 'Delete' && activeOverlayIndex >= 0) {
|
817 |
+
e.preventDefault(); // ๊ธฐ๋ณธ ๋์(๋ค๋ก๊ฐ๊ธฐ ๋ฑ) ๋ฐฉ์ง
|
818 |
+
deleteSelectedLayer();
|
819 |
+
}
|
820 |
+
});
|
821 |
+
|
822 |
+
// ํฌ๊ธฐ ์กฐ์ ์ฌ๋ผ์ด๋ ์ด๋ฒคํธ
|
823 |
+
scaleSlider.addEventListener('input', function() {
|
824 |
+
if (activeOverlayIndex >= 0) {
|
825 |
+
overlays[activeOverlayIndex].scale = parseInt(this.value) / 100;
|
826 |
+
scaleValue.textContent = this.value + '%';
|
827 |
+
drawCanvas(); // ์บ๋ฒ์ค ๋ค์ ๊ทธ๋ฆฌ๊ธฐ
|
828 |
+
}
|
829 |
+
});
|
830 |
+
|
831 |
+
// ํ์ ์ฌ๋ผ์ด๋ ์ด๋ฒคํธ
|
832 |
+
rotationSlider.addEventListener('input', function() {
|
833 |
+
if (activeOverlayIndex >= 0) {
|
834 |
+
overlays[activeOverlayIndex].rotation = parseInt(this.value);
|
835 |
+
rotationValue.textContent = overlays[activeOverlayIndex].rotation + 'ยฐ';
|
836 |
+
drawCanvas(); // ์บ๋ฒ์ค ๋ค์ ๊ทธ๋ฆฌ๊ธฐ
|
837 |
+
}
|
838 |
+
});
|
839 |
+
|
840 |
+
// ํํฐ ์ฌ๋ผ์ด๋ ์ด๋ฒคํธ
|
841 |
+
temperatureSlider.addEventListener('input', function() { temperatureValue.textContent = this.value; applyCurrentFilters(); });
|
842 |
+
brightnessSlider.addEventListener('input', function() { brightnessValue.textContent = this.value + '%'; applyCurrentFilters(); });
|
843 |
+
contrastSlider.addEventListener('input', function() { contrastValue.textContent = this.value + '%'; applyCurrentFilters(); });
|
844 |
+
saturationSlider.addEventListener('input', function() { saturationValue.textContent = this.value + '%'; applyCurrentFilters(); });
|
845 |
+
|
846 |
+
// ํํฐ ์ด๊ธฐํ ๋ฒํผ ์ด๋ฒคํธ
|
847 |
+
resetFilterBtn.addEventListener('click', function() {
|
848 |
+
// filter.js์ resetFilters ํจ์ ํธ์ถ
|
849 |
+
const defaultFilters = ImageFilters.resetFilters(overlays, activeOverlayIndex);
|
850 |
+
// ์ฌ๋ผ์ด๋ ๊ฐ๊ณผ ํ์ ์
๋ฐ์ดํธ
|
851 |
+
temperatureSlider.value = defaultFilters.temperature; temperatureValue.textContent = defaultFilters.temperature;
|
852 |
+
brightnessSlider.value = defaultFilters.brightness; brightnessValue.textContent = defaultFilters.brightness + '%';
|
853 |
+
contrastSlider.value = defaultFilters.contrast; contrastValue.textContent = defaultFilters.contrast + '%';
|
854 |
+
saturationSlider.value = defaultFilters.saturation; saturationValue.textContent = defaultFilters.saturation + '%';
|
855 |
+
drawCanvas(); // ๋ณ๊ฒฝ ์ฌํญ ๋ฐ์
|
856 |
+
});
|
857 |
+
|
858 |
+
|
859 |
+
// ์บ๋ฒ์ค ๋ง์ฐ์ค/ํฐ์น ์ด๋ฒคํธ ๋ฆฌ์ค๋
|
860 |
+
canvas.addEventListener('mousedown', function(e) {
|
861 |
+
// ๋ง์ฐ์ค ์ผ์ชฝ ๋ฒํผ๋ง ์ฒ๋ฆฌ
|
862 |
+
if (e.button !== 0) return;
|
863 |
+
|
864 |
+
const { x, y } = getCanvasCoordinates(e.clientX, e.clientY);
|
865 |
+
const isAltPressed = e.altKey; // Alt ํค ๋๋ฆผ ์ฌ๋ถ ํ์ธ
|
866 |
+
|
867 |
+
let clickedOverlayIndex = -1; // ํด๋ฆญ๋ ์ค๋ฒ๋ ์ด ์ธ๋ฑ์ค
|
868 |
+
let handle = null; // ํด๋ฆญ๋ ํธ๋ค
|
869 |
+
|
870 |
+
// ํ์ฑ ๋ ์ด์ด๊ฐ ์๋ค๋ฉด ๋จผ์ ํด๋น ๋ ์ด์ด์ ํธ๋ค ํด๋ฆญ ์ฌ๋ถ ํ์ธ
|
871 |
+
if (activeOverlayIndex >= 0) {
|
872 |
+
handle = getHandleAtPosition(x, y, overlays[activeOverlayIndex]);
|
873 |
+
if (handle) {
|
874 |
+
clickedOverlayIndex = activeOverlayIndex; // ํธ๋ค์ด ํด๋ฆญ๋๋ฉด ํด๋น ๋ ์ด์ด ์ ํ
|
875 |
+
}
|
876 |
+
}
|
877 |
+
|
878 |
+
// ํธ๋ค์ด ํด๋ฆญ๋์ง ์์๋ค๋ฉด ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง ์์ฒด ํด๋ฆญ ์ฌ๋ถ ํ์ธ
|
879 |
+
if (!handle) {
|
880 |
+
let overlaysAtPosition = []; // ํด๋ฆญ๋ ์์น์ ์๋ ๋ชจ๋ ์ค๋ฒ๋ ์ด ๋ชฉ๋ก
|
881 |
+
// ๋ชจ๋ ์ค๋ฒ๋ ์ด๋ฅผ ์ํํ๋ฉฐ ํด๋ฆญ๋ ์์น์ ํด๋นํ๋ ์ค๋ฒ๋ ์ด ์ฐพ๊ธฐ
|
882 |
+
for (let i = 0; i < overlays.length; i++) {
|
883 |
+
if (isOverOverlayImage(x, y, overlays[i])) {
|
884 |
+
overlaysAtPosition.push(i);
|
885 |
+
}
|
886 |
+
}
|
887 |
+
|
888 |
+
if (overlaysAtPosition.length > 0) {
|
889 |
+
// ์ฌ๋ฌ ๊ฐ์ ์ค๋ฒ๋ ์ด๊ฐ ๊ฒน์ณ ์๋ค๋ฉด Alt ํค ๋๋ฆผ ์ฌ๋ถ์ ๋ฐ๋ผ ์ฒ๋ฆฌ
|
890 |
+
if (isAltPressed && overlaysAtPosition.length > 1) {
|
891 |
+
// Alt ํค๊ฐ ๋๋ ธ๊ณ ์ฌ๋ฌ ๊ฐ๊ฐ ๊ฒน์ณ ์๋ค๋ฉด, ํ์ฌ ์ ํ๋ ๋ ์ด์ด ๋ค์ ์์์ ๋ ์ด์ด๋ฅผ ์ ํ
|
892 |
+
if (activeOverlayIndex >= 0) {
|
893 |
+
const currentIndexInAtPosition = overlaysAtPosition.indexOf(activeOverlayIndex);
|
894 |
+
if (currentIndexInAtPosition !== -1) {
|
895 |
+
const nextIndexInAtPosition = (currentIndexInAtPosition + 1) % overlaysAtPosition.length;
|
896 |
+
clickedOverlayIndex = overlaysAtPosition[nextIndexInAtPosition];
|
897 |
+
} else {
|
898 |
+
// ํ์ฌ ์ ํ๋ ๋ ์ด์ด๊ฐ ํด๋ฆญ๋ ์์น์ ์์ผ๋ฉด ๊ฐ์ฅ ์์ ์๋ ๋ ์ด์ด ์ ํ (๊ธฐ๋ณธ ๋์)
|
899 |
+
clickedOverlayIndex = overlaysAtPosition[overlaysAtPosition.length - 1];
|
900 |
+
}
|
901 |
+
} else {
|
902 |
+
// Alt ํค๊ฐ ๋๋ ธ์ง๋ง ํ์ฌ ์ ํ๋ ๋ ์ด์ด๊ฐ ์์ผ๋ฉด ๊ฐ์ฅ ์์ ์๋ ๋ ์ด์ด ์ ํ
|
903 |
+
clickedOverlayIndex = overlaysAtPosition[overlaysAtPosition.length - 1];
|
904 |
+
}
|
905 |
+
} else {
|
906 |
+
// Alt ํค๊ฐ ๋๋ฆฌ์ง ์์๊ฑฐ๋ ํ๋๋ง ๊ฒน์ณ ์๋ค๋ฉด, ๊ฐ์ฅ ์์ ์๋ ๋ ์ด์ด ์ ํ
|
907 |
+
clickedOverlayIndex = overlaysAtPosition[overlaysAtPosition.length - 1];
|
908 |
+
}
|
909 |
+
}
|
910 |
+
}
|
911 |
+
|
912 |
+
|
913 |
+
// ํด๋ฆญ๋ ์ค๋ฒ๋ ์ด๊ฐ ์๋ค๋ฉด ํด๋น ์ค๋ฒ๋ ์ด๋ฅผ ํ์ฑ ๋ ์ด์ด๋ก ์ค์ ํ๊ณ ์ํ ์
๋ฐ์ดํธ
|
914 |
+
if (clickedOverlayIndex >= 0) {
|
915 |
+
const activeOverlay = overlays[clickedOverlayIndex];
|
916 |
+
// ์ด๋ฏธ ํ์ฑ ๋ ์ด์ด์ธ ๊ฒฝ์ฐ๋ ์ ์ธ
|
917 |
+
if (activeOverlayIndex !== clickedOverlayIndex) {
|
918 |
+
activeOverlayIndex = clickedOverlayIndex;
|
919 |
+
updateControlPanel(); // ์ปจํธ๋กค ํจ๋ ์
๋ฐ์ดํธ
|
920 |
+
updateLayersList(); // ๋ ์ด์ด ๋ชฉ๋ก ์
๋ฐ์ดํธ
|
921 |
+
}
|
922 |
+
|
923 |
+
// ํด๋ฆญ๋ ๊ฒ์ด ํธ๋ค์ด๋ฉด ํด๋น ์์
์์
|
924 |
+
if (handle) {
|
925 |
+
if (handle.id === 'rotate') {
|
926 |
+
isRotating = true;
|
927 |
+
canvas.style.cursor = 'grabbing';
|
928 |
+
} else {
|
929 |
+
isResizing = true;
|
930 |
+
activeHandle = handle.id; // ํ์ฑ ํธ๋ค ID ์ค์
|
931 |
+
// ๋ฆฌ์ฌ์ด์ฆ ์์ ์ ๋ง์ฐ์ค ์์น์ ์ค๋ฒ๋ ์ด ์ค์ฌ ๊ฐ์ ๊ฑฐ๋ฆฌ ๊ณ์ฐ (๋น๋ก ์ค์ผ์ผ๋ง์ ์ฌ์ฉ)
|
932 |
+
const dxMouse = x - activeOverlay.x;
|
933 |
+
const dyMouse = y - activeOverlay.y;
|
934 |
+
resizeStartDistance = Math.sqrt(dxMouse * dxMouse + dyMouse * dyMouse);
|
935 |
+
if (resizeStartDistance < 10) resizeStartDistance = 10; // ๋๋ฌด ๊ฐ๊น์ฐ๋ฉด ์ต์๊ฐ ์ค์
|
936 |
+
}
|
937 |
+
} else {
|
938 |
+
// ํธ๋ค์ด ์๋ ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง ์์ฒด๋ฅผ ํด๋ฆญํ ๊ฒฝ์ฐ ๋๋๊ทธ ์์
|
939 |
+
isDragging = true;
|
940 |
+
canvas.style.cursor = 'grabbing'; // ๋๋๊ทธ ์ปค์ ๋ชจ์
|
941 |
+
}
|
942 |
+
} else {
|
943 |
+
// ์ค๋ฒ๋ ์ด ์ด๋ฏธ์ง๊ฐ ์๋ ๋น ๊ณต๊ฐ์ ํด๋ฆญํ ๊ฒฝ์ฐ ํ์ฑ ๋ ์ด์ด ํด์
|
944 |
+
activeOverlayIndex = -1;
|
945 |
+
updateControlPanel(); // ์ปจํธ๋กค ํจ๋ ์ด๊ธฐํ
|
946 |
+
updateLayersList(); // ๋ ์ด์ด ๋ชฉ๋ก ์
๋ฐ์ดํธ (ํ์ฑ ํ์ ์ ๊ฑฐ)
|
947 |
+
}
|
948 |
+
|
949 |
+
// ๋ง์ง๋ง ๋ง์ฐ์ค/ํฐ์น ์ขํ ์ ์ฅ
|
950 |
+
lastX = x;
|
951 |
+
lastY = y;
|
952 |
+
|
953 |
+
drawCanvas(); // ์บ๋ฒ์ค ๋ค์ ๊ทธ๋ฆฌ๊ธฐ (ํ์ฑ ๋ ์ด์ด ํธ๋ค ํ์ ์
๋ฐ์ดํธ)
|
954 |
+
});
|
955 |
+
|
956 |
+
canvas.addEventListener('mousemove', function(e) {
|
957 |
+
const { x, y } = getCanvasCoordinates(e.clientX, e.clientY);
|
958 |
+
|
959 |
+
// ๋๋๊ทธ, ํ์ , ๋ฆฌ์ฌ์ด์ฆ ์ค์ด ์๋๋ฉด ์ปค์ ๋ชจ์ ์
๋ฐ์ดํธ
|
960 |
+
if (!isDragging && !isRotating && !isResizing) {
|
961 |
+
updateCursor(x, y);
|
962 |
+
} else if (activeOverlayIndex >= 0) { // ๋๋๊ทธ, ํ์ , ๋ฆฌ์ฌ์ด์ฆ ์ค์ด๊ณ ํ์ฑ ๋ ์ด์ด๊ฐ ์๋ค๋ฉด
|
963 |
+
const activeOverlay = overlays[activeOverlayIndex];
|
964 |
+
canvas.style.cursor = 'grabbing'; // ์์
์ค์๋ ์ก๋ ์ปค์ ์ ์ง
|
965 |
+
|
966 |
+
if (isRotating) {
|
967 |
+
// ๋ง์ฐ์ค ์์น๋ฅผ ๊ธฐ์ค์ผ๋ก ํ์ ๊ฐ๋ ๊ณ์ฐ
|
968 |
+
const dx = x - activeOverlay.x;
|
969 |
+
const dy = y - activeOverlay.y;
|
970 |
+
let angle = Math.atan2(dy, dx) * 180 / Math.PI + 90; // atan2 ๊ฒฐ๊ณผ๋ -180~180, +90ํ์ฌ 0~360์ผ๋ก ๋ณํ
|
971 |
+
angle = (angle % 360 + 360) % 360; // ๊ฐ๋๋ฅผ 0~360 ๋ฒ์๋ก ์ ์ง
|
972 |
+
activeOverlay.rotation = angle;
|
973 |
+
|
974 |
+
// ํ์ ์ฌ๋ผ์ด๋ ๋ฐ ๊ฐ ์
๋ฐ์ดํธ
|
975 |
+
rotationSlider.value = Math.round(activeOverlay.rotation);
|
976 |
+
rotationValue.textContent = Math.round(activeOverlay.rotation) + 'ยฐ';
|
977 |
+
|
978 |
+
} else if (isResizing && activeOverlay.image) {
|
979 |
+
// ๋ฆฌ์ฌ์ด์ฆ ์ค์ด๊ณ ์ด๋ฏธ์ง๊ฐ ์๋ค๋ฉด
|
980 |
+
const dxMouse = x - activeOverlay.x;
|
981 |
+
const dyMouse = y - activeOverlay.y;
|
982 |
+
const currentDistance = Math.sqrt(dxMouse * dxMouse + dyMouse * dyMouse);
|
983 |
+
|
984 |
+
if (resizeStartDistance > 0 && currentDistance > 0) {
|
985 |
+
// ๋ง์ฐ์ค ์ด๋ ๊ฑฐ๋ฆฌ์ ๋น๋กํ์ฌ ์ค์ผ๏ฟฝ๏ฟฝ ์กฐ์
|
986 |
+
let newScale = activeOverlay.scale * (currentDistance / resizeStartDistance);
|
987 |
+
activeOverlay.scale = Math.max(0.01, newScale); // ์ค์ผ์ผ ์ต์๊ฐ ์ ํ
|
988 |
+
resizeStartDistance = currentDistance; // ๋ค์ ์ด๋ ๊ณ์ฐ์ ์ํด ๊ฑฐ๋ฆฌ ์
๋ฐ์ดํธ
|
989 |
+
}
|
990 |
+
|
991 |
+
// ์ค์ผ์ผ ์ฌ๋ผ์ด๋ ๋ฐ ๊ฐ ์
๋ฐ์ดํธ
|
992 |
+
const scalePercent = Math.round(activeOverlay.scale * 100);
|
993 |
+
scaleSlider.value = scalePercent;
|
994 |
+
scaleValue.textContent = scalePercent + '%';
|
995 |
+
|
996 |
+
} else if (isDragging && activeOverlay.image) {
|
997 |
+
// ๋๋๊ทธ ์ค์ด๊ณ ์ด๋ฏธ์ง๊ฐ ์๋ค๋ฉด
|
998 |
+
const dx = x - lastX; // x์ถ ์ด๋ ๊ฑฐ๋ฆฌ
|
999 |
+
const dy = y - lastY; // y์ถ ์ด๋ ๊ฑฐ๋ฆฌ
|
1000 |
+
|
1001 |
+
activeOverlay.x += dx; // ์ค๋ฒ๋ ์ด ์์น ์
๋ฐ์ดํธ
|
1002 |
+
activeOverlay.y += dy;
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
// ์์
์ค์๋ ์บ๋ฒ์ค ๊ณ์ ๋ค์ ๊ทธ๋ฆฌ๊ธฐ
|
1006 |
+
if (isRotating || isResizing || isDragging) {
|
1007 |
+
drawCanvas();
|
1008 |
+
}
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
// ๋ง์ง๋ง ๋ง์ฐ์ค/ํฐ์น ์ขํ ์
๋ฐ์ดํธ
|
1012 |
+
lastX = x;
|
1013 |
+
lastY = y;
|
1014 |
+
});
|
1015 |
+
|
1016 |
+
// ๋ง์ฐ์ค ๋ฒํผ ๋ผ๊ฑฐ๋ ์บ๋ฒ์ค ๋ฐ์ผ๋ก ๋ฒ์ด๋ฌ์ ๋ ์์
์ข
๋ฃ
|
1017 |
+
window.addEventListener('mouseup', function(e) {
|
1018 |
+
isDragging = false;
|
1019 |
+
isRotating = false;
|
1020 |
+
isResizing = false;
|
1021 |
+
activeHandle = null; // ํ์ฑ ํธ๋ค ์์
|
1022 |
+
|
1023 |
+
// ๋ง์ฐ์ค ์ขํ๊ฐ ์ ํจํ๋ฉด ์ปค์ ๋ชจ์ ์
๋ฐ์ดํธ
|
1024 |
+
if (e.clientX !== undefined && e.clientY !== undefined) {
|
1025 |
+
const { x, y } = getCanvasCoordinates(e.clientX, e.clientY);
|
1026 |
+
updateCursor(x, y);
|
1027 |
+
} else {
|
1028 |
+
// ์ขํ๊ฐ ์ ํจํ์ง ์์ผ๋ฉด ๊ธฐ๋ณธ ์ปค์๋ก ์ค์
|
1029 |
+
canvas.style.cursor = 'default';
|
1030 |
+
}
|
1031 |
+
});
|
1032 |
+
|
1033 |
+
|
1034 |
+
// ํฐ์น ์ด๋ฒคํธ (๋ง์ฐ์ค ์ด๋ฒคํธ๋ฅผ ์๋ฎฌ๋ ์ด์
ํ์ฌ ์ฒ๋ฆฌ)
|
1035 |
+
canvas.addEventListener('touchstart', function(e) {
|
1036 |
+
e.preventDefault(); // ๊ธฐ๋ณธ ํฐ์น ๋์ ๋ฐฉ์ง (์คํฌ๋กค ๋ฑ)
|
1037 |
+
if (e.touches.length > 0) {
|
1038 |
+
const touch = e.touches[0];
|
1039 |
+
// ์ฒซ ๋ฒ์งธ ํฐ์น ์ ๋ณด๋ฅผ ์ฌ์ฉํ์ฌ mousedown ์ด๋ฒคํธ ์์ฑ ๋ฐ ๋ฐ์
|
1040 |
+
const mouseEvent = new MouseEvent('mousedown', { clientX: touch.clientX, clientY: touch.clientY, buttons: 1 });
|
1041 |
+
canvas.dispatchEvent(mouseEvent);
|
1042 |
+
}
|
1043 |
+
}, { passive: false }); // passive: false๋ก ์ค์ ํ์ฌ preventDefault()๊ฐ ๋์ํ๋๋ก ํจ
|
1044 |
+
|
1045 |
+
canvas.addEventListener('touchmove', function(e) {
|
1046 |
+
e.preventDefault(); // ๊ธฐ๋ณธ ํฐ์น ๋์ ๋ฐฉ์ง
|
1047 |
+
if (e.touches.length > 0) {
|
1048 |
+
const touch = e.touches[0];
|
1049 |
+
// ์ฒซ ๋ฒ์งธ ํฐ์น ์ ๋ณด๋ฅผ ์ฌ์ฉํ์ฌ mousemove ์ด๋ฒคํธ ์์ฑ ๋ฐ ๋ฐ์
|
1050 |
+
const mouseEvent = new MouseEvent('mousemove', { clientX: touch.clientX, clientY: touch.clientY, buttons: 1 });
|
1051 |
+
canvas.dispatchEvent(mouseEvent);
|
1052 |
+
}
|
1053 |
+
}, { passive: false });
|
1054 |
+
|
1055 |
+
canvas.addEventListener('touchend', function(e) {
|
1056 |
+
e.preventDefault(); // ๊ธฐ๋ณธ ํฐ์น ๋์ ๋ฐฉ์ง
|
1057 |
+
// mouseup ์ด๋ฒคํธ ์์ฑ ๋ฐ ๋ฐ์ (์ขํ ์ ๋ณด๋ ํ์ ์์)
|
1058 |
+
const mouseEvent = new MouseEvent('mouseup', {});
|
1059 |
+
window.dispatchEvent(mouseEvent); // window์ ์ด๋ฒคํธ๋ฅผ ๋ฐ์์์ผ mouseup ๋ฆฌ์ค๋๊ฐ ๋์ํ๋๋ก ํจ
|
1060 |
+
}, { passive: false });
|
1061 |
+
|
1062 |
+
|
1063 |
+
// ํฉ์ฑ ๋ฒํผ ์ด๋ฒคํธ
|
1064 |
+
generateBtn.addEventListener('click', function() {
|
1065 |
+
generateMergedImage(); // ํฉ์ฑ ์ด๋ฏธ์ง ์์ฑ ๋ฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์ ํ์
|
1066 |
+
// ์ด ๋ฒํผ ํด๋ฆญ ์ UI ๋ ์ด์์์ ๋ณ๊ฒฝํ๋ ์ฝ๋๋ ์ฌ๊ธฐ์ ์์ต๋๋ค.
|
1067 |
+
// ์ค์ง generateMergedImage() ํจ์๋ง ํธ์ถํฉ๋๋ค.
|
1068 |
+
});
|
1069 |
+
|
1070 |
+
// ์ ์ฒด ์ด๊ธฐํ ๋ฒํผ ์ด๋ฒคํธ
|
1071 |
+
resetAllBtn.addEventListener('click', function() {
|
1072 |
+
backgroundImage = null; // ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง ์ด๊ธฐํ
|
1073 |
+
overlays = []; // ์ค๋ฒ๋ ์ด ๋ฐฐ์ด ์ด๊ธฐํ
|
1074 |
+
activeOverlayIndex = -1; // ํ์ฑ ๋ ์ด์ด ํด์
|
1075 |
+
backgroundInput.value = ''; // ํ์ผ input ๊ฐ ์ด๊ธฐํ
|
1076 |
+
overlayInput.value = '';
|
1077 |
+
|
1078 |
+
updateControlPanel(); // ์ปจํธ๋กค ํจ๋ ์ด๊ธฐํ
|
1079 |
+
updateLayersList(); // ๋ ์ด์ด ๋ชฉ๋ก ์ด๊ธฐํ
|
1080 |
+
|
1081 |
+
// ํํฐ ์ปจํธ๋กค ์ด๊ธฐ๊ฐ์ผ๋ก ์ค์
|
1082 |
+
const defaultFilters = ImageFilters.resetFilters(overlays, activeOverlayIndex); // (์ฌ์ค์ overlays๊ฐ ๋น์ด ์์ผ๋ฏ๋ก ๊ธฐ๋ณธ๊ฐ ๋ฐํ)
|
1083 |
+
temperatureSlider.value = defaultFilters.temperature; temperatureValue.textContent = defaultFilters.temperature;
|
1084 |
+
brightnessSlider.value = defaultFilters.brightness; brightnessValue.textContent = defaultFilters.brightness + '%';
|
1085 |
+
contrastSlider.value = defaultFilters.contrast; contrastValue.textContent = defaultFilters.contrast + '%';
|
1086 |
+
saturationSlider.value = defaultFilters.saturation; saturationValue.textContent = defaultFilters.saturation + '%';
|
1087 |
+
|
1088 |
+
// ๏ฟฝ๏ฟฝ๏ฟฝ๋ฒ์ค ํฌ๊ธฐ ๋ฐ ์ด๊ธฐ ์ํ๋ก ์ฌ์ค์
|
1089 |
+
canvasAdjustedHeight = CANVAS_HEIGHT;
|
1090 |
+
canvas.height = canvasAdjustedHeight;
|
1091 |
+
initCanvas(); // ์บ๋ฒ์ค ํฐ์ ๋ฐฐ๊ฒฝ์ผ๋ก ์ด๊ธฐํ
|
1092 |
+
|
1093 |
+
previewContainer.style.display = 'none'; // ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์์ญ ์จ๊น
|
1094 |
+
});
|
1095 |
+
|
1096 |
+
// ๋ค์ด๋ก๋ ๋ฒํผ ์ด๋ฒคํธ
|
1097 |
+
downloadBtn.addEventListener('click', function() {
|
1098 |
+
const resultCanvas = generateMergedImage(); // ํฉ์ฑ ์ด๋ฏธ์ง ์์ฑ
|
1099 |
+
if (!resultCanvas) return; // ์ด๋ฏธ์ง๊ฐ ์์ผ๋ฉด ๋ค์ด๋ก๋ํ์ง ์์
|
1100 |
+
|
1101 |
+
const link = document.createElement('a'); // ๋ค์ด๋ก๋๋ฅผ ์ํ ์์ ๋งํฌ ์์ ์์ฑ
|
1102 |
+
// ํ์ผ ์ด๋ฆ ์์ฑ (ํ์ฌ ์๊ฐ ๊ธฐ๋ฐ)
|
1103 |
+
const timestamp = new Date().toISOString().replace(/[-:.]/g, '').substring(0, 14);
|
1104 |
+
// ์ด๋ฏธ์ง ํฌ๋งท ๋ฐ ํ์ฅ์ ๊ฒฐ์ (์๋ณธ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง ํฌ๋งท ๋ฐ๋ฆ)
|
1105 |
+
const mimeType = originalFormat === 'jpg' ? 'image/jpeg' : `image/${originalFormat}`;
|
1106 |
+
const fileExt = originalFormat;
|
1107 |
+
|
1108 |
+
link.download = `merged_image_${timestamp}.${fileExt}`; // ๋ค์ด๋ก๋๋ ํ์ผ ์ด๋ฆ ์ค์
|
1109 |
+
// ์บ๋ฒ์ค ์ด๋ฏธ์ง๋ฅผ Data URL๋ก ๋ณํํ์ฌ ๋งํฌ์ href๋ก ์ค์
|
1110 |
+
link.href = resultCanvas.toDataURL(mimeType, 1.0); // 1.0์ ํ์ง (PNG๋ ์ํฅ ์์, JPG๋ 0~1)
|
1111 |
+
|
1112 |
+
link.click(); // ๋งํฌ ํด๋ฆญ ์ด๋ฒคํธ๋ฅผ ๋ฐ์์์ผ ๋ค์ด๋ก๋ ์คํ
|
1113 |
+
});
|
1114 |
+
|
1115 |
+
|
1116 |
+
// ํ์ด์ง ๋ก๋ ์ ์ด๊ธฐํ ํจ์ ํธ์ถ
|
1117 |
+
initCanvas(); // ์บ๋ฒ์ค ์ด๊ธฐ ์ํ๋ก ์ค์
|
1118 |
+
updateControlPanel(); // ์ปจํธ๋กค ํจ๋ ์ด๊ธฐ ์ํ๋ก ์ค์ (๋ฒํผ ๋นํ์ฑํ ๋ฑ)
|
1119 |
+
|
1120 |
+
}); // DOMContentLoaded ๋
|
style.css
CHANGED
@@ -1,28 +1,301 @@
|
|
1 |
body {
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
}
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
}
|
10 |
|
11 |
p {
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
|
18 |
-
.
|
19 |
-
|
20 |
-
margin: 0 auto;
|
21 |
-
padding: 16px;
|
22 |
-
border: 1px solid lightgray;
|
23 |
-
border-radius: 16px;
|
24 |
}
|
25 |
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
body {
|
2 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
3 |
+
line-height: 1.6;
|
4 |
+
margin: 0;
|
5 |
+
padding: 0;
|
6 |
+
background-color: #f0f0f0;
|
7 |
+
color: #333;
|
8 |
}
|
9 |
|
10 |
+
.container {
|
11 |
+
max-width: 1200px; /* ํ์ด์ง ์ ์ฒด ์ปจํ
์ด๋ ์ต๋ ๋๋น */
|
12 |
+
margin: 20px auto;
|
13 |
+
padding: 20px;
|
14 |
+
background-color: white;
|
15 |
+
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
16 |
+
border-radius: 8px;
|
17 |
+
display: flex;
|
18 |
+
flex-direction: column;
|
19 |
+
}
|
20 |
+
|
21 |
+
h1, h2, h3 {
|
22 |
+
color: #2c3e50;
|
23 |
+
text-align: center;
|
24 |
}
|
25 |
|
26 |
p {
|
27 |
+
text-align: center;
|
28 |
+
margin-bottom: 20px;
|
29 |
+
}
|
30 |
+
|
31 |
+
.upload-container {
|
32 |
+
display: flex;
|
33 |
+
flex-wrap: wrap;
|
34 |
+
justify-content: space-around;
|
35 |
+
margin-bottom: 20px;
|
36 |
+
gap: 20px;
|
37 |
+
}
|
38 |
+
|
39 |
+
.upload-box {
|
40 |
+
flex: 1;
|
41 |
+
min-width: 300px;
|
42 |
+
border: 2px dashed #3498db;
|
43 |
+
border-radius: 5px;
|
44 |
+
padding: 20px;
|
45 |
+
text-align: center;
|
46 |
+
transition: background-color 0.3s;
|
47 |
+
}
|
48 |
+
|
49 |
+
.upload-box:hover {
|
50 |
+
background-color: #ecf0f1;
|
51 |
+
}
|
52 |
+
|
53 |
+
.upload-label {
|
54 |
+
display: block;
|
55 |
+
font-weight: bold;
|
56 |
+
margin-bottom: 10px;
|
57 |
+
color: #2980b9;
|
58 |
+
}
|
59 |
+
|
60 |
+
.file-input {
|
61 |
+
display: none;
|
62 |
+
}
|
63 |
+
|
64 |
+
.upload-button {
|
65 |
+
display: inline-block;
|
66 |
+
background-color: #3498db;
|
67 |
+
color: white;
|
68 |
+
padding: 10px 20px;
|
69 |
+
border-radius: 5px;
|
70 |
+
cursor: pointer;
|
71 |
+
transition: background-color 0.3s;
|
72 |
+
}
|
73 |
+
|
74 |
+
.upload-button:hover {
|
75 |
+
background-color: #2980b9;
|
76 |
+
}
|
77 |
+
|
78 |
+
/* ์์
์์ญ ๋ํผ */
|
79 |
+
.workspace-wrapper {
|
80 |
+
display: flex; /* ์บ๋ฒ์ค+์ปจํธ๋กค ์์ญ๊ณผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์์ญ์ ๊ฐ๋ก๋ก ๋ฐฐ์น */
|
81 |
+
flex-wrap: wrap; /* ํ๋ฉด์ด ์์ ๊ฒฝ์ฐ ์ค๋ฐ๊ฟ ํ์ฉ */
|
82 |
+
gap: 20px;
|
83 |
+
margin-bottom: 20px;
|
84 |
+
}
|
85 |
+
|
86 |
+
/* ์บ๋ฒ์ค์ ์ปจํธ๋กค ํจ๋๋ค์ ๋ฌถ๋ ์์ญ */
|
87 |
+
.canvas-and-controls {
|
88 |
+
flex: 3; /* ๊ฐ๋ก ๋ฐฐ์น ์ ๋น์จ (์บ๋ฒ์ค ์์ญ์ด ๋ ๋๊ฒ) */
|
89 |
+
display: flex;
|
90 |
+
flex-direction: column; /* ์บ๋ฒ์ค ์๋์ ์ปจํธ๋กค ํจ๋ ๋ฐฐ์น (ํ์์ ๊ตฌ์กฐ ๋ณ๊ฒฝ) */
|
91 |
+
min-width: 0; /* flex item์ ๋ด์ฉ์ด ๋์น ๋ ์์ถํ๋๋ก ํจ */
|
92 |
+
}
|
93 |
+
|
94 |
+
.canvas-container {
|
95 |
+
position: relative;
|
96 |
+
width: 100%; /* ๋ถ๋ชจ ๋๋น์ ๋ง์ถค */
|
97 |
+
/* max-width: 800px; /* ์บ๋ฒ์ค ์ต๋ ๋๋น๋ JS์์ ์ค์ ๋ CANVAS_WIDTH์ ๋ฐ๋ฆ */
|
98 |
+
border: 2px solid #333;
|
99 |
+
border-radius: 4px;
|
100 |
+
overflow: hidden; /* ์บ๋ฒ์ค๊ฐ ๋์น์ง ์๋๋ก */
|
101 |
+
margin-bottom: 20px; /* ์ปจํธ๋กค ํจ๋๊ณผ์ ๊ฐ๊ฒฉ */
|
102 |
+
}
|
103 |
+
|
104 |
+
#canvas {
|
105 |
+
display: block; /* ํ๋จ ์ฌ๋ฐฑ ์ ๊ฑฐ */
|
106 |
+
width: 100%; /* canvas-container์ ๊ฝ ์ฐจ๊ฒ */
|
107 |
+
height: auto; /* ๋น์จ ์ ์ง */
|
108 |
+
background-color: #ffffff;
|
109 |
+
cursor: default;
|
110 |
+
}
|
111 |
+
|
112 |
+
/* ์ปจํธ๋กค ํจ๋๋ค์ ๋ชจ์๋๋ ์ฌ์ด๋๋ฐ ์ญํ (๋๋ ์บ๋ฒ์ค ์๋ ์์ญ) */
|
113 |
+
.control-panel-sidebar {
|
114 |
+
display: flex;
|
115 |
+
flex-direction: column;
|
116 |
+
gap: 15px;
|
117 |
+
/* flex: 1; /* canvas-and-controls ๋ด์์ ๋น์จ (ํ์์) */
|
118 |
+
}
|
119 |
+
|
120 |
+
|
121 |
+
.control-group {
|
122 |
+
display: flex;
|
123 |
+
flex-direction: column;
|
124 |
+
/* align-items: center; ํญ๋ชฉ๋ค์ด ์ค์ ์ ๋ ฌ๋์ง ์๋๋ก ์ ๊ฑฐ ๋๋ ์์ */
|
125 |
+
border: 1px solid #ddd;
|
126 |
+
padding: 15px;
|
127 |
+
border-radius: 5px;
|
128 |
+
background-color: #f9f9f9;
|
129 |
+
/* min-width: 250px; /* ์ต์ ๋๋น๋ ์ํฉ์ ๋ฐ๋ผ ์กฐ์ */
|
130 |
+
}
|
131 |
+
|
132 |
+
.control-group h3 {
|
133 |
+
margin: 0 0 15px 0;
|
134 |
+
font-size: 1rem;
|
135 |
+
text-align: center;
|
136 |
+
width: 100%;
|
137 |
+
}
|
138 |
+
|
139 |
+
.slider-container {
|
140 |
+
display: flex;
|
141 |
+
align-items: center;
|
142 |
+
gap: 10px;
|
143 |
+
margin: 8px 0;
|
144 |
+
width: 100%;
|
145 |
+
padding: 0 5px;
|
146 |
+
box-sizing: border-box;
|
147 |
+
}
|
148 |
+
|
149 |
+
.slider-container label {
|
150 |
+
font-weight: bold;
|
151 |
+
min-width: 50px; /* "ํ์ :" ๋ฑ ๋ ์ด๋ธ์ด ์๋ฆฌ์ง ์๋๋ก ์ถฉ๋ถํ */
|
152 |
+
text-align: left;
|
153 |
+
flex-shrink: 0;
|
154 |
+
}
|
155 |
+
|
156 |
+
.slider-container input[type="range"] {
|
157 |
+
flex-grow: 1; /* ์ฌ๋ผ์ด๋๊ฐ ๋จ์ ๊ณต๊ฐ์ ๋ชจ๋ ์ฐจ์ง */
|
158 |
+
width: auto; /* flex-grow๊ฐ ์๋ํ๋๋ก auto๋ก ์ค์ */
|
159 |
+
margin: 0 5px; /* ์ข์ฐ ์ฝ๊ฐ์ ์ฌ๋ฐฑ */
|
160 |
+
}
|
161 |
+
|
162 |
+
.slider-container .value-display {
|
163 |
+
min-width: 40px; /* ๊ฐ ํ์ ์์ญ ๋๋น */
|
164 |
+
text-align: right; /* ๊ฐ์ ์ค๋ฅธ์ชฝ์ ํ์ */
|
165 |
+
flex-shrink: 0;
|
166 |
+
}
|
167 |
+
|
168 |
+
/* ๋ ์ด์ด ๋ชฉ๋ก ์คํ์ผ */
|
169 |
+
.layers-list {
|
170 |
+
width: 100%;
|
171 |
+
max-height: 150px;
|
172 |
+
overflow-y: auto;
|
173 |
+
border: 1px solid #ddd;
|
174 |
+
border-radius: 4px;
|
175 |
+
}
|
176 |
+
|
177 |
+
.layer-item {
|
178 |
+
padding: 8px;
|
179 |
+
border-bottom: 1px solid #eee;
|
180 |
+
cursor: pointer;
|
181 |
+
display: flex;
|
182 |
+
justify-content: space-between;
|
183 |
+
align-items: center;
|
184 |
+
}
|
185 |
+
.layer-item:last-child { border-bottom: none; }
|
186 |
+
.layer-item:hover { background-color: #f5f5f5; }
|
187 |
+
.layer-item.active { background-color: #e3f2fd; font-weight: bold; }
|
188 |
+
.layer-name { flex-grow: 1; padding-left: 5px; }
|
189 |
+
.layer-controls { display: flex; gap: 5px; }
|
190 |
+
.layer-button {
|
191 |
+
background-color: #f0f0f0; border: 1px solid #ddd; border-radius: 3px;
|
192 |
+
padding: 2px 5px; cursor: pointer; font-size: 11px; color: #555;
|
193 |
+
transition: all 0.2s ease;
|
194 |
+
}
|
195 |
+
.layer-button:hover { background-color: #e0e0e0; }
|
196 |
+
|
197 |
+
|
198 |
+
/* ํํฐ ํจ๋ ์คํ์ผ */
|
199 |
+
.filter-panel {
|
200 |
+
/* width: 100%; /* ๋ถ๋ชจ(.control-panel-sidebar)์ ์ํด ๋๋น ๊ฒฐ์ */
|
201 |
+
padding: 15px;
|
202 |
+
border: 1px solid #ddd;
|
203 |
+
border-radius: 5px;
|
204 |
+
background-color: #f9f9f9;
|
205 |
+
}
|
206 |
+
.filter-panel h3 { margin: 0 0 15px 0; text-align: center; }
|
207 |
+
.filter-sliders { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; }
|
208 |
+
.filter-slider-container { display: flex; flex-direction: column; gap: 5px; width: 100%; padding: 0 5px; box-sizing: border-box; }
|
209 |
+
.filter-slider-container label { font-size: 14px; margin-bottom: 5px; text-align: left; }
|
210 |
+
.large-slider { width: 100%; height: 20px; /* ์ฌ๋ผ์ด๋ ๋์ด ์กฐ์ */ }
|
211 |
+
.filter-slider-container .value-display { text-align: right; font-weight: bold; }
|
212 |
+
.filter-buttons { display: flex; justify-content: center; margin-top: 15px; }
|
213 |
+
#reset-filter-btn { width: auto; padding: 8px 15px; flex-grow: 1; max-width: 200px; }
|
214 |
+
|
215 |
+
|
216 |
+
/* ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์น์
*/
|
217 |
+
.preview-section {
|
218 |
+
flex: 2; /* ๊ฐ๋ก ๋ฐฐ์น ์ ๋น์จ (์บ๋ฒ์ค ์์ญ๋ณด๋ค ์๊ฒ) */
|
219 |
+
display: flex; /* ๋ด๋ถ ์ปจํ
์ด๋ ์ ๋ ฌ ์ํจ */
|
220 |
+
flex-direction: column;
|
221 |
+
align-items: center; /* ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์ปจํ
์ด๋๋ฅผ ์ค์์ */
|
222 |
+
min-width: 0; /* flex item์ ๋ด์ฉ์ด ๋์น ๋ ์์ถํ๋๋ก ํจ */
|
223 |
+
}
|
224 |
+
|
225 |
+
.preview-container {
|
226 |
+
width: 100%; /* preview-section ๋๋น์ ๋ง์ถค */
|
227 |
+
margin-top: 0; /* workspace-wrapper์์ gap์ผ๋ก ์ฒ๋ฆฌ */
|
228 |
+
display: none; /* ์ด๊ธฐ์๋ ์จ๊น (JS๋ก ์ ์ด) */
|
229 |
+
flex-direction: column;
|
230 |
+
align-items: center;
|
231 |
+
padding: 10px;
|
232 |
+
border: 1px dashed #ccc;
|
233 |
+
border-radius: 4px;
|
234 |
+
background-color: #f9f9f9;
|
235 |
}
|
236 |
|
237 |
+
.preview-container h3 {
|
238 |
+
margin-bottom: 10px;
|
|
|
|
|
|
|
|
|
239 |
}
|
240 |
|
241 |
+
#preview-img {
|
242 |
+
max-width: 100%;
|
243 |
+
max-height: 400px; /* ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์ด๋ฏธ์ง ์ต๋ ๋์ด ์ ํ */
|
244 |
+
border: 2px solid #333;
|
245 |
+
border-radius: 4px;
|
246 |
+
object-fit: contain; /* ์ด๋ฏธ์ง ๋น์จ ์ ์ง */
|
247 |
}
|
248 |
+
|
249 |
+
/* ํ๋จ ๋ฒํผ ์ปจํ
์ด๋ */
|
250 |
+
.button-container {
|
251 |
+
display: flex;
|
252 |
+
justify-content: center;
|
253 |
+
gap: 15px;
|
254 |
+
margin-top: 20px; /* workspace-wrapper ์์ ๊ฐ๊ฒฉ */
|
255 |
+
flex-wrap: wrap;
|
256 |
+
}
|
257 |
+
|
258 |
+
button {
|
259 |
+
padding: 10px 20px;
|
260 |
+
border: none;
|
261 |
+
border-radius: 5px;
|
262 |
+
cursor: pointer;
|
263 |
+
font-weight: bold;
|
264 |
+
transition: background-color 0.3s;
|
265 |
+
}
|
266 |
+
.primary-btn { background-color: #27ae60; color: white; }
|
267 |
+
.primary-btn:hover { background-color: #219653; }
|
268 |
+
.danger-btn { background-color: #e74c3c; color: white; }
|
269 |
+
.danger-btn:hover { background-color: #c0392b; }
|
270 |
+
.info-btn { background-color: #3498db; color: white; }
|
271 |
+
.info-btn:hover { background-color: #2980b9; }
|
272 |
+
|
273 |
+
|
274 |
+
/* ๋ชจ๋ฐ์ผ ๋์ */
|
275 |
+
@media (max-width: 900px) { /* ์ข ๋ ๋์ ํ๋ฉด์์๋ถํฐ ๋ ์ด์์ ๋ณ๊ฒฝ ๊ณ ๋ ค */
|
276 |
+
.workspace-wrapper {
|
277 |
+
flex-direction: column; /* ์์
์์ญ๊ณผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ๋ฅผ ์ธ๋ก๋ก ๋ฐฐ์น */
|
278 |
+
align-items: center; /* ์ค์ ์ ๋ ฌ */
|
279 |
+
}
|
280 |
+
.canvas-and-controls, .preview-section {
|
281 |
+
flex-basis: auto; /* flex ๋น์จ ์ด๊ธฐํ */
|
282 |
+
width: 100%; /* ์ ์ฒด ๋๋น ์ฌ์ฉ */
|
283 |
+
max-width: 600px; /* ๋ชจ๋ฐ์ผ์์ ๋๋ฌด ๋์ด์ง์ง ์๋๋ก */
|
284 |
+
}
|
285 |
+
.control-panel-sidebar {
|
286 |
+
width: 100%; /* ์ ์ฒด ๋๋น ์ฌ์ฉ */
|
287 |
+
}
|
288 |
+
.filter-sliders {
|
289 |
+
grid-template-columns: 1fr; /* ํํฐ ์ฌ๋ผ์ด๋ ํ ์ค๋ก */
|
290 |
+
}
|
291 |
+
}
|
292 |
+
|
293 |
+
@media (max-width: 768px) {
|
294 |
+
.upload-container {
|
295 |
+
flex-direction: column;
|
296 |
+
}
|
297 |
+
.upload-box {
|
298 |
+
width: 100%;
|
299 |
+
margin-bottom: 10px;
|
300 |
+
}
|
301 |
+
}
|