diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c5b2a96..9d66f020 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: strategy: max-parallel: 4 matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [windows-latest, ubuntu-latest, macos-latest] python-version: [3.6, 3.7, 3.8] steps: diff --git a/README.md b/README.md index 06c7010b..7aab6925 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## pyp5js: Python to P5.js Transcriptor +## pyp5js: drawing with Python 3 [![PyPI version](https://badge.fury.io/py/pyp5js.svg)](https://badge.fury.io/py/pyp5js) ![Continuous Integration](https://github.com/berinhard/pyp5js/workflows/Continuous%20Integration/badge.svg?branch=develop&event=push) @@ -6,7 +6,7 @@ > [Processing](https://processing.org) ideas and Python 3 together with [P5.js](https://p5js.org) in the browser. -Python 3 drawing in the web 🐍 🐍 🐍 Try it [here](https://berinhard.github.io/pyp5js/pyodide/)! +Python 3 drawing in the web! Try it [here](https://berinhard.github.io/pyp5js/pyodide/)! Here's an example of a valid Python code using P5.js API: diff --git a/docs/index.md b/docs/index.md index 9950595e..d17f9ded 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,4 +1,4 @@ -# pyp5js: Python to P5.js Transcriptor +## pyp5js: drawing with Python 3 [![PyPI version](https://badge.fury.io/py/pyp5js.svg)](https://badge.fury.io/py/pyp5js) ![Continuous Integration](https://github.com/berinhard/pyp5js/workflows/Continuous%20Integration/badge.svg?branch=develop&event=push) diff --git a/docs/pyodide/index.html b/docs/pyodide/index.html index 6fce20e6..e45578ad 100644 --- a/docs/pyodide/index.html +++ b/docs/pyodide/index.html @@ -56,8 +56,8 @@
- - + +
@@ -1256,7 +1256,7 @@ script.onload = logOnloaded script.src = src document.head.appendChild(script) -` +`; let placeholder = ` def setup(): @@ -1264,7 +1264,20 @@ def draw(): pass -` +`; + +const initialSketch = ` +def setup(): + createCanvas(200, 200) + background(160) + +def draw(): + fill("blue") + background(200) + radius = sin(frameCount / 60) * 50 + 50 + ellipse(100, 100, radius, radius) +`; + languagePluginLoader.then(() => { pyodide.runPython(` import io, code, sys @@ -1297,6 +1310,8 @@ editor.session.setOptions({ tabSize: 4, }); + editor.setValue(initialSketch, -1); + document.getElementById("id_py_code").innerHTML = initialSketch; editor.session.on('change', function(){ document.getElementById("id_py_code").innerHTML = editor.getSession().getValue(); @@ -1307,12 +1322,22 @@ $("body").bind("keydown",keyDown); + function cleanKeyCode(e) { + // Shortcuts work for Ctrl or Cmd + if (e.ctrlKey || e.metaKey) { + return e.keyCode; + } + } + function keyDown(e){ - if((e.ctrlKey) && (e.keyCode == 13)){ - runCode(); + if (cleanKeyCode(e) === 13) { // Ctrl + Enter to run + e.preventDefault(); + $("#executeBtn").click(); + } else if(cleanKeyCode(e) === 190){ // Ctrl + . to clear + e.preventDefault(); + $("#clearBtn").click(); } } -