freealise commited on
Commit
37e5c5e
1 Parent(s): a8299bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -352,30 +352,30 @@ 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' onpointermove='try{chart(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"/>
359
  <stop offset="100%" stop-color="black"/>
360
  </linearGradient>
361
  </defs>
362
- <polyline id='pl' points='0,0 0,64 255,64 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)*64+' ';
369
  }
370
  pl.setAttribute('points', pts);
371
  }catch(e){alert(e);}
372
- function chart(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
- input_json = gr.JSON(value="{}", visible=False)
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='
380
  BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/this.value));
381
  BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast = 2.0;
 
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{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"/>
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
  }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='
380
  BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/this.value));
381
  BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast = 2.0;