freealise commited on
Commit
e0cd9be
1 Parent(s): bb56c78

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -18
app.py CHANGED
@@ -352,34 +352,33 @@ 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' 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"/>
359
- <stop offset="100%" stop-color="black"/>
360
- </linearGradient>
361
- </defs>
362
- <polyline id='pl' points='0,0 0,127 255,127 255,0' stroke='url(#lg)' fill='none' stroke-width='3'/>
363
- </svg>
364
- <script>try{
365
- var pl = document.getElementById('pl');
366
  var pts = '';
367
  for (var i=0; i<256; i++) {
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='
385
  BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/this.value));
 
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;' onload='
356
+ try{
 
 
 
 
 
 
 
 
 
357
  var pts = '';
358
  for (var i=0; i<256; i++) {
359
  pts += i+','+Math.sin(i/256*Math.PI/2)*127+' ';
360
  }
361
+ document.getElementById('pl').setAttribute('points', pts);
362
+ this.onpointermove = function(event) {
363
  var x = event.clientX - event.target.getBoundingClientRect().x;
364
  var y = event.clientY - event.target.getBoundingClientRect().y;
365
+ var pl_a = document.getElementById('pl').getAttribute('points').split(' ');
366
  pl_a[x] = x+','+y;
367
+ document.getElementById('pl').setAttribute('points', pl_a.join(' '));
368
  }
369
+ this.onpointerup = function(event) {
370
  document.getElementsByTagName('input[type=text]')[1].value = document.getElementById('pl').getAttribute('points');
371
  }
372
+ }catch(e){alert(e);}
373
+ '>
374
+ <defs>
375
+ <linearGradient id="lg" x1="0%" x2="100%" y1="0%" y2="0%">
376
+ <stop offset="0%" stop-color="white"/>
377
+ <stop offset="100%" stop-color="black"/>
378
+ </linearGradient>
379
+ </defs>
380
+ <polyline id='pl' points='0,0 0,127 255,127 255,0' stroke='url(#lg)' fill='none' stroke-width='3'/>
381
+ </svg>""")
382
  txt_in = gr.Textbox(value="")
383
  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='
384
  BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/this.value));