From 9a2d39600eeecb0cbff482da565f637df8b0f5da Mon Sep 17 00:00:00 2001 From: Kieran Wood Date: Sat, 21 Nov 2020 10:00:26 -0700 Subject: [PATCH 01/14] Added mouse_down(), mouse_is_pressed and mouse_up docs --- docs/img/mouse_down.png | Bin 0 -> 9730 bytes docs/img/mouse_is_pressed.png | Bin 0 -> 9820 bytes docs/img/mouse_up.png | Bin 0 -> 9093 bytes docs/input.md | 105 ++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 docs/img/mouse_down.png create mode 100644 docs/img/mouse_is_pressed.png create mode 100644 docs/img/mouse_up.png diff --git a/docs/img/mouse_down.png b/docs/img/mouse_down.png new file mode 100644 index 0000000000000000000000000000000000000000..231c2e5085b8f818b8515fd373e98e0640adb24f GIT binary patch literal 9730 zcmeHtdsvd&)-SbeSGu|{wK8>;+J(GimS&)?u$G#sl$aM(Dl#iWQW8Z(x@hjTEG^B{ zye%sg^FnHhh(b3tuT)+LQK`HTS5p)e1P-pV&w2LV&)(13-#_O$=Xt(AfH^1gedl<` zoZ~lsV~qDVsJGi1-L1L+0AP)W`_WSXz_Kju=i92kXh&}FqRq8G%P^GW(q~yansgoju*mi}dIT01Djq>qhOt7pQ4F^k z&!ZNWIqq3Q?gk}~PmRp3I3xXIRclE!?3_7mr_H@9=Z_uR|M2Vk-R7@;AAbA$nBjVh z$5{pYe%hgT3$|^q@n3&9+K7F*R`-xMyx6aru$~#`b+MAecCo#x zgc5RZU^;#ZGZo0FljWwQh9)jd{AS*v}}zK$6WJPZUEkwv|G+d#v>(-7`81n_Og?;^GwTzU1biTH+*RVz0d5 zQKB%W?;4Y#CibyR4pT|^Sr#HcQ8R<~@zE@Fv?7Omvm0hTxOXZXM^%zoAOBF?#O!#c zk7U5Of734S6YXinaBy#Z=6Lcqx@%Zq4(!n4xKeXXq2Lz9*ULbQt(!FaR7!c`g%5@8 z5AgdFuaOp24&FASEPCy#JM-*3L}*gml;#`7FumMU$xWObpY71hi}^-~xU*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`CM)XmF{Q9XAU~O{L-%3RVPaD?vE zL?%RuH;f)mCy0=#XF76pj!$|jj}T2>Hn7W~xp>T+p1;-l7}}GmBFAS{noJ}gj;aY+ z1u?D=*YWdOoFYZMNG7QL-Q!GKD}GVbK{ukP`7he?ZM3QpJ9^9d9G_DZ{y}qP@*>l* zf!y`1sC}4uZbYar3?6C#m(n$BFKiJe`an2ks=%Zdejy=l-O_F|*wq~E+RFg>h<}cD h{&So=_ekyXqw(HZ(ayv3+V{2q9>=_oRzuF*{2#5k^{@Z{ literal 0 HcmV?d00001 diff --git a/docs/img/mouse_is_pressed.png b/docs/img/mouse_is_pressed.png new file mode 100644 index 0000000000000000000000000000000000000000..b5f37608357fdf70439cceae6776206879274276 GIT binary patch literal 9820 zcmeHtd011)wl6rf0}g0pun{yWCdyz$1r$iDAjnK;L>dAbAhgY72s4D(dQ?adL<1p$ zM!|qGMP|Yf90&meq=h3v!q6QiAp{I#AS8L4KBv#Q_jcbt|J?h%d*Ao|$hWhr)~>Z` z)f#@Qs*;=?t+#I8vsp<=Y3oHBON5e=GD}Hm&83YSfEFk}dk%OgV-eQpluA0Z#(|f0 z0cRb~Dk+twZdtjy9(dn$-Npl}q_pkb>Q9*+`od31>5%xM<=Jney+!?@FM>xN>wF2k zCe7P5s80Icd&6HkqfkCJ53jUtxh?o6r|HD=L*LqMJa~D(?tx1;RUX)C`D8wefq8NI zBJckczAyM7_Ke2oZxSyyq@U2dn0LwdQJ|pWV!duJ63-utitiZejickHECT5b-D7Kg zIy~@;jhxvA?rG^H7OkwL2endykibeHTUDjaw2ex)5$kT8gRc4J8A$nQW)M^^VZ+r_ zRX-hhXu$H3O}K->;D%g~m8GREDJL<}CJ6yjRfW0`faXKCE|!+hEun#$CD?C?* z&(IBcNXbkf5sn-Dnn-3YPRs-brACzMFC^iHYRuScx0}7H8OiWeGpzse_CqbFeQ9<~ zo#!1VnhE4Zs;X-0=3gQd+KNhN;TA`j_&JuMRxZl}FCQ-WfJZ$T99E{{O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Gguu_#TQ5CE(>E!_8hBi3~46%xh<;Io7VU=R*cC7A+MDxO=<=g~3sod(f z5sUX6%iWl}wudczi%W!$mh3C68_Bvkl)$(zrP>yyY89;Nc@n%EO>d#-Gti3J( zdUyI?`DveH-_$+hf#~~UolThrt24r!xw{;1MFQKCS7%+bm$orE?Z5M1ng(S1N$HMi zzMIM2`#AG}*W<2)N#Jr%vkkON-BwlO0IkIvh(yUGaNIM{k1)jllbtSlz#0sly#Re1 u{-*`ypB6K}v+{r81b^6l`8z#1ym$ZbrX`#M2DlNXbkWMuvgF*AoBs!tk*K)< literal 0 HcmV?d00001 diff --git a/docs/img/mouse_up.png b/docs/img/mouse_up.png new file mode 100644 index 0000000000000000000000000000000000000000..85571e61d5c5b590a27f26eef1297f62c2f4003b GIT binary patch literal 9093 zcmeHtX;_k5+cphuQ!BH*b1J1_*Urk+Z4O~dIaX#lG&z@+CW>T+8VT&mDN}4$Tg@?Y zA{B80N2F4r9;XZh1(BUrC`d$#D2TlH{QQph{l543-s63KJwNV~d#z*L_jRpnt@~W( zx)u+;&w6aqHr56J0Gm#oboB)Q)KKK0L}927@u-IaXu+TR2-TW^yN-E68N6=>X(CY z<)_V`{8f3n!WZ#p&ma)H!R{}gbteFyv&KBWFF=NiJ^&CDwNeK{c z8zXCmbnRsPSs8xF4OhB2*`~1zgGC8yV9Y-D5HQkgFC&8+|2~4@++gwxL`0Z!EpUcf z!yPw=eZc3Ga*38b1m!~Z1YXxIpn=5M^W%AB$*aR1vyF(aHAx3vlDr_5cxWXR0&GJn z76LdCpNLx&l7vofN1}{c7?%Z(oGI86CqJVH;R-&O=b&U*+BS%v4`$bbfON9+%hdyo zR+*XA_@>2xEc5S~5c*1cc4OQWRYNaVayg{f&(?g;IAz?{34s>PKbLp7ATch3_1elY%&`nEmc&|!*qLsbl^6xFjjy%F( zNr9%MIw)@2S3|$KFlTf4>__uW_#D=~47&J93Oh_doR%x-jb`&x8;D9qdRXoC)G?m? zaR3tmW!a;JF1r?5jL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`lDsHHC>Iu@NbQJzlU+V~|9@dTNl2S_XP!!kAffj3n5hBZ$D6Ohx^ zWy151`>zu2#KzXOe@fe4T~&e*EEl9slgHZO!Y346c~fgXYwwW|)>+)uwvVs85BhGm zi>>`eQLP~Sfj4`jx85_>M}DZ#%hOa#2nl=!1SdmxG3v)>f^d`tB4Gq*jBF(?t2cRv z7at3Knqmt-EoI#3%sFYcB`$5c`$oedle=4tIk(L#HYfms;n1hAtPqPd5+tf^X)X*5FppLbZVI;?pL<-A1?I`I`u*31~AOnco380}P zdK#Nv9jcPE$hvJvOYF!t0iOwSMXG!_8dL)?8qSHFr^gp3jCXDrH8fmG;622 zW}-6A{TQjlPPsJiKx&rJJ}i>NTF1+uVi$%##`hiv*7>eKLUpQLY1@zdZd3V-U$&&> z{ONExR``Qe8BP2{eSqueo@`!WRpJ}unmq6}$DFJQf^qgQ2^sO|!>SO3QnTzRTKpW^B#Zsfa6Q=~{mwbS?qVJIa{XxfS>Rhk?N6-U8-K0+G@MSS<~enC zzX)H-Sd3S&u1vRk4og-8StW^c7qOOvmT3>4P|lio(umQFGBl-de{lB;Ry6+y%ZO*4 zgMq4u&H1uh`LgvpopIdsLA0Tp*$(~voS~r)yFq!WRH|L-l`ZTcaUh69whgX|NRk9e z3`-URvJIP)4nu(#aH+W>cyGL&Py0_;+oxt(>bbG~x_KLC{zaryuN literal 0 HcmV?d00001 diff --git a/docs/input.md b/docs/input.md index 33963ec..1da9381 100644 --- a/docs/input.md +++ b/docs/input.md @@ -108,6 +108,107 @@ which results in: ![Ask circle diameter](img/circle_radius.png){: loading=lazy } + +### Check for mouse presses + +Spark features multiple ways to check for user mouse presses: + +| Name | Type | Description | +|---------------------------------------|-----------------------|------------------------------------------------------------------------| +| [mouse_is_pressed](#mouse_is_pressed) | Variable | A boolean variable that is True when a mouse button is pressed | +| [mouse_down()](#mouse_down) | User defined function | A definable function that activates when a mousebutton is pressed down | +| [mouse_up()](#mouse_up) | User defined function | A definable function that activates when a mousebutton is released | + +**Notes** + +- All of these variables fire on **any** mouse button press (left mouse click, right mouse click, or scroll wheel click) +- Mouse events are only captured when the mouse is **inside** the canvas boundary + + +#### mouse_is_pressed +A boolean that is True when **any** mouse button is pressed + +**Example(s):** + +*Draw a square at the (mouse_x, mouse_y) position when the mouse is pressed* + + +```python hl_lines="7" +%%ignite +def setup(): + background(255) + size(500,500) + +def draw(): + if mouse_is_pressed: + square(mouse_x, mouse_y, 45) +``` + +Results in: + +![mouse_is_pressed example](img/mouse_is_pressed.png){: loading=lazy } + +#### mouse_down() + +```python +def mouse_down(): + # Your code goes here +``` + +This is a user definable function that activates when **any** mouse button is pressed down. + +Example(s): + +*Print "Mouse Button Pressed Down" if a mouse button is pressed down* + +```python hl_lines="9 10" +%%ignite + +def setup(): + size(200, 200) + +def draw(): + ... # Does nothing + +def mouse_down(): + print("Mouse Button Pressed Down") +``` + +Results in: + +![mouse_down() example](img/mouse_down.png){: loading=lazy } + + +#### mouse_up() + +```python +def mouse_up(): + # Your code goes here +``` + +This is a user definable function that activates when **any** mouse button is released after being pressed down. + +Example(s): + +*Print "Mouse Button Released" if a mouse button is released after being pressed down* + +```python hl_lines="9 10" +%%ignite + +def setup(): + size(200, 200) + +def draw(): + ... # Does nothing + +def mouse_up(): + print("Mouse Button Released") +``` + +Results in: + +![mouse_up() example](img/mouse_up.png){: loading=lazy } + ### Check for key presses Spark features multiple ways to check for user key presses: @@ -120,6 +221,10 @@ Spark features multiple ways to check for user key presses: | [key_released()](#key_released) | User defined function | A definable function that activates when any key is released | | [key_repeated()](#key_repeated) | User defined function | A definable function that activates when any key is held | +**Notes** + +- Key events **only** trigger when the mouse is **inside** the canvas + #### key A string that is the last key event (a key being pressed, released, or held down). So for example if you press, hold or release ++shift++ then `#!python key == "Shift"`. From 19fd2465cfc175c028c26624fba7ffd9b960ab8e Mon Sep 17 00:00:00 2001 From: Kieran Wood Date: Sat, 21 Nov 2020 10:05:10 -0700 Subject: [PATCH 02/14] Added info about mouse_down() and mouse_up() only firing once in draw loop --- docs/input.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/input.md b/docs/input.md index 1da9381..dce0ad2 100644 --- a/docs/input.md +++ b/docs/input.md @@ -157,6 +157,10 @@ def mouse_down(): This is a user definable function that activates when **any** mouse button is pressed down. +##### Notes + +- This function is handy when you want to do something in a ```#!python draw()``` loop **one time** on mouse press. ```#!python mouse_is_pressed``` will constantly fire in a ```#!python draw()``` loop, whereas ```#!python mouse_down()``` will fire once per event + Example(s): *Print "Mouse Button Pressed Down" if a mouse button is pressed down* @@ -188,6 +192,10 @@ def mouse_up(): This is a user definable function that activates when **any** mouse button is released after being pressed down. +##### Notes + +- This function is handy when you want to do something in a ```#!python draw()``` loop **one time** on mouse release. ```#!python mouse_is_pressed``` will constantly fire in a ```#!python draw()``` loop, whereas ```#!python mouse_up()``` will fire once per event + Example(s): *Print "Mouse Button Released" if a mouse button is released after being pressed down* From ccf5e61fb09fe24cf3bfbf92352e914ff07d393a Mon Sep 17 00:00:00 2001 From: Kieran Wood Date: Sat, 21 Nov 2020 10:49:39 -0700 Subject: [PATCH 03/14] Changes mousebutton to mouse button in docs --- docs/input.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/input.md b/docs/input.md index dce0ad2..a8da2cc 100644 --- a/docs/input.md +++ b/docs/input.md @@ -113,11 +113,11 @@ which results in: Spark features multiple ways to check for user mouse presses: -| Name | Type | Description | -|---------------------------------------|-----------------------|------------------------------------------------------------------------| -| [mouse_is_pressed](#mouse_is_pressed) | Variable | A boolean variable that is True when a mouse button is pressed | -| [mouse_down()](#mouse_down) | User defined function | A definable function that activates when a mousebutton is pressed down | -| [mouse_up()](#mouse_up) | User defined function | A definable function that activates when a mousebutton is released | +| Name | Type | Description | +|---------------------------------------|-----------------------|-------------------------------------------------------------------------| +| [mouse_is_pressed](#mouse_is_pressed) | Variable | A boolean variable that is True when a mouse button is pressed | +| [mouse_down()](#mouse_down) | User defined function | A definable function that activates when a mouse button is pressed down | +| [mouse_up()](#mouse_up) | User defined function | A definable function that activates when a mouse button is released | **Notes** From d36c23ec1047600bf8a77a57b6f771b6adcb7dc8 Mon Sep 17 00:00:00 2001 From: R Lee Date: Sat, 6 Feb 2021 17:34:21 -0700 Subject: [PATCH 04/14] Bumped test run --- test/SyntaxError.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/SyntaxError.ipynb b/test/SyntaxError.ipynb index 951bdc8..60ff6d8 100644 --- a/test/SyntaxError.ipynb +++ b/test/SyntaxError.ipynb @@ -116,7 +116,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "dc9380c179a44ca1aa449f95a515d032", + "model_id": "808deebe81c54d0e9eaa18a98ed583c5", "version_major": 2, "version_minor": 0 }, @@ -250,7 +250,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.8.6" } }, "nbformat": 4, From 2705f8a2bc318c3d5fc934e0e9eeb94e038e9239 Mon Sep 17 00:00:00 2001 From: R Lee Date: Wed, 17 Feb 2021 22:25:31 -0700 Subject: [PATCH 05/14] Fixed rotation_explanation.png link --- docs/utilities.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/utilities.md b/docs/utilities.md index 767e1af..d523224 100644 --- a/docs/utilities.md +++ b/docs/utilities.md @@ -60,7 +60,7 @@ Results in: ### Rotation -![rotation explanation](rotation_explanation.png) +![rotation explanation](img/rotation_explanation.png) Transformations are always done to the **canvas**, not the individual shapes themselves. Rotation is done around the origin, point (0, 0) and affects all shapes drawn afterwards. You can use our built-in `pi` variable to express radians, or convert from degrees to radians by multiplying your number of degrees by `pi / 180`. From 1ea80fd2ca6d8fa6fc3f07ea06358ad4a9a3a986 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 22 Feb 2021 17:27:24 -0700 Subject: [PATCH 06/14] Added a FRAME_RATE variable to global_constants{} Not sure if this is the right place to put it but I was getting a key error trying to put it as property --- spark/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spark/core.py b/spark/core.py index 46ba78b..acf64e2 100644 --- a/spark/core.py +++ b/spark/core.py @@ -31,7 +31,8 @@ class Core: # All constants that will be injected into global scope in the user"s cell global_constants = { - "pi": pi + "pi": pi, + "FRAME_RATE": FRAME_RATE } ignite_globals = _ignite_globals From 43b4432e3041891ac4e0e2e78f383b21297ac0a1 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 27 Feb 2021 21:31:58 -0700 Subject: [PATCH 07/14] Added documentation mentioning the frame rate --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 1a9d138..335b753 100644 --- a/docs/index.md +++ b/docs/index.md @@ -102,7 +102,7 @@ def setup(): size(200, 200) # You can change 200, 200 to any integers ``` -You can also use the draw() function, which will execute the code constantly that is inside it. This makes it ideal for things like animation, and any code that will update itself over time. **Most of the time this will be the setup you want**: +You can also use the draw() function, which will execute the code constantly that is inside it. The draw function executes 30 times per second. This makes it ideal for things like animation, and any code that will update itself over time. **Most of the time this will be the setup you want**: ```python %%ignite From 3631226f018308eb9263e1b5c148994ebc754a04 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 27 Feb 2021 21:35:55 -0700 Subject: [PATCH 08/14] Unit test for for frame rate tests different cases of trying to re-assign FRAME_RATE --- FrameRateTest.ipynb | 685 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 685 insertions(+) create mode 100644 FrameRateTest.ipynb diff --git a/FrameRateTest.ipynb b/FrameRateTest.ipynb new file mode 100644 index 0000000..9e67f0c --- /dev/null +++ b/FrameRateTest.ipynb @@ -0,0 +1,685 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 45, + "id": "difficult-membership", + "metadata": {}, + "outputs": [], + "source": [ + "import spark\n", + "%reload_ext spark\n", + "\n", + "# 'Unit test' for FRAME_RATE" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "id": "cooperative-galaxy", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Done drawing.\n",
+       "
\n" + ], + "text/latex": [ + "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", + "\\PY{err}{D}\\PY{err}{o}\\PY{err}{n}\\PY{err}{e}\\PY{err}{ }\\PY{err}{d}\\PY{err}{r}\\PY{err}{a}\\PY{err}{w}\\PY{err}{i}\\PY{err}{n}\\PY{err}{g}\\PY{err}{.}\n", + "\\end{Verbatim}\n" + ], + "text/plain": [ + "Done drawing." + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "b979b65b533c4dd1bc4871df23cb73fe", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Canvas(height=100, width=100)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
frame rate: 30\n",
+       "
\n" + ], + "text/latex": [ + "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", + "\\PY{err}{f}\\PY{err}{r}\\PY{err}{a}\\PY{err}{m}\\PY{err}{e}\\PY{err}{ }\\PY{err}{r}\\PY{err}{a}\\PY{err}{t}\\PY{err}{e}\\PY{err}{:}\\PY{err}{ }\\PY{err}{3}\\PY{err}{0}\n", + "\\end{Verbatim}\n" + ], + "text/plain": [ + "frame rate: 30" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "%%ignite\n", + "\n", + "def setup():\n", + " size(200, 100)\n", + " background(\"light blue\")\n", + " print(\"frame rate:\", FRAME_RATE)\n", + " # this prints 30, the actual frame rate" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "id": "monetary-killer", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Done drawing.\n",
+       "
\n" + ], + "text/latex": [ + "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", + "\\PY{err}{D}\\PY{err}{o}\\PY{err}{n}\\PY{err}{e}\\PY{err}{ }\\PY{err}{d}\\PY{err}{r}\\PY{err}{a}\\PY{err}{w}\\PY{err}{i}\\PY{err}{n}\\PY{err}{g}\\PY{err}{.}\n", + "\\end{Verbatim}\n" + ], + "text/plain": [ + "Done drawing." + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "768bb7ac20e843528a812a505ad79625", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Canvas(height=100, width=100)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
frame rate: 1\n",
+       "
\n" + ], + "text/latex": [ + "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", + "\\PY{err}{f}\\PY{err}{r}\\PY{err}{a}\\PY{err}{m}\\PY{err}{e}\\PY{err}{ }\\PY{err}{r}\\PY{err}{a}\\PY{err}{t}\\PY{err}{e}\\PY{err}{:}\\PY{err}{ }\\PY{err}{1}\n", + "\\end{Verbatim}\n" + ], + "text/plain": [ + "frame rate: 1" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "%%ignite\n", + "\n", + "def setup():\n", + " size(200, 100)\n", + " background(\"light blue\")\n", + " FRAME_RATE = 1\n", + " print(\"frame rate:\", FRAME_RATE)\n", + " # this prints 1, not what I want\n" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "id": "insured-amino", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Error in setup() function: local variable 'FRAME_RATE' referenced before assignment\n",
+       "
\n" + ], + "text/latex": [ + "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", + "\\PY{n}{Error} \\PY{o+ow}{in} \\PY{n}{setup}\\PY{p}{(}\\PY{p}{)} \\PY{n}{function}\\PY{p}{:} \\PY{n}{local} \\PY{n}{variable} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{FRAME\\PYZus{}RATE}\\PY{l+s+s1}{\\PYZsq{}} \\PY{n}{referenced} \\PY{n}{before} \\PY{n}{assignment}\n", + "\\end{Verbatim}\n" + ], + "text/plain": [ + "Error in setup() function: local variable 'FRAME_RATE' referenced before assignment" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "62bace9c8b6a472b8eda88eb47e25ec0", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Canvas(height=100, width=100)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n",
+       "
\n" + ], + "text/latex": [ + "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", + "\n", + "\\end{Verbatim}\n" + ], + "text/plain": [] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "%%ignite\n", + "\n", + "def setup():\n", + " size(200, 100)\n", + " background(\"light blue\")\n", + " print(\"frame rate:\", FRAME_RATE)\n", + " FRAME_RATE = 10\n", + " # this gives an error, FRAME_RATE is referenced before assignment" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "mediterranean-limit", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.9.1" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 626bad0bf9e673e9bb31941558cadd355009c5dc Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 27 Feb 2021 21:38:57 -0700 Subject: [PATCH 09/14] Added FRAME_RATE variable FRAME_RATE is a @property and an @ignite_global. @FRAME_RATE.setter is supposed to prevent the user from re-assigning. --- spark/core.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/spark/core.py b/spark/core.py index acf64e2..20c9035 100644 --- a/spark/core.py +++ b/spark/core.py @@ -31,8 +31,7 @@ class Core: # All constants that will be injected into global scope in the user"s cell global_constants = { - "pi": pi, - "FRAME_RATE": FRAME_RATE + "pi": pi } ignite_globals = _ignite_globals @@ -140,6 +139,18 @@ def height(self, val): self._globals_dict["height"] = val self.canvas.height = val + # this is working + @property + @ignite_global + def FRAME_RATE(self, mutable=False): + return FRAME_RATE + + # this is not working + @FRAME_RATE.setter + def FRAME_RATE(self, val): + raise RuntimeError("FRAME_RATE cannot be reassigned") + + ### Library init ### # Updates last activity time From 8fa33fe019f7738fbd18851efc27490c80e23daf Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 28 Feb 2021 21:21:28 -0700 Subject: [PATCH 10/14] Moved FrameRateTest.ipynb to the correct folder (test) --- FrameRateTest.ipynb => test/FrameRateTest.ipynb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename FrameRateTest.ipynb => test/FrameRateTest.ipynb (100%) diff --git a/FrameRateTest.ipynb b/test/FrameRateTest.ipynb similarity index 100% rename from FrameRateTest.ipynb rename to test/FrameRateTest.ipynb From 00356c518015281d1047786d991a658c4f68abbc Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 2 Mar 2021 07:30:43 -0700 Subject: [PATCH 11/14] Removed non-functional code --- spark/core.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/spark/core.py b/spark/core.py index df5b2c4..7c8f58f 100644 --- a/spark/core.py +++ b/spark/core.py @@ -139,17 +139,11 @@ def height(self, val): self._globals_dict["height"] = val self.canvas.height = val - # this is working @property @ignite_global - def FRAME_RATE(self, mutable=False): + def FRAME_RATE(self): return FRAME_RATE - # this is not working - @FRAME_RATE.setter - def FRAME_RATE(self, val): - raise RuntimeError("FRAME_RATE cannot be reassigned") - ### Library init ### From 1e896e9f89f2b25bdee7726c3e30d3d487fe14f2 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 2 Mar 2021 07:35:43 -0700 Subject: [PATCH 12/14] Just adjusted a comment --- test/FrameRateTest.ipynb | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/test/FrameRateTest.ipynb b/test/FrameRateTest.ipynb index 9e67f0c..e1cf320 100644 --- a/test/FrameRateTest.ipynb +++ b/test/FrameRateTest.ipynb @@ -2,21 +2,31 @@ "cells": [ { "cell_type": "code", - "execution_count": 45, - "id": "difficult-membership", + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'spark'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mspark\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mget_ipython\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrun_line_magic\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'reload_ext'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'spark'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;31m# Unit test for FRAME_RATE\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'spark'" + ] + } + ], "source": [ - "import spark\n", - "%reload_ext spark\n", - "\n", - "# 'Unit test' for FRAME_RATE" + "import spark\r\n", + "%reload_ext spark\r\n", + "\r\n", + "# Unit test for FRAME_RATE" ] }, { "cell_type": "code", "execution_count": 47, - "id": "cooperative-galaxy", "metadata": {}, "outputs": [ { @@ -229,7 +239,6 @@ { "cell_type": "code", "execution_count": 46, - "id": "monetary-killer", "metadata": {}, "outputs": [ { @@ -443,7 +452,6 @@ { "cell_type": "code", "execution_count": 48, - "id": "insured-amino", "metadata": {}, "outputs": [ { @@ -655,7 +663,6 @@ { "cell_type": "code", "execution_count": null, - "id": "mediterranean-limit", "metadata": {}, "outputs": [], "source": [] @@ -677,9 +684,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.1" + "version": "3.9.1-final" } }, "nbformat": 4, "nbformat_minor": 5 -} +} \ No newline at end of file From 36b6aec9c38fb2b63bdf236f47b26d0f19f25d74 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 8 Mar 2021 11:22:45 -0700 Subject: [PATCH 13/14] Cleaned up unit test for FRAME_RATE --- test/FrameRateTest.ipynb | 290 ++++++++------------------------------- 1 file changed, 55 insertions(+), 235 deletions(-) diff --git a/test/FrameRateTest.ipynb b/test/FrameRateTest.ipynb index e1cf320..bd52172 100644 --- a/test/FrameRateTest.ipynb +++ b/test/FrameRateTest.ipynb @@ -2,21 +2,10 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, + "id": "turned-warrior", "metadata": {}, - "outputs": [ - { - "ename": "ModuleNotFoundError", - "evalue": "No module named 'spark'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mspark\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mget_ipython\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrun_line_magic\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'reload_ext'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'spark'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;31m# Unit test for FRAME_RATE\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'spark'" - ] - } - ], + "outputs": [], "source": [ "import spark\r\n", "%reload_ext spark\r\n", @@ -26,7 +15,8 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 9, + "id": "commercial-islam", "metadata": {}, "outputs": [ { @@ -105,16 +95,30 @@ ".output_html .vg { color: #19177C } /* Name.Variable.Global */\n", ".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n", ".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n", - ".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */
Done drawing.\n",
+       ".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */
Stopped\n",
        "
\n" ], "text/latex": [ "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", - "\\PY{err}{D}\\PY{err}{o}\\PY{err}{n}\\PY{err}{e}\\PY{err}{ }\\PY{err}{d}\\PY{err}{r}\\PY{err}{a}\\PY{err}{w}\\PY{err}{i}\\PY{err}{n}\\PY{err}{g}\\PY{err}{.}\n", + "\\PY{err}{S}\\PY{err}{t}\\PY{err}{o}\\PY{err}{p}\\PY{err}{p}\\PY{err}{e}\\PY{err}{d}\n", "\\end{Verbatim}\n" ], "text/plain": [ - "Done drawing." + "Stopped" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "e90b48a28d754b98a473c7ceef8ca21e", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Button(description='Stop', style=ButtonStyle())" ] }, "metadata": {}, @@ -123,7 +127,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "b979b65b533c4dd1bc4871df23cb73fe", + "model_id": "840a907740a1451cb8e72795767c686e", "version_major": 2, "version_minor": 0 }, @@ -229,16 +233,19 @@ "source": [ "%%ignite\n", "\n", + "# The FRAME_RATE variable is accessible to the user\n", + "# It's value should not be changed.\n", + "\n", "def setup():\n", " size(200, 100)\n", " background(\"light blue\")\n", - " print(\"frame rate:\", FRAME_RATE)\n", - " # this prints 30, the actual frame rate" + " print(\"frame rate:\", FRAME_RATE)" ] }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 19, + "id": "norwegian-estonia", "metadata": {}, "outputs": [ { @@ -317,16 +324,16 @@ ".output_html .vg { color: #19177C } /* Name.Variable.Global */\n", ".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n", ".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n", - ".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */
Done drawing.\n",
+       ".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */
Stopped\n",
        "
\n" ], "text/latex": [ "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", - "\\PY{err}{D}\\PY{err}{o}\\PY{err}{n}\\PY{err}{e}\\PY{err}{ }\\PY{err}{d}\\PY{err}{r}\\PY{err}{a}\\PY{err}{w}\\PY{err}{i}\\PY{err}{n}\\PY{err}{g}\\PY{err}{.}\n", + "\\PY{err}{S}\\PY{err}{t}\\PY{err}{o}\\PY{err}{p}\\PY{err}{p}\\PY{err}{e}\\PY{err}{d}\n", "\\end{Verbatim}\n" ], "text/plain": [ - "Done drawing." + "Stopped" ] }, "metadata": {}, @@ -335,211 +342,12 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "768bb7ac20e843528a812a505ad79625", + "model_id": "7ccab1ce0b2b4ef8ab1db8ea85bfa5e7", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "Canvas(height=100, width=100)" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
frame rate: 1\n",
-       "
\n" - ], - "text/latex": [ - "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", - "\\PY{err}{f}\\PY{err}{r}\\PY{err}{a}\\PY{err}{m}\\PY{err}{e}\\PY{err}{ }\\PY{err}{r}\\PY{err}{a}\\PY{err}{t}\\PY{err}{e}\\PY{err}{:}\\PY{err}{ }\\PY{err}{1}\n", - "\\end{Verbatim}\n" - ], - "text/plain": [ - "frame rate: 1" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%ignite\n", - "\n", - "def setup():\n", - " size(200, 100)\n", - " background(\"light blue\")\n", - " FRAME_RATE = 1\n", - " print(\"frame rate:\", FRAME_RATE)\n", - " # this prints 1, not what I want\n" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
Error in setup() function: local variable 'FRAME_RATE' referenced before assignment\n",
-       "
\n" - ], - "text/latex": [ - "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", - "\\PY{n}{Error} \\PY{o+ow}{in} \\PY{n}{setup}\\PY{p}{(}\\PY{p}{)} \\PY{n}{function}\\PY{p}{:} \\PY{n}{local} \\PY{n}{variable} \\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{FRAME\\PYZus{}RATE}\\PY{l+s+s1}{\\PYZsq{}} \\PY{n}{referenced} \\PY{n}{before} \\PY{n}{assignment}\n", - "\\end{Verbatim}\n" - ], - "text/plain": [ - "Error in setup() function: local variable 'FRAME_RATE' referenced before assignment" + "Button(description='Stop', style=ButtonStyle())" ] }, "metadata": {}, @@ -548,7 +356,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "62bace9c8b6a472b8eda88eb47e25ec0", + "model_id": "d4a8b0faf6a54cf995b9fc7b6ecd7c49", "version_major": 2, "version_minor": 0 }, @@ -635,15 +443,17 @@ ".output_html .vg { color: #19177C } /* Name.Variable.Global */\n", ".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n", ".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n", - ".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */
\n",
+       ".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */
frame rate: 30\n",
        "
\n" ], "text/latex": [ "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", - "\n", + "\\PY{err}{f}\\PY{err}{r}\\PY{err}{a}\\PY{err}{m}\\PY{err}{e}\\PY{err}{ }\\PY{err}{r}\\PY{err}{a}\\PY{err}{t}\\PY{err}{e}\\PY{err}{:}\\PY{err}{ }\\PY{err}{3}\\PY{err}{0}\n", "\\end{Verbatim}\n" ], - "text/plain": [] + "text/plain": [ + "frame rate: 30" + ] }, "metadata": {}, "output_type": "display_data" @@ -652,17 +462,27 @@ "source": [ "%%ignite\n", "\n", + "# An example use-case is to set speeds in pixels/second using FRAME_RATE\n", + "\n", "def setup():\n", - " size(200, 100)\n", + " size(500, 300)\n", " background(\"light blue\")\n", " print(\"frame rate:\", FRAME_RATE)\n", - " FRAME_RATE = 10\n", - " # this gives an error, FRAME_RATE is referenced before assignment" + "\n", + "x = 0\n", + "speed = 250/FRAME_RATE # this speed will be 200 pixels/second\n", + "\n", + "def draw():\n", + " background(\"light blue\")\n", + " global x, speed\n", + " circle(x, 50, 30)\n", + " x += speed" ] }, { "cell_type": "code", "execution_count": null, + "id": "married-fabric", "metadata": {}, "outputs": [], "source": [] @@ -684,9 +504,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.1-final" + "version": "3.9.1" } }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} From a1b9122a4819f8c0f94f57e6e9926accd49b1653 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 8 Mar 2021 11:41:56 -0700 Subject: [PATCH 14/14] Added FRAME_RATE docs Added a description of FRAME_RATE to utilities.md --- docs/img/frame_rate.png | Bin 0 -> 5585 bytes docs/utilities.md | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 docs/img/frame_rate.png diff --git a/docs/img/frame_rate.png b/docs/img/frame_rate.png new file mode 100644 index 0000000000000000000000000000000000000000..e71495973ce4340d68ac5873a9083fbe12aada40 GIT binary patch literal 5585 zcmeHLX*8Q%yNG}1Yb=LRqtn=fn^W$32v-f(QwePj}zOVbb?sOX~QxV|b zKmY(BVs_)Y9RR>*%)?PZ0p3h$xj3Hp;ES*`H3VP=PtNlO`~9z3UIPFcvV^w1`FZ1m z;Wu0&007bMKj7;LtMcJZo{luW6=`(e*E=#WEcBE^V2Cf^vg&0uUDYePs@kX2)O4?? z>t4~xeN^}Z0FclzyME0f#*;-C`p1D%+_SO=0DjjN*zaJXDtP3BX{q-G6Y(>0-y+n$ z-)$-jzN(0E1!WAF+&$>@H0Ow=(oNN_JEtWi?`7tl&3L?DXrEyAbH}r*!o7F*d+q1< ze(+#%+iGTHo6$L>YM`{90CvPLeV>Xao6DK&vkOPLqjM68;l5$WmSK#Xlxu_YGstD z2I{!=kw~omD`epaKw71MbA~@M^65b9asncJZPIDzvV`I)Nm3H^(3&)DjKVi@5-B~2 z92L|Bw?==4Qh|#4s$S$S2R@( zm56}Q??N2|Zlbb_y_J9e{=G3*o|S4wnzVCwhX_e3|7Xx92aO$5&SF?Hd0Bduui0~v zPir^tnBOA5Zvofgrq9k&(CpDQ*Em|lFlQ&&(GRRNryaP6>f2s!!9~wnj0H0$1l7=LB708 z_9o7H!Pt)4=bcg#_ipqkoI_a^2R%F>hQVeH9wxsrPDJS^41cYa|gl_?|Kj-53;hryDcKpy6PSxgGD-5AX&MLBAtku;Bkz%n}eNQHfa3O!J}Ob zBPeSzh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IdGJhJ6AA&CzJ$B~LG}u~1`; z1bKVpetVto85F@76k!6s{B)N`|E;8?)Ld3pR*$*5$TKT~=C2{`6HPuXRUi9_=#o}Qke_LUY50|+fQp5`0|0u*?u1$;L=JZvMU z?AqMR%SE(EW!2?TO>7_-UW)#-y}j)t2DtI5b*bsE#+H_eu^N}7V|r1G$1xXnw;5n- z=d1-g*`)0iEZPjv+iEj99_Apy>*8IksU|5Myv2G*m`_3%Q-LS z*3YZGaMhM03W8~((m_pr13;z*jqjB1qS0YMqXL8H$A=F67is;kGW&n;z2fDL>;yeN W>f%eQ2fU6ez|7d{I>zvJ%6|ZS;$eXR literal 0 HcmV?d00001 diff --git a/docs/utilities.md b/docs/utilities.md index 1d29de3..a4a01c6 100644 --- a/docs/utilities.md +++ b/docs/utilities.md @@ -124,4 +124,40 @@ def setup(): Results in: -![dist demo](img/dist_2.png) \ No newline at end of file +![dist demo](img/dist_2.png) + +### Accessing the canvas frame rate + +The frame rate of the canvas can be accessed through the built-in variable + +```python +FRAME_RATE +``` + +The value of FRAME_RATE is set to 30 by default, and should not be changed by the user. Changing this manually will not change the actual frame rate, and will likely result in errors. + +**Example:** + +```python +%%ignite + +def setup(): + print(FRAME_RATE) +``` + +Results in: + +![FRAME_RATE demo](img/frame_rate.png) + +The use-cases of this of this variable are fairly limited, but can be used for example to set a speed variable in terms of the frame rate. For example: + +```python +x = 10 +speed = 300/FRAME_RATE + +def draw(): + global x, speed + circle(x, 100, 50) + x += speed +``` +will result in the circle moving across the screen at 300 pixels per second. \ No newline at end of file