Created
July 16, 2022 18:11
-
-
Save micuat/e1439593ca4ef964f9a81f5515a103b4 to your computer and use it in GitHub Desktop.
p5pylivecode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Starting App...\n", | |
">> [Jython] Created!\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"from processing_py import *\n", | |
"app = App(600,600) # create window: width, height\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"ename": "KeyboardInterrupt", | |
"evalue": "", | |
"output_type": "error", | |
"traceback": [ | |
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | |
"\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", | |
"\u001b[1;32mc:\\Users\\naoto\\Documents\\repositories\\p5pylivecode\\sketch.ipynb Cell 2'\u001b[0m in \u001b[0;36m<cell line: 2>\u001b[1;34m()\u001b[0m\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/naoto/Documents/repositories/p5pylivecode/sketch.ipynb#ch0000001?line=2'>3</a>\u001b[0m app\u001b[39m.\u001b[39mcolorMode(\u001b[39m'\u001b[39m\u001b[39mHSB\u001b[39m\u001b[39m'\u001b[39m,\u001b[39m255\u001b[39m,\u001b[39m255\u001b[39m,\u001b[39m255\u001b[39m)\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/naoto/Documents/repositories/p5pylivecode/sketch.ipynb#ch0000001?line=3'>4</a>\u001b[0m \u001b[39m# app.background(255)\u001b[39;00m\n\u001b[1;32m----> <a href='vscode-notebook-cell:/c%3A/Users/naoto/Documents/repositories/p5pylivecode/sketch.ipynb#ch0000001?line=4'>5</a>\u001b[0m app\u001b[39m.\u001b[39;49mnoStroke()\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/naoto/Documents/repositories/p5pylivecode/sketch.ipynb#ch0000001?line=5'>6</a>\u001b[0m app\u001b[39m.\u001b[39mfill((app\u001b[39m.\u001b[39mmillis()\u001b[39m*\u001b[39m\u001b[39m0.1\u001b[39m)\u001b[39m%\u001b[39m\u001b[39m255\u001b[39m,\u001b[39m255\u001b[39m,\u001b[39m255\u001b[39m)\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/naoto/Documents/repositories/p5pylivecode/sketch.ipynb#ch0000001?line=6'>7</a>\u001b[0m w \u001b[39m=\u001b[39m math\u001b[39m.\u001b[39msin(app\u001b[39m.\u001b[39mmillis()\u001b[39m*\u001b[39m\u001b[39m0.0015\u001b[39m)\u001b[39m*\u001b[39m\u001b[39m100\u001b[39m\n", | |
"File \u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\processing_py\\app.py:358\u001b[0m, in \u001b[0;36mApp.noStroke\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m <a href='file:///c%3A/Users/naoto/AppData/Local/Programs/Python/Python310/lib/site-packages/processing_py/app.py?line=356'>357</a>\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mnoStroke\u001b[39m(\u001b[39mself\u001b[39m):\n\u001b[1;32m--> <a href='file:///c%3A/Users/naoto/AppData/Local/Programs/Python/Python310/lib/site-packages/processing_py/app.py?line=357'>358</a>\u001b[0m \t\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mstd_function(\u001b[39m'\u001b[39;49m\u001b[39mnoStroke\u001b[39;49m\u001b[39m'\u001b[39;49m)\n", | |
"File \u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\processing_py\\app.py:72\u001b[0m, in \u001b[0;36mApp.std_function\u001b[1;34m(self, name, *args)\u001b[0m\n\u001b[0;32m <a href='file:///c%3A/Users/naoto/AppData/Local/Programs/Python/Python310/lib/site-packages/processing_py/app.py?line=69'>70</a>\u001b[0m \ts \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39mstr\u001b[39m(l[\u001b[39mlen\u001b[39m(l)\u001b[39m-\u001b[39m\u001b[39m1\u001b[39m])\n\u001b[0;32m <a href='file:///c%3A/Users/naoto/AppData/Local/Programs/Python/Python310/lib/site-packages/processing_py/app.py?line=70'>71</a>\u001b[0m s \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39m'\u001b[39m\u001b[39m)\u001b[39m\u001b[39m'\u001b[39m\n\u001b[1;32m---> <a href='file:///c%3A/Users/naoto/AppData/Local/Programs/Python/Python310/lib/site-packages/processing_py/app.py?line=71'>72</a>\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49msendLine(s)\n", | |
"File \u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\processing_py\\app.py:61\u001b[0m, in \u001b[0;36mApp.sendLine\u001b[1;34m(self, line)\u001b[0m\n\u001b[0;32m <a href='file:///c%3A/Users/naoto/AppData/Local/Programs/Python/Python310/lib/site-packages/processing_py/app.py?line=58'>59</a>\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mBaseException\u001b[39;00m:\n\u001b[0;32m <a href='file:///c%3A/Users/naoto/AppData/Local/Programs/Python/Python310/lib/site-packages/processing_py/app.py?line=59'>60</a>\u001b[0m \t\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mclose()\n\u001b[1;32m---> <a href='file:///c%3A/Users/naoto/AppData/Local/Programs/Python/Python310/lib/site-packages/processing_py/app.py?line=60'>61</a>\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mwaitAnswer()\n", | |
"File \u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\processing_py\\app.py:34\u001b[0m, in \u001b[0;36mApp.waitAnswer\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m <a href='file:///c%3A/Users/naoto/AppData/Local/Programs/Python/Python310/lib/site-packages/processing_py/app.py?line=32'>33</a>\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mwaitAnswer\u001b[39m(\u001b[39mself\u001b[39m):\n\u001b[1;32m---> <a href='file:///c%3A/Users/naoto/AppData/Local/Programs/Python/Python310/lib/site-packages/processing_py/app.py?line=33'>34</a>\u001b[0m \tans \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mstream\u001b[39m.\u001b[39;49mstdout\u001b[39m.\u001b[39;49mreadline()\u001b[39m.\u001b[39mdecode(\u001b[39m'\u001b[39m\u001b[39mutf-8\u001b[39m\u001b[39m'\u001b[39m)\n\u001b[0;32m <a href='file:///c%3A/Users/naoto/AppData/Local/Programs/Python/Python310/lib/site-packages/processing_py/app.py?line=34'>35</a>\u001b[0m \t\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mhandle_answer(ans)\n", | |
"\u001b[1;31mKeyboardInterrupt\u001b[0m: " | |
] | |
} | |
], | |
"source": [ | |
"import math\n", | |
"while True:\n", | |
" app.colorMode('HSB',255,255,255)\n", | |
" # app.background(255)\n", | |
" app.noStroke()\n", | |
" app.fill((app.millis()*0.1)%255,255,255)\n", | |
" w = math.sin(app.millis()*0.0015)*100\n", | |
" app.translate(app.mouseX, app.mouseY)\n", | |
" app.rotate(app.millis()*0.001)\n", | |
" app.rect(0,0, w, w)\n", | |
" app.redraw()" | |
] | |
} | |
], | |
"metadata": { | |
"interpreter": { | |
"hash": "9babdb07c6481c55c67c3b23f5a9ec5d2842c1ba4f8e99cb62b56fb107186111" | |
}, | |
"kernelspec": { | |
"display_name": "Python 3.10.4 64-bit", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.10.4" | |
}, | |
"orig_nbformat": 4 | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment