Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions public/usage-examples/color/random_rgb_color-1-example-oop.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
@@ -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();
38 changes: 38 additions & 0 deletions public/usage-examples/color/random_rgb_color-1-example.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions public/usage-examples/color/random_rgb_color-1-example.py
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions public/usage-examples/color/random_rgb_color-1-example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Random Colour Grid