Advertisement
here2share

# js_bezierCurveTo.py

Nov 26th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. # js_bezierCurveTo.py
  2.  
  3. import tempfile
  4. import webbrowser
  5. import os
  6.  
  7. js_data = '''<!DOCTYPE html>
  8. <html>
  9.    <head>
  10.        <title>HTML5 bezierCurveTo</title>
  11.    </head>
  12.    <body>
  13.        <canvas id="myCanvas" width="500" height="200"  
  14.                style="border:1px solid blue;">
  15.        </canvas>
  16.        <script>
  17.            var canvas = document.getElementById("myCanvas");
  18.            var ctx = canvas.getContext("2d");
  19.            ctx.beginPath();
  20.            ctx.moveTo(100, 75);
  21.            ctx.bezierCurveTo(200, 275, 300, -125, 400, 75);
  22.            ctx.stroke();
  23.        </script>
  24.    </body>
  25. </html>
  26. '''
  27.  
  28. chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
  29.  
  30. tf = tempfile.mktemp(".html", "JSdemo_")
  31. print tf
  32. with open(tf, 'w') as temp:
  33.     temp.write(js_data)
  34. webbrowser.get(chrome_path).open(tf)
  35. os.remove(tf)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement