From b399acbcd66c1cedf6e61d52e24b0d443cc13478 Mon Sep 17 00:00:00 2001 From: Sparshdeep Singh <66513733+Sparsh300@users.noreply.github.com> Date: Thu, 21 May 2026 20:25:53 +1000 Subject: [PATCH] feat: add interactive random_color usage example --- .../color/random_color-2-example-oop.cs | 40 ++++++++++++++++++ .../color/random_color-2-example-top-level.cs | 34 +++++++++++++++ .../color/random_color-2-example.cpp | 33 +++++++++++++++ .../color/random_color-2-example.png | Bin 0 -> 68 bytes .../color/random_color-2-example.py | 24 +++++++++++ .../color/random_color-2-example.txt | 3 ++ 6 files changed, 134 insertions(+) create mode 100644 public/usage-examples/color/random_color-2-example-oop.cs create mode 100644 public/usage-examples/color/random_color-2-example-top-level.cs create mode 100644 public/usage-examples/color/random_color-2-example.cpp create mode 100644 public/usage-examples/color/random_color-2-example.png create mode 100644 public/usage-examples/color/random_color-2-example.py create mode 100644 public/usage-examples/color/random_color-2-example.txt diff --git a/public/usage-examples/color/random_color-2-example-oop.cs b/public/usage-examples/color/random_color-2-example-oop.cs new file mode 100644 index 000000000..30bac4666 --- /dev/null +++ b/public/usage-examples/color/random_color-2-example-oop.cs @@ -0,0 +1,40 @@ +using SplashKitSDK; + +public static class Program +{ + public static void Main() + { + new Window("Random Color Example", 800, 600); + + Color boxColor = Color.Blue; + + while (!SplashKit.QuitRequested()) + { + SplashKit.ProcessEvents(); + + if (SplashKit.MouseClicked(MouseButton.LeftButton)) + { + boxColor = SplashKit.RandomColor(); + } + + SplashKit.ClearScreen(Color.White); + + SplashKit.FillRectangle( + boxColor, + 250, + 200, + 300, + 180 + ); + + SplashKit.DrawText( + "Click anywhere to change colour", + Color.Black, + 220, + 420 + ); + + SplashKit.RefreshScreen(); + } + } +} \ No newline at end of file diff --git a/public/usage-examples/color/random_color-2-example-top-level.cs b/public/usage-examples/color/random_color-2-example-top-level.cs new file mode 100644 index 000000000..90a05459c --- /dev/null +++ b/public/usage-examples/color/random_color-2-example-top-level.cs @@ -0,0 +1,34 @@ +using SplashKitSDK; + +new Window("Random Color Example", 800, 600); + +Color boxColor = Color.Blue; + +while (!SplashKit.QuitRequested()) +{ + SplashKit.ProcessEvents(); + + if (SplashKit.MouseClicked(MouseButton.LeftButton)) + { + boxColor = SplashKit.RandomColor(); + } + + SplashKit.ClearScreen(Color.White); + + SplashKit.FillRectangle( + boxColor, + 250, + 200, + 300, + 180 + ); + + SplashKit.DrawText( + "Click anywhere to change colour", + Color.Black, + 220, + 420 + ); + + SplashKit.RefreshScreen(); +} \ No newline at end of file diff --git a/public/usage-examples/color/random_color-2-example.cpp b/public/usage-examples/color/random_color-2-example.cpp new file mode 100644 index 000000000..2ce69877a --- /dev/null +++ b/public/usage-examples/color/random_color-2-example.cpp @@ -0,0 +1,33 @@ +#include "splashkit.h" + +int main() +{ + open_window("Random Color Example", 800, 600); + + color box_color = COLOR_BLUE; + + while (!quit_requested()) + { + process_events(); + + if (mouse_clicked(LEFT_BUTTON)) + { + box_color = random_color(); + } + + clear_screen(COLOR_WHITE); + + fill_rectangle(box_color, 250, 200, 300, 180); + + draw_text( + "Click anywhere to change colour", + COLOR_BLACK, + 220, + 420 + ); + + refresh_screen(); + } + + return 0; +} \ No newline at end of file diff --git a/public/usage-examples/color/random_color-2-example.png b/public/usage-examples/color/random_color-2-example.png new file mode 100644 index 0000000000000000000000000000000000000000..3776b29de46f11dccb14837b0f007836a8f8b922 GIT binary patch literal 68 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx0wlM}@Gt=>Zci7-kcwN$fBwreFui2_*0`m7 Q4N#cD)78&qol`;+0HiDr^8f$< literal 0 HcmV?d00001 diff --git a/public/usage-examples/color/random_color-2-example.py b/public/usage-examples/color/random_color-2-example.py new file mode 100644 index 000000000..53e790278 --- /dev/null +++ b/public/usage-examples/color/random_color-2-example.py @@ -0,0 +1,24 @@ +from splashkit import * + +open_window("Random Color Example", 800, 600) + +box_color = color_blue() + +while not quit_requested(): + process_events() + + if mouse_clicked(LEFT_BUTTON): + box_color = random_color() + + clear_screen(color_white()) + + fill_rectangle(box_color, 250, 200, 300, 180) + + draw_text( + "Click anywhere to change colour", + color_black(), + 220, + 420 + ) + + refresh_screen() \ No newline at end of file diff --git a/public/usage-examples/color/random_color-2-example.txt b/public/usage-examples/color/random_color-2-example.txt new file mode 100644 index 000000000..d93dd761c --- /dev/null +++ b/public/usage-examples/color/random_color-2-example.txt @@ -0,0 +1,3 @@ +Interactive random colour example + +Click the rectangle to change it to a random colour using random_color(). \ No newline at end of file