Advertisement
here2share

# js_curve.py

Nov 24th, 2019
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. # js_curve.py
  2.  
  3. import tempfile
  4. import webbrowser
  5. import os
  6.  
  7. js_data = '''<!DOCTYPE html>
  8.  
  9. <html>
  10. <body>
  11.  
  12. <svg width="1200" height="600">
  13.  
  14.  Sorry, your browser does not support inline SVG.
  15.  
  16.  <path id="lineAB" d="M 100 350 l 150 -300" stroke="red" stroke-width="3" fill="none" />
  17.  <path id="lineBC" d="M 250 50 l 150 300" stroke="red" stroke-width="3" fill="none" />
  18.  <path d="M 175 200 l 150 0" stroke="green" stroke-width="3" fill="none" />
  19.  <path d="M 100 350 q 150 -300 300 0" stroke="blue" stroke-width="5" fill="none" />
  20.  <!-- Mark relevant points -->
  21.  <g stroke="black" stroke-width="3" fill="black">
  22.    <circle id="pointA" cx="100" cy="350" r="3" />
  23.    <circle id="pointB" cx="250" cy="50" r="3" />
  24.    <circle id="pointC" cx="400" cy="350" r="3" />
  25.  </g>
  26.  <!-- Label the points -->
  27.  <g font-size="30" font-family="sans-serif" fill="black" stroke="none" text-anchor="middle">
  28.    <text x="100" y="350" dx="-30">A</text>
  29.    <text x="250" y="50" dy="-10">B</text>
  30.    <text x="400" y="350" dx="30">C</text>
  31.  </g>
  32. </svg>
  33.  
  34. </body>
  35. </html>'''
  36.  
  37. chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
  38.  
  39. tf = tempfile.mktemp(".html", "JSdemo_")
  40. print tf
  41. with open(tf, 'w') as temp:
  42.     temp.write(js_data)
  43. webbrowser.get(chrome_path).open(tf)
  44. os.remove(tf)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement