freealise commited on
Commit
03ed984
1 Parent(s): cc4515a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -469,10 +469,10 @@ with gr.Blocks(css=css) as demo:
469
  if (x < 0) { x = 0; } else if (x > 255) { x = 255; }
470
  if (y < 0) { y = 0; } else if (y > 255) { y = 255; }
471
 
472
- if (document.getElementById(\"cr\").title == \"move\") {
473
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x = x-128;
474
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z = y-128;
475
- } else if (document.getElementById(\"cr\").title == \"rotate\") {
476
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotationQuaternion = null;
477
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.y = parseInt(event.clientX - this.getBoundingClientRect().x-128)/128*Math.PI;
478
  }
@@ -496,23 +496,22 @@ with gr.Blocks(css=css) as demo:
496
  }
497
  this.onclick = function(event) {
498
  try{
499
- if (document.getElementById(\"cr\").title != \"rotate\")
500
- document.getElementById(\"cr\").title = \"rotate\";
501
  } else {
502
- document.getElementById(\"cr\").title = \"move\";
503
  }
504
- alert(document.getElementById(\"cr\").title);
505
  }catch(e){alert(e);}
506
  }
507
  }
508
  '>
509
  <defs>
510
- <linearGradient id='lg' x1='0%' x2='100%' y1='0%' y2='0%'>
511
  <stop offset='0%' stop-color='white'/>
512
  <stop offset='100%' stop-color='black'/>
513
- </linearGradient>
514
  </defs>
515
- <circle title='move' cx='127' cy='127' r='32' id='cr' stroke='none' fill='url(#lg)'/>
516
  </svg>""")
517
 
518
  html = gr.HTML(value="""<label for='zoom'>Zoom</label><input id='zoom' type='range' style='width:256px;height:1em;' value='0.8' min='0.157' max='1.57' step='0.001' oninput='
 
469
  if (x < 0) { x = 0; } else if (x > 255) { x = 255; }
470
  if (y < 0) { y = 0; } else if (y > 255) { y = 255; }
471
 
472
+ if (document.getElementById(\"cr\").getAttribute(\"stroke\") == \"none\") {
473
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x = x-128;
474
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z = y-128;
475
+ } else if (document.getElementById(\"cr\").getAttribute(\"stroke\") == \"black\") {
476
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotationQuaternion = null;
477
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.y = parseInt(event.clientX - this.getBoundingClientRect().x-128)/128*Math.PI;
478
  }
 
496
  }
497
  this.onclick = function(event) {
498
  try{
499
+ if (document.getElementById(\"cr\").getAttribute(\"stroke\") != \"black\")
500
+ document.getElementById(\"cr\").getAttribute(\"stroke\") = \"black\";
501
  } else {
502
+ document.getElementById(\"cr\").getAttribute(\"stroke\") = \"none\";
503
  }
 
504
  }catch(e){alert(e);}
505
  }
506
  }
507
  '>
508
  <defs>
509
+ <radialGradient id='rg' cx='50%' cy='50%'>
510
  <stop offset='0%' stop-color='white'/>
511
  <stop offset='100%' stop-color='black'/>
512
+ </radialGradient>
513
  </defs>
514
+ <circle cx='127' cy='127' r='32' id='cr' stroke='none' fill='url(#lg)'/>
515
  </svg>""")
516
 
517
  html = gr.HTML(value="""<label for='zoom'>Zoom</label><input id='zoom' type='range' style='width:256px;height:1em;' value='0.8' min='0.157' max='1.57' step='0.001' oninput='