From 886fe6621668c204c7593c255bcf58e26e4987d7 Mon Sep 17 00:00:00 2001 From: tessyraspberrypi <136448689+tessyraspberrypi@users.noreply.github.com> Date: Fri, 23 Jun 2023 11:42:18 +0100 Subject: [PATCH 1/6] Updated line of code --- lib/tasks/project_components/hello_world_example/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tasks/project_components/hello_world_example/main.py b/lib/tasks/project_components/hello_world_example/main.py index d84bb32bd..8b705eda4 100644 --- a/lib/tasks/project_components/hello_world_example/main.py +++ b/lib/tasks/project_components/hello_world_example/main.py @@ -4,6 +4,7 @@ # Emoji variables to use in your project world = '🌍🌎🌏' python = 'Python 🐍' +fire = 🔥 # Emojis to copy and paste into your code # 📅🕒🎨🎮🔬🎉🕶️🎲🦄🚀💯⭐💛 From 39a9cea9504047f0098fad86ff0b9663d3eaecf1 Mon Sep 17 00:00:00 2001 From: Pete Bell <104009652+pjbRPF@users.noreply.github.com> Date: Mon, 26 Jun 2023 14:22:45 +0100 Subject: [PATCH 2/6] Create p5.py --- .../target_practice_starter/p5.py | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 lib/tasks/project_components/target_practice_starter/p5.py diff --git a/lib/tasks/project_components/target_practice_starter/p5.py b/lib/tasks/project_components/target_practice_starter/p5.py new file mode 100644 index 000000000..3ef9571e8 --- /dev/null +++ b/lib/tasks/project_components/target_practice_starter/p5.py @@ -0,0 +1,137 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def circle(x, y, w): + ellipse(x, y, w, w) + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() From 73088ba2af689753a66d96eb1d1a6eeb05d57832 Mon Sep 17 00:00:00 2001 From: Pete Bell <104009652+pjbRPF@users.noreply.github.com> Date: Mon, 26 Jun 2023 14:33:26 +0100 Subject: [PATCH 3/6] Delete p5.py --- .../target_practice_starter/p5.py | 137 ------------------ 1 file changed, 137 deletions(-) delete mode 100644 lib/tasks/project_components/target_practice_starter/p5.py diff --git a/lib/tasks/project_components/target_practice_starter/p5.py b/lib/tasks/project_components/target_practice_starter/p5.py deleted file mode 100644 index 3ef9571e8..000000000 --- a/lib/tasks/project_components/target_practice_starter/p5.py +++ /dev/null @@ -1,137 +0,0 @@ -# Definitions for compatibility with the p5py processing library -from processing import * -import __main__ - -# Shape -from processing import rectMode as rect_mode -from processing import ellipseMode as ellipse_mode -from processing import strokeWeight as stroke_weight -from processing import strokeCap as stroke_cap -from processing import strokeJoin as stroke_join -from processing import noStroke as no_stroke -from processing import noFill as no_fill - -# Fonts -from processing import createFont as create_font -from processing import loadFont as load_font -from processing import textFont as text_font - -# Text -from processing import textAlign as text_align -from processing import textLeading as text_leading -from processing import textMode as text_mode -from processing import textSize as text_size -from processing import textWidth as text_width - -# Colour -from processing import blendColor as blend_color -from processing import lerpColor as lerp_color -from processing import color as Color - -# Images -from processing import createImage as create_image -from processing import imageMode as image_mode -from processing import loadImage as load_image -from processing import noTint as no_tint -from processing import requestImage as request_image - -# Environment -from processing import frameRate as frame_rate -from processing import noCursor as no_cursor -from processing import noLoop as no_loop - -# Transform -from processing import applyMatrix as apply_matrix -from processing import popMatrix as pop_matrix -from processing import printMatrix as print_matrix -from processing import pushMatrix as push_matrix -from processing import resetMatrix as reset_matrix -from processing import rotateX as rotate_x -from processing import rotateY as rotate_y -from processing import pushStyle as push_style -from processing import popStyle as pop_style - -from processing import run as main_run - -# Keyboard - -def mousePressed(): - if hasattr(__main__, "mouse_pressed"): - mouse_pressed = getattr(__main__, "mouse_pressed") - mouse_pressed() - -def mouseReleased(): - if hasattr(__main__, "mouse_released"): - mouse_released = getattr(__main__, "mouse_released") - mouse_released() - -__main__.mouse_x = 0 -__main__.mouse_y = 0 -__main__.mouse_px = 0 -__main__.mouse_py = 0 -__main__.frame_count = 0 -__main__.frame_rate = 60 - -def mouseMoved(): - __main__.mouse_x = mouse.x - __main__.mouse_y = mouse.y - __main__.mouse_px = mouse.px - __main__.mouse_py = mouse.py - if hasattr(__main__, "mouse_moved"): - mouse_moved = getattr(__main__, "mouse_moved") - mouse_moved() - -def mouseDragged(): - if hasattr(__main__, "mouse_dragged"): - mouse_dragged = getattr(__main__, "mouse_dragged") - mouse_dragged() - -def new_draw(): - __main__.frame_count = frameCount - frameRate = __main__.frame_rate - old_draw() - -def run(): - global old_draw - old_draw = __main__.draw - __main__.draw = new_draw - main_run() - -def grid(): - pushMatrix() - stroke(200) - fill(0) - line(0, height/2, width, height/2) - line(width/2, 0, width/2, height) - x_coords = [0, width/2, width] - y_coords = [0, height/2, height] - - for x in x_coords: - for y in y_coords: - show_coord(x, y) - - popMatrix() - -def circle(x, y, w): - ellipse(x, y, w, w) - -def show_coord(x, y): - if x == width: - x_align = RIGHT - elif x == 0: - x_align = LEFT - else: - x_align = CENTER - - if y == height: - y_align = BASELINE - elif y == 0: - y_align = TOP - else: - y_align = CENTER - - pushStyle() - fill(100) - text_align(x_align, y_align) - text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) - popStyle() From 9e3df928bf46bae82063cf8ba3149f7c5aa24f32 Mon Sep 17 00:00:00 2001 From: Pete Bell <104009652+pjbRPF@users.noreply.github.com> Date: Mon, 26 Jun 2023 14:54:08 +0100 Subject: [PATCH 4/6] Create p5.py --- .../target_practice_example/p5.py | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 lib/tasks/project_components/target_practice_example/p5.py diff --git a/lib/tasks/project_components/target_practice_example/p5.py b/lib/tasks/project_components/target_practice_example/p5.py new file mode 100644 index 000000000..4249cd99a --- /dev/null +++ b/lib/tasks/project_components/target_practice_example/p5.py @@ -0,0 +1,139 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def circle(x, y, w): + ellipse(x, y, w, w) + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + + From 1df235dbf3765c08f7979ddd82080a4a420f4416 Mon Sep 17 00:00:00 2001 From: tessyraspberrypi <136448689+tessyraspberrypi@users.noreply.github.com> Date: Mon, 26 Jun 2023 16:37:06 +0100 Subject: [PATCH 5/6] Update variables main.py --- lib/tasks/project_components/hello_world_example/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/project_components/hello_world_example/main.py b/lib/tasks/project_components/hello_world_example/main.py index 8b705eda4..87d61800a 100644 --- a/lib/tasks/project_components/hello_world_example/main.py +++ b/lib/tasks/project_components/hello_world_example/main.py @@ -4,7 +4,7 @@ # Emoji variables to use in your project world = '🌍🌎🌏' python = 'Python 🐍' -fire = 🔥 +fire = '🔥' # Emojis to copy and paste into your code # 📅🕒🎨🎮🔬🎉🕶️🎲🦄🚀💯⭐💛 @@ -17,7 +17,7 @@ def roll_dice(): max = input('How many sides for a 🎲?: ') # Wait for input from the user print('Rolling a', max, 'sided dice ...') # Use the number the user entered roll = randint(1, int(max)) # Generate a random number between 1 and 6 - print(roll, '🔥' * roll) # Repeat the fire emoji to match the dice roll + print(roll, fire * roll) # Repeat the fire emoji to match the dice roll # Put code to run under here print('Hello', world) From 845f8126f03db3e22d8713ee50d1c540495b68a7 Mon Sep 17 00:00:00 2001 From: tessyraspberrypi <136448689+tessyraspberrypi@users.noreply.github.com> Date: Mon, 26 Jun 2023 16:43:42 +0100 Subject: [PATCH 6/6] Update display main.py --- lib/tasks/project_components/hello_world_example/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/project_components/hello_world_example/main.py b/lib/tasks/project_components/hello_world_example/main.py index 87d61800a..23584a5b9 100644 --- a/lib/tasks/project_components/hello_world_example/main.py +++ b/lib/tasks/project_components/hello_world_example/main.py @@ -8,7 +8,7 @@ # Emojis to copy and paste into your code # 📅🕒🎨🎮🔬🎉🕶️🎲🦄🚀💯⭐💛 -# 😃😜❤️📚⚽🎾👟♻️🌳🔥✨🥺🌈 +# 😃😜❤️📚⚽🎾👟♻️🌳✨🥺🌈 # Useful characters :',()*_/.# @@ -17,7 +17,7 @@ def roll_dice(): max = input('How many sides for a 🎲?: ') # Wait for input from the user print('Rolling a', max, 'sided dice ...') # Use the number the user entered roll = randint(1, int(max)) # Generate a random number between 1 and 6 - print(roll, fire * roll) # Repeat the fire emoji to match the dice roll + print('You rolled a', roll, fire * roll) # Repeat the fire emoji to match the dice roll # Put code to run under here print('Hello', world)