-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
200 lines (186 loc) · 6.05 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
color: white;
background-color: rgba(40,40,40,1);
}
.container {
text-align: center;
margin: 50px;
}
#image-container {
position: relative;
display: inline-block;
}
#image {
width: 100%;
height: auto;
border: 8px solid black;
filter: none; /* Initial state */
transform: none;
}
#filter-options {
position: relative;
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
/* Wrap potentially overflowing text in the CSS code block */
#css-code {
white-space: pre-wrap;
}
.filter-option {
display: inline-block;
margin: 10px;
}
/* Adjust the width of the sliders */
input[type="range"] {
width: 100%;
}
</style>
</head>
<body>
<div class="container">
<!-- Image loading section -->
<div id="image-loading">
<label for="image-url">Enter Image location relatve to this html file, or a URL:</label>
<input type="text" id="image-url" placeholder="images/pic.jpg">
<button id="load-button">Load</button>
</div>
<br>
<div id="filter-options">
<div class="filter-option">
<label for="zoom">Zoom:</label>
<input type="range" id="zoom" min="10" max="150" value="100">
<span id="zoom-value">100</span> %
</div>
<br>
<!-- Image display section -->
<div id="image-container">
<img id="image" src="images/pic.jpg" alt="Image">
</div>
<br>
<div class="filter-option">
<label for="rotation">Rotation:</label>
<input type="range" id="rotation" min="0" max="360" value="0">
<span id="rotation-value">0</span> degrees
</div>
<br>
<div class="filter-option">
<label for="blur">Blur:</label>
<input type="range" id="blur" min="0" max="20" step="0.1" value="0">
<span id="blur-value">0</span>
</div>
<br>
<div class="filter-option">
<label for="hue">Hue:</label>
<input type="range" id="hue" min="0" max="360" value="0">
<span id="hue-value">0</span> degrees
</div>
<br>
<div class="filter-option">
<label for="invert">Invert:</label>
<input type="checkbox" id="invert">
</div>
<div class="filter-option">
<label for="saturate">Saturate:</label>
<input type="text" id="saturate" value="100">
</div>
<div class="filter-option">
<label for="brightness">Brightness:</label>
<input type="text" id="brightness" value="100">
</div>
<div class="filter-option">
<label for="contrast">Contrast:</label>
<input type="text" id="contrast" value="100">
</div>
<br>
<button id="apply-button">Apply</button>
<button id="revert-button">Revert</button>
</div>
<pre id="css-code" style="border: 2px solid black; padding: 4px;">
/* CSS code will be displayed here */
</pre>
</div>
<script>
const imageUrlInput = document.getElementById('image-url');
const loadButton = document.getElementById('load-button');
const image = document.getElementById('image');
const zoomInput = document.getElementById('zoom');
const zoomValueSpan = document.getElementById('zoom-value');
const rotationInput = document.getElementById('rotation');
const rotationValueSpan = document.getElementById('rotation-value');
const hueInput = document.getElementById('hue');
const hueValueSpan = document.getElementById('hue-value');
const blurInput = document.getElementById('blur');
const blurValueSpan = document.getElementById('blur-value');
const applyButton = document.getElementById('apply-button');
const revertButton = document.getElementById('revert-button');
const cssCodeBlock = document.getElementById('css-code');
loadButton.addEventListener('click', loadNewImage);
zoomInput.addEventListener('input', updateZoomValue);
rotationInput.addEventListener('input', updateRotationValue);
applyButton.addEventListener('click', applyFilters);
revertButton.addEventListener('click', revertFilters);
hueInput.addEventListener('input', updateHueValue);
blurInput.addEventListener('input', updateBlurValue);
function loadNewImage() {
const imageUrl = imageUrlInput.value;
image.src = imageUrl;
}
function applyFilters() {
const zoomValue = zoomInput.value;
const rotationValue = rotationInput.value;
const brightnessValue = document.getElementById('brightness').value;
const contrastValue = document.getElementById('contrast').value;
const hueValue = hueInput.value;
const invertCheckbox = document.getElementById('invert');
const invertValue = invertCheckbox.checked ? 100 : 0;
const saturateValue = document.getElementById('saturate').value;
const blurValue = blurInput.value;
// Add more filter values here
const filters = `brightness(${brightnessValue}%) contrast(${contrastValue}%) hue-rotate(${hueValue}deg) saturate(${saturateValue}%) invert(${invertValue}%) blur(${blurValue}px)`;
const transform = `rotate(${rotationValue}deg)`;
image.style.filter = filters;
image.style.transform = transform;
image.style.width = `${zoomValue}%`;
const cssCode = `#image {
filter: ${filters};
transform: ${transform};
width: ${zoomValue}%;
}
- OR put this inside your <img> tag -
style="filter: ${filters}; transform: ${transform}; width: ${zoomValue}%;"`;
cssCodeBlock.textContent = cssCode;
}
function revertFilters() {
image.style.filter = `none`;
}
function updateRotationValue() {
const rotationValue = rotationInput.value;
rotationValueSpan.textContent = `${rotationValue}`;
applyFilters();
}
function updateZoomValue() {
const zoomValue = zoomInput.value;
zoomValueSpan.textContent = `${zoomValue}`;
applyFilters();
}
function updateHueValue() {
const hueValue = hueInput.value;
hueValueSpan.textContent = `${hueValue}`;
applyFilters();
}
function updateBlurValue() {
const blurValue = blurInput.value;
blurValueSpan.textContent = blurValue;
applyFilters();
}
</script>
</body>
</html>