freealise commited on
Commit
1880eb2
1 Parent(s): 6b3d5a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -397,6 +397,33 @@ with gr.Blocks(css=css) as demo:
397
  <polyline id='pl' points='-3,0 0,127 255,127 258,0' stroke='url(#lg)' fill='none' stroke-width='3'/>
398
  </svg>""")
399
  blur_in = gr.Textbox(value="", label="Blur kernel size")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
400
  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='
401
  BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/this.value));
402
 
 
397
  <polyline id='pl' points='-3,0 0,127 255,127 258,0' stroke='url(#lg)' fill='none' stroke-width='3'/>
398
  </svg>""")
399
  blur_in = gr.Textbox(value="", label="Blur kernel size")
400
+ average = gr.HTML(value="""<label for='average'>Average</label><input id='average' type='range' style='width:256px;height:1em;' value='1' min='1' max='255' step='2' onclick='
401
+ var pts_a = document.getElementsByTagName(\"textarea\")[1].value.split(\" \");
402
+ for (var i=0; i<pts_a.length; i++) {
403
+ var avg = 0;
404
+ for (var j = i-parseInt(this.value/2); j <= i+parseInt(this.value/2); j++) {
405
+ if (pts_a[j]) {
406
+ avg += pts_a[j];
407
+ } else if (j < 0) {
408
+ avg += pts_a[0];
409
+ } else if (j >= pts_a.length) {
410
+ avg += pts_a[pts_a.length - 1];
411
+ }
412
+ }
413
+ pts_a[i] = parseInt(avg / this.value);
414
+ }
415
+ document.getElementsByTagName(\"textarea\")[1].value = pts_a.join(\" \");
416
+ for (var i=0; i<pts_a.length; i++) {
417
+ pts_a[i] = i+\",\"+pts_a[i];
418
+ }
419
+ document.getElementById(\"pl\").setAttribute(\"points\", pts_a.join(\" \"));
420
+
421
+ var evt = document.createEvent(\"Event\");
422
+ evt.initEvent(\"input\", true, false);
423
+ document.getElementsByTagName(\"textarea\")[1].dispatchEvent(evt);
424
+ ' oninput='
425
+ this.parentNode.childNodes[2].innerText = this.value;
426
+ '/><span>1</span>""")
427
  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='
428
  BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/this.value));
429