Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -353,7 +353,7 @@ with gr.Blocks(css=css) as demo:
|
|
353 |
result = gr.Model3D(label="3D Mesh", clear_color=[0.5, 0.5, 0.5, 0.0], camera_position=[0, 90, 0])
|
354 |
svg_in = gr.HTML(value="""<svg id='svg_in' height='128' width='256' viewBox='0 0 256 128' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;' onpointerdown='
|
355 |
try{
|
356 |
-
if (document.getElementById(\"pl\").getAttribute(\"points\")
|
357 |
var pts = \"\";
|
358 |
for (var i=0; i<256; i++) {
|
359 |
pts += i+\",\"+Math.sin(i/256*Math.PI/2)*127+\" \";
|
@@ -361,17 +361,24 @@ with gr.Blocks(css=css) as demo:
|
|
361 |
document.getElementById(\"pl\").setAttribute(\"points\", pts);
|
362 |
this.onpointermove = function(event) {
|
363 |
if (this.style.borderBottom == \"1px dotted white\") {
|
364 |
-
var x = event.clientX - event.target.getBoundingClientRect().x;
|
365 |
-
var y = event.clientY - event.target.getBoundingClientRect().y;
|
|
|
|
|
366 |
var pl_a = document.getElementById(\"pl\").getAttribute(\"points\").split(\" \");
|
367 |
pl_a[x] = x+\",\"+y;
|
368 |
document.getElementById(\"pl\").setAttribute(\"points\", pl_a.join(\" \"));
|
369 |
}
|
370 |
}
|
371 |
this.onpointerup = function(event) {
|
372 |
-
|
|
|
|
|
|
|
|
|
373 |
this.style.borderBottom = \"1px dotted black\";
|
374 |
}
|
|
|
375 |
}
|
376 |
this.style.borderBottom = \"1px dotted white\";
|
377 |
}catch(e){alert(e);}
|
@@ -382,9 +389,9 @@ with gr.Blocks(css=css) as demo:
|
|
382 |
<stop offset='100%' stop-color='black'/>
|
383 |
</linearGradient>
|
384 |
</defs>
|
385 |
-
<polyline id='pl' points='
|
386 |
</svg>""")
|
387 |
-
txt_in = gr.Textbox(value="")
|
388 |
html = gr.HTML(value="""<label for='zoom'>Zoom</label><input id='zoom' type='range' style='width:256px;height:1em;' min='0.157' max='1.57' step='0.001' oninput='
|
389 |
BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/this.value));
|
390 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast = 2.0;
|
|
|
353 |
result = gr.Model3D(label="3D Mesh", clear_color=[0.5, 0.5, 0.5, 0.0], camera_position=[0, 90, 0])
|
354 |
svg_in = gr.HTML(value="""<svg id='svg_in' height='128' width='256' viewBox='0 0 256 128' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;' onpointerdown='
|
355 |
try{
|
356 |
+
if (document.getElementById(\"pl\").getAttribute(\"points\").length < 256) {
|
357 |
var pts = \"\";
|
358 |
for (var i=0; i<256; i++) {
|
359 |
pts += i+\",\"+Math.sin(i/256*Math.PI/2)*127+\" \";
|
|
|
361 |
document.getElementById(\"pl\").setAttribute(\"points\", pts);
|
362 |
this.onpointermove = function(event) {
|
363 |
if (this.style.borderBottom == \"1px dotted white\") {
|
364 |
+
var x = parseInt(event.clientX - event.target.getBoundingClientRect().x);
|
365 |
+
var y = parseInt(event.clientY - event.target.getBoundingClientRect().y);
|
366 |
+
if (x < 0) { x = 0; } else if (x > 255) { x = 255; }
|
367 |
+
if (y < 0) { y = 0; } else if (y > 127) { x = 127; }
|
368 |
var pl_a = document.getElementById(\"pl\").getAttribute(\"points\").split(\" \");
|
369 |
pl_a[x] = x+\",\"+y;
|
370 |
document.getElementById(\"pl\").setAttribute(\"points\", pl_a.join(\" \"));
|
371 |
}
|
372 |
}
|
373 |
this.onpointerup = function(event) {
|
374 |
+
var pl_a = document.getElementById(\"pl\").getAttribute(\"points\").replace(/\d+,/g, \"\").split(\" \");
|
375 |
+
for (var i=0; i<pl_a.length; i++) {
|
376 |
+
pl_a[i] = pl_a[i] * 2 + 1;
|
377 |
+
}
|
378 |
+
document.getElementsByTagName(\"textarea\")[1].value = pl_a.join(\" \");
|
379 |
this.style.borderBottom = \"1px dotted black\";
|
380 |
}
|
381 |
+
this.onpointerleave = this.onpointerup;
|
382 |
}
|
383 |
this.style.borderBottom = \"1px dotted white\";
|
384 |
}catch(e){alert(e);}
|
|
|
389 |
<stop offset='100%' stop-color='black'/>
|
390 |
</linearGradient>
|
391 |
</defs>
|
392 |
+
<polyline id='pl' points='-3,0 0,127 255,127 258,0' stroke='url(#lg)' fill='none' stroke-width='3'/>
|
393 |
</svg>""")
|
394 |
+
txt_in = gr.Textbox(value="", label="Blur kernel size")
|
395 |
html = gr.HTML(value="""<label for='zoom'>Zoom</label><input id='zoom' type='range' style='width:256px;height:1em;' min='0.157' max='1.57' step='0.001' oninput='
|
396 |
BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/this.value));
|
397 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast = 2.0;
|