diff --git a/public/usage-examples/color/random_rgb_color-1-example-oop.cs b/public/usage-examples/color/random_rgb_color-1-example-oop.cs new file mode 100644 index 000000000..7762a00b4 --- /dev/null +++ b/public/usage-examples/color/random_rgb_color-1-example-oop.cs @@ -0,0 +1,42 @@ +using SplashKitSDK; + +namespace RandomRgbColorExample +{ + public class Program + { + public static void Main() + { + // Open a window to display the random colours + Window wind = SplashKit.OpenWindow("Random Colour Grid", 640, 480); + + while (!SplashKit.QuitRequested()) + { + SplashKit.ProcessEvents(); + + // Clear the screen before drawing + SplashKit.ClearWindow(wind, SplashKit.ColorWhite()); + + // Draw a grid of squares with random colours + for (int row = 0; row < 4; row++) + { + for (int col = 0; col < 4; col++) + { + Color randomColour = SplashKit.RandomRgbColor(255); + + SplashKit.FillRectangle(randomColour, 80 + col * 120, 80 + row * 80, 80, 50); + SplashKit.DrawRectangle(SplashKit.ColorBlack(), 80 + col * 120, 80 + row * 80, 80, 50); + } + } + + // Add a label to explain the example + SplashKit.DrawText("Each square uses RandomRgbColor()", SplashKit.ColorBlack(), 150, 420); + + // Refresh the window to show updated colours + SplashKit.RefreshWindow(wind); + } + + // Close the window when the program ends + SplashKit.CloseAllWindows(); + } + } +} \ No newline at end of file diff --git a/public/usage-examples/color/random_rgb_color-1-example-top-level.cs b/public/usage-examples/color/random_rgb_color-1-example-top-level.cs new file mode 100644 index 000000000..31f79ab5c --- /dev/null +++ b/public/usage-examples/color/random_rgb_color-1-example-top-level.cs @@ -0,0 +1,34 @@ +using static SplashKitSDK.SplashKit; +using SplashKitSDK; + +// Open a window to display the random colours +Window wind = OpenWindow("Random Colour Grid", 640, 480); + +while (!QuitRequested()) +{ + ProcessEvents(); + + // Clear the screen before drawing + ClearWindow(wind, ColorWhite()); + + // Draw a grid of squares with random colours + for (int row = 0; row < 4; row++) + { + for (int col = 0; col < 4; col++) + { + Color randomColour = RandomRgbColor(255); + + FillRectangle(randomColour, 80 + col * 120, 80 + row * 80, 80, 50); + DrawRectangle(ColorBlack(), 80 + col * 120, 80 + row * 80, 80, 50); + } + } + + // Add a label to explain the example + DrawText("Each square uses RandomRgbColor()", ColorBlack(), 150, 420); + + // Refresh the window to show updated colours + RefreshWindow(wind); +} + +// Close the window when the program ends +CloseAllWindows(); \ No newline at end of file diff --git a/public/usage-examples/color/random_rgb_color-1-example.cpp b/public/usage-examples/color/random_rgb_color-1-example.cpp new file mode 100644 index 000000000..41adad3d4 --- /dev/null +++ b/public/usage-examples/color/random_rgb_color-1-example.cpp @@ -0,0 +1,38 @@ +#include "splashkit.h" + +int main() +{ + // Open a window to display the random colours + open_window("Random Colour Grid", 640, 480); + + while (!quit_requested()) + { + process_events(); + + // Clear the screen before drawing + clear_screen(color_white()); + + // Draw a grid of squares with random colours + for (int row = 0; row < 4; row++) + { + for (int col = 0; col < 4; col++) + { + color random_colour = random_rgb_color(255); + + fill_rectangle(random_colour, 80 + col * 120, 80 + row * 80, 80, 50); + draw_rectangle(color_black(), 80 + col * 120, 80 + row * 80, 80, 50); + } + } + + // Add a label to explain the example + draw_text("Each square uses random_rgb_color()", color_black(), 150, 420); + + // Refresh the screen to show the updated colours + refresh_screen(2); + } + + // Close the window when the program ends + close_all_windows(); + + return 0; +} \ No newline at end of file diff --git a/public/usage-examples/color/random_rgb_color-1-example.gif b/public/usage-examples/color/random_rgb_color-1-example.gif new file mode 100644 index 000000000..b8ee147e8 Binary files /dev/null and b/public/usage-examples/color/random_rgb_color-1-example.gif differ diff --git a/public/usage-examples/color/random_rgb_color-1-example.py b/public/usage-examples/color/random_rgb_color-1-example.py new file mode 100644 index 000000000..e7884366c --- /dev/null +++ b/public/usage-examples/color/random_rgb_color-1-example.py @@ -0,0 +1,27 @@ +from splashkit import * + +# Open a window to display the random colours +open_window("Random Colour Grid", 640, 480) + +while not quit_requested(): + process_events() + + # Clear the screen before drawing + clear_screen(Color.WHITE) + + # Draw a grid of squares with random colours + for row in range(4): + for col in range(4): + random_colour = random_rgb_color(255) + + fill_rectangle(random_colour, 80 + col * 120, 80 + row * 80, 80, 50) + draw_rectangle(Color.BLACK, 80 + col * 120, 80 + row * 80, 80, 50) + + # Add a label to explain the example + draw_text("Each square uses random_rgb_color()", Color.BLACK, 150, 420) + + # Refresh the screen to show updated colours + refresh_screen_with_target_fps(2) + +# Close the window when the program ends +close_all_windows() \ No newline at end of file diff --git a/public/usage-examples/color/random_rgb_color-1-example.txt b/public/usage-examples/color/random_rgb_color-1-example.txt new file mode 100644 index 000000000..266ea18f1 --- /dev/null +++ b/public/usage-examples/color/random_rgb_color-1-example.txt @@ -0,0 +1 @@ +Random Colour Grid \ No newline at end of file