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 000000000..3776b29de Binary files /dev/null and b/public/usage-examples/color/random_color-2-example.png differ 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