freealise commited on
Commit
bb56c78
1 Parent(s): 4c928fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -352,7 +352,7 @@ with gr.Blocks(css=css) as demo:
352
  processed_zip = gr.File(label="Output Archive")
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="""
355
- <svg id='svg_in' height='128' width='256' viewBox='0 0 256 128' onpointerup='document.getElementsByTagName(\"input[type=text]\")[1].value=document.getElementById(\"pl\").getAttribute(\"points\")' onpointermove='try{window.chartPoints(event.clientX-this.getBoundingClientRect().x, event.clientY-this.getBoundingClientRect().y);}catch(e){alert(e);}' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;'>
356
  <defs>
357
  <linearGradient id="lg" x1="0%" x2="100%" y1="0%" y2="0%">
358
  <stop offset="0%" stop-color="white"/>
@@ -368,12 +368,17 @@ with gr.Blocks(css=css) as demo:
368
  pts += i+','+Math.sin(i/256*Math.PI/2)*127+' ';
369
  }
370
  pl.setAttribute('points', pts);
371
- }catch(e){alert(e);}
372
- window.chartPoints = function(x,y) {
 
373
  var pl_a = pl.getAttribute('points').split(' ');
374
  pl_a[x] = x+','+y;
375
  pl.setAttribute('points', pl_a.join(' '));
376
  }
 
 
 
 
377
  </script>""")
378
  txt_in = gr.Textbox(value="")
379
  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='
 
352
  processed_zip = gr.File(label="Output Archive")
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="""
355
+ <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;'>
356
  <defs>
357
  <linearGradient id="lg" x1="0%" x2="100%" y1="0%" y2="0%">
358
  <stop offset="0%" stop-color="white"/>
 
368
  pts += i+','+Math.sin(i/256*Math.PI/2)*127+' ';
369
  }
370
  pl.setAttribute('points', pts);
371
+ document.getElementById('svg_in').onpointermove = function(event) {
372
+ var x = event.clientX - event.target.getBoundingClientRect().x;
373
+ var y = event.clientY - event.target.getBoundingClientRect().y;
374
  var pl_a = pl.getAttribute('points').split(' ');
375
  pl_a[x] = x+','+y;
376
  pl.setAttribute('points', pl_a.join(' '));
377
  }
378
+ document.getElementById('svg_in').onpointerup = function(event) {
379
+ document.getElementsByTagName('input[type=text]')[1].value = document.getElementById('pl').getAttribute('points');
380
+ }
381
+ }catch(e){alert(e);}
382
  </script>""")
383
  txt_in = gr.Textbox(value="")
384
  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='