Clear canvas
Browse files- src/routes/+page.svelte +24 -4
src/routes/+page.svelte
CHANGED
@@ -93,7 +93,7 @@
|
|
93 |
const { imgFile, imgBitmap: initialSketchBitmap } = await getCanvasSnapshot(canvas);
|
94 |
const form = new FormData();
|
95 |
form.append('prompt', txt);
|
96 |
-
form.append('strength',
|
97 |
form.append('image', imgFile);
|
98 |
|
99 |
try {
|
@@ -149,7 +149,7 @@
|
|
149 |
}, 2500);
|
150 |
|
151 |
if (!isOutputControlAdded && imgEls.length > 1) {
|
152 |
-
|
153 |
}
|
154 |
} catch (err) {
|
155 |
console.error(err);
|
@@ -157,7 +157,7 @@
|
|
157 |
}
|
158 |
}
|
159 |
|
160 |
-
function
|
161 |
const div = document.createElement('div');
|
162 |
div.className = 'drawing-board-control';
|
163 |
|
@@ -178,6 +178,23 @@
|
|
178 |
}
|
179 |
}
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
function copySketch() {
|
182 |
const context = sketchEl.getContext('2d');
|
183 |
|
@@ -250,6 +267,7 @@
|
|
250 |
e.preventDefault();
|
251 |
return false;
|
252 |
};
|
|
|
253 |
});
|
254 |
</script>
|
255 |
|
@@ -284,7 +302,9 @@
|
|
284 |
diffuse the f rest
|
285 |
</button>
|
286 |
</div>
|
287 |
-
<p class="no-hover:hidden mt-2 opacity-50">
|
|
|
|
|
288 |
<div class="mt-1">
|
289 |
<label class="with-hover:hidden border py-1 px-1.5 bg-slate-200 cursor-pointer">
|
290 |
<input
|
|
|
93 |
const { imgFile, imgBitmap: initialSketchBitmap } = await getCanvasSnapshot(canvas);
|
94 |
const form = new FormData();
|
95 |
form.append('prompt', txt);
|
96 |
+
form.append('strength', '0.85');
|
97 |
form.append('image', imgFile);
|
98 |
|
99 |
try {
|
|
|
149 |
}, 2500);
|
150 |
|
151 |
if (!isOutputControlAdded && imgEls.length > 1) {
|
152 |
+
addOutputControl();
|
153 |
}
|
154 |
} catch (err) {
|
155 |
console.error(err);
|
|
|
157 |
}
|
158 |
}
|
159 |
|
160 |
+
function addOutputControl() {
|
161 |
const div = document.createElement('div');
|
162 |
div.className = 'drawing-board-control';
|
163 |
|
|
|
178 |
}
|
179 |
}
|
180 |
|
181 |
+
function addClearCanvasControl() {
|
182 |
+
const div = document.createElement('div');
|
183 |
+
div.className = 'drawing-board-control';
|
184 |
+
|
185 |
+
const btn = document.createElement('button');
|
186 |
+
btn.innerHTML = '🧹';
|
187 |
+
btn.onclick = () => {
|
188 |
+
ctx?.clearRect(0, 0, canvasSize, canvasSize);
|
189 |
+
};
|
190 |
+
div.append(btn);
|
191 |
+
|
192 |
+
const controlsEl = document.querySelector('.drawing-board-controls');
|
193 |
+
if (controlsEl) {
|
194 |
+
controlsEl.appendChild(div);
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
function copySketch() {
|
199 |
const context = sketchEl.getContext('2d');
|
200 |
|
|
|
267 |
e.preventDefault();
|
268 |
return false;
|
269 |
};
|
270 |
+
addClearCanvasControl();
|
271 |
});
|
272 |
</script>
|
273 |
|
|
|
302 |
diffuse the f rest
|
303 |
</button>
|
304 |
</div>
|
305 |
+
<p class="no-hover:hidden mt-2 opacity-50">
|
306 |
+
pro tip: upload img by pasting OR dropping on the canvas
|
307 |
+
</p>
|
308 |
<div class="mt-1">
|
309 |
<label class="with-hover:hidden border py-1 px-1.5 bg-slate-200 cursor-pointer">
|
310 |
<input
|