diff --git a/public/usage-examples/graphics/current_clip/current-clip-1-simple-oop.cs b/public/usage-examples/graphics/current_clip/current-clip-1-simple-oop.cs new file mode 100644 index 00000000..942c2047 --- /dev/null +++ b/public/usage-examples/graphics/current_clip/current-clip-1-simple-oop.cs @@ -0,0 +1,24 @@ +using SplashKitSDK; + +public class Program +{ + public static void Main() + { + // Open a window with the title "Current Clip" and dimensions + Window window= SplashKit.OpenWindow("Current Clip", 800, 600); + + // Push a clipping area + Rectangle rectangle = SplashKit.CurrentClip(); + // Display information about the current clipping area (Width and Height) in the window + SplashKit.DrawText($"Current Clip: Width:{rectangle.Width} Height:{rectangle.Height}", Color.Black, "Arial", 24, 100, 100); + + // Refresh the screen to display the text + SplashKit.RefreshScreen(); + + // Wait for 5 seconds to observe the clipping area information + SplashKit.Delay(5000); + + // Close the window + SplashKit.CloseAllWindows(); + } +} diff --git a/public/usage-examples/graphics/current_clip/current-clip-1-simple-top-level.cs b/public/usage-examples/graphics/current_clip/current-clip-1-simple-top-level.cs new file mode 100644 index 00000000..c9b50e0f --- /dev/null +++ b/public/usage-examples/graphics/current_clip/current-clip-1-simple-top-level.cs @@ -0,0 +1,19 @@ +using static SplashKitSDK.SplashKit; +using SplashKitSDK; + // Open a window with the title "Current Clip" and dimensions + Window window= OpenWindow("Current Clip", 800, 600); + + // Push a clipping area + Rectangle rectangle = CurrentClip(); + // Display information about the current clipping area (Width and Height) in the window + DrawText($"Current Clip: Width:{rectangle.Width} Height:{rectangle.Height}", Color.Black, "Arial", 24, 100, 100); + + // Refresh the screen to display the text + RefreshScreen(); + + // Wait for 5 seconds to observe the clipping area information + Delay(5000); + + // Close the window + CloseAllWindows(); + diff --git a/public/usage-examples/graphics/current_clip/current-clip-1-simple.cpp b/public/usage-examples/graphics/current_clip/current-clip-1-simple.cpp new file mode 100644 index 00000000..635f2a2a --- /dev/null +++ b/public/usage-examples/graphics/current_clip/current-clip-1-simple.cpp @@ -0,0 +1,24 @@ +#include "splashkit.h" + +int main() +{ + // Open a window with the title "Current Clip" and dimensions + window win = open_window("Current Clip", 800, 600); + + // Define the clipping area + rectangle rect = current_clip(win); + + // Draw the clipping information + draw_text("Current Clip: " + std::to_string(rect.width) + " X " + std::to_string(rect.height), COLOR_BLACK, "Arial", 24, 100, 100); + + // Refresh the screen to display the text + refresh_screen(); + + // Wait for 5 seconds + delay(5000); + + // Close all windows + close_all_windows(); + + return 0; +} diff --git a/public/usage-examples/graphics/current_clip/current-clip-1-simple.png b/public/usage-examples/graphics/current_clip/current-clip-1-simple.png new file mode 100644 index 00000000..69b2b75e Binary files /dev/null and b/public/usage-examples/graphics/current_clip/current-clip-1-simple.png differ diff --git a/public/usage-examples/graphics/current_clip/current-clip-1-simple.py b/public/usage-examples/graphics/current_clip/current-clip-1-simple.py new file mode 100644 index 00000000..04d81b5c --- /dev/null +++ b/public/usage-examples/graphics/current_clip/current-clip-1-simple.py @@ -0,0 +1,21 @@ +from splashkit import * + +# Open a window with the title "Current Clip" and dimensions of 800x600 pixels +window = open_window("Current Clip", 800, 600) +font = load_font("Arial", "arial.ttf") + +# Retrieve the current clipping area +r = current_clip() + +# Draw the clipping area dimensions as text on the screen +draw_text("Current Clip: " + str(r.width) + " X " + str(r.height), color_black(), font, 24, 100, 100) + +# Refresh the screen to display the text +refresh_screen() + +# Wait for 5 seconds +delay(5000) + +# Close all windows +close_all_windows() + diff --git a/public/usage-examples/graphics/current_clip/current-clip-1-simple.txt b/public/usage-examples/graphics/current_clip/current-clip-1-simple.txt new file mode 100644 index 00000000..ab748f8b --- /dev/null +++ b/public/usage-examples/graphics/current_clip/current-clip-1-simple.txt @@ -0,0 +1,3 @@ +#### CURRENT CLIP + +The following code shows an examples of using [Current Clip](/api/graphics#current-clip) to set a clip region and draw a rectangle to visually show the active clipping area. \ No newline at end of file diff --git a/public/usage-examples/graphics/pop_clip/pop-clip-1-simple-oop.cs b/public/usage-examples/graphics/pop_clip/pop-clip-1-simple-oop.cs new file mode 100644 index 00000000..dab48510 --- /dev/null +++ b/public/usage-examples/graphics/pop_clip/pop-clip-1-simple-oop.cs @@ -0,0 +1,34 @@ +using SplashKitSDK; + +public class Program +{ + public static void Main() + { + // Open a window with the title "Pop Clip" and dimensions 800x600 + Window window = SplashKit.OpenWindow("Pop Clip", 800, 600); + + // Define a rectangle for the clipping area starting at (100, 100) with width 600 and height 400 + Rectangle rectangle = SplashKit.RectangleFrom(100, 100, 600, 400); + + // Push a clipping area to restrict drawing to within the defined rectangle + SplashKit.PushClip(window, rectangle); + + // Draw a blue rectangle within the clipping area (this will be affected by clipping) + SplashKit.FillRectangle(Color.Blue, 50, 50, 700, 500); // This will be clipped + + // Pop the clipping area to restore the full window area for drawing + SplashKit.PopClip(window); + + // Draw a red rectangle outside the clipping area (this will be fully visible) + SplashKit.FillRectangle(Color.Red, 100, 100, 200, 200); // This won't be clipped + + // Refresh the screen to display all changes + SplashKit.RefreshScreen(); + + // Wait for 5 seconds before closing the window + SplashKit.Delay(5000); + + // Close all open windows to end the program + SplashKit.CloseAllWindows(); + } +} diff --git a/public/usage-examples/graphics/pop_clip/pop-clip-1-simple-top-level.cs b/public/usage-examples/graphics/pop_clip/pop-clip-1-simple-top-level.cs new file mode 100644 index 00000000..5a6f2136 --- /dev/null +++ b/public/usage-examples/graphics/pop_clip/pop-clip-1-simple-top-level.cs @@ -0,0 +1,31 @@ +using static SplashKitSDK.SplashKit; +using SplashKitSDK; + + // Open a window with the title "Pop Clip" and dimensions 800x600 + Window window = OpenWindow("Pop Clip", 800, 600); + + // Define a rectangle for the clipping area starting at (100, 100) with width 600 and height 400 + Rectangle rectangle = RectangleFrom(100, 100, 600, 400); + + // Push a clipping area to restrict drawing to within the defined rectangle + PushClip(window, rectangle); + + // Draw a blue rectangle within the clipping area (this will be affected by clipping) + FillRectangle(Color.Blue, 50, 50, 700, 500); // This will be clipped + + // Pop the clipping area to restore the full window area for drawing + PopClip(window); + + // Draw a red rectangle outside the clipping area (this will be fully visible) + FillRectangle(Color.Red, 100, 100, 200, 200); // This won't be clipped + + // Refresh the screen to display all changes + RefreshScreen(); + + // Wait for 5 seconds before closing the window + Delay(5000); + + // Close all open windows to end the program + CloseAllWindows(); + + diff --git a/public/usage-examples/graphics/pop_clip/pop-clip-1-simple.cpp b/public/usage-examples/graphics/pop_clip/pop-clip-1-simple.cpp new file mode 100644 index 00000000..cae00c07 --- /dev/null +++ b/public/usage-examples/graphics/pop_clip/pop-clip-1-simple.cpp @@ -0,0 +1,33 @@ +#include "splashkit.h" + +int main() +{ + // Open a window with the title "Pop Clip" and dimensions 800x600 + open_window("Pop Clip", 800, 600); + + // Define the clipping area starting at (100, 100) with width 600 and height 400 + rectangle rect = {100, 100, 600, 400}; + + // Push a clipping area to restrict drawing to within the defined rectangle + push_clip(rect); + + // Draw a blue rectangle inside the clipping area (this will be affected by clipping) + fill_rectangle(COLOR_BLUE, 50, 50, 700, 500); + + // Restore the full window area after clipping + pop_clip(); + + // Draw a red rectangle outside the clipping area (this won't be affected by clipping) + fill_rectangle(COLOR_RED, 100, 100, 200, 200); + + // Refresh the screen to display the changes + refresh_screen(); + + // Wait for 5 seconds before closing the window + delay(5000); + + // Close all open windows to end the program + close_all_windows(); + + return 0; +} diff --git a/public/usage-examples/graphics/pop_clip/pop-clip-1-simple.png b/public/usage-examples/graphics/pop_clip/pop-clip-1-simple.png new file mode 100644 index 00000000..d589ec59 Binary files /dev/null and b/public/usage-examples/graphics/pop_clip/pop-clip-1-simple.png differ diff --git a/public/usage-examples/graphics/pop_clip/pop-clip-1-simple.py b/public/usage-examples/graphics/pop_clip/pop-clip-1-simple.py new file mode 100644 index 00000000..ac14ae1a --- /dev/null +++ b/public/usage-examples/graphics/pop_clip/pop-clip-1-simple.py @@ -0,0 +1,28 @@ +from splashkit import * + +# Open a window with the title "Pop Clip" and dimensions 800x600 +window = open_window("Pop Clip", 800, 600) + +# Define the clipping area as a rectangle starting at (100, 100) with width 600 and height 400 +r = rectangle_from(100, 100, 600, 400) + +# Push a clipping area for the window +push_clip_for_window(window, r) + +# Draw a blue rectangle inside the clipping area (this will be clipped by the clipping area) +fill_rectangle(color_blue(), 50, 50, 700, 500) + +# Restore the full window area after the clipping +pop_clip_for_window(window) + +# Draw a red rectangle outside the clipping area (this will not be clipped) +fill_rectangle(color_red(), 100, 100, 200, 200) + +# Refresh the screen to display the changes +refresh_screen() + +# Wait for 5 seconds to observe the drawing +delay(5000) + +# Close all open windows to end the program +close_all_windows() diff --git a/public/usage-examples/graphics/pop_clip/pop-clip-1-simple.txt b/public/usage-examples/graphics/pop_clip/pop-clip-1-simple.txt new file mode 100644 index 00000000..8c644600 --- /dev/null +++ b/public/usage-examples/graphics/pop_clip/pop-clip-1-simple.txt @@ -0,0 +1,3 @@ +#### POP CLIP + +The following code shows an examples of using [Pop Clip](/api/graphics#pop-clip) to push a clipping area and then pop it to restore the full window drawing area, with indicators of the change. diff --git a/public/usage-examples/graphics/push_clip/push-clip-1-simple-oop.cs b/public/usage-examples/graphics/push_clip/push-clip-1-simple-oop.cs new file mode 100644 index 00000000..3527d1dc --- /dev/null +++ b/public/usage-examples/graphics/push_clip/push-clip-1-simple-oop.cs @@ -0,0 +1,34 @@ +using SplashKitSDK; + +public class Program +{ + public static void Main() + { + // Open a window with the title "Push Clip" and dimensions 800x600 + Window window = SplashKit.OpenWindow("Push Clip", 800, 600); + + // Define a rectangular clipping area starting at (100, 100) with width 200 and height 200 + Rectangle rectangle = SplashKit.RectangleFrom(100, 100, 200, 200); + + // Push a clipping area on the window + SplashKit.PushClip(window, rectangle); + + // Draw a blue rectangle inside the clipping area (this will be clipped by the clipping area) + SplashKit.FillRectangle(Color.Blue, 50, 50, 300, 300); // This will be clipped + + // Pop the clipping area to restore full screen drawing capability + SplashKit.PopClip(); + + // Draw a red rectangle outside the clipping area (this won't be clipped) + SplashKit.FillRectangle(Color.Red, 300, 300, 200, 200); + + // Refresh the screen to display the drawing + SplashKit.RefreshScreen(); + + // Wait for 5 seconds to observe the changes + SplashKit.Delay(5000); + + // Close all open windows to end the program + SplashKit.CloseAllWindows(); + } +} diff --git a/public/usage-examples/graphics/push_clip/push-clip-1-simple-top-level.cs b/public/usage-examples/graphics/push_clip/push-clip-1-simple-top-level.cs new file mode 100644 index 00000000..7b2000c8 --- /dev/null +++ b/public/usage-examples/graphics/push_clip/push-clip-1-simple-top-level.cs @@ -0,0 +1,31 @@ +using static SplashKitSDK.SplashKit; +using SplashKitSDK; + + // Open a window with the title "Push Clip" and dimensions 800x600 + Window window = OpenWindow("Push Clip", 800, 600); + + // Define a rectangular clipping area starting at (100, 100) with width 200 and height 200 + Rectangle rectangle = RectangleFrom(100, 100, 200, 200); + + // Push a clipping area on the window + PushClip(window, rectangle); + + // Draw a blue rectangle inside the clipping area (this will be clipped by the clipping area) + FillRectangle(Color.Blue, 50, 50, 300, 300); // This will be clipped + + // Pop the clipping area to restore full screen drawing capability + PopClip(); + + // Draw a red rectangle outside the clipping area (this won't be clipped) + FillRectangle(Color.Red, 300, 300, 200, 200); + + // Refresh the screen to display the drawing + RefreshScreen(); + + // Wait for 5 seconds to observe the changes + Delay(5000); + + // Close all open windows to end the program + CloseAllWindows(); + + diff --git a/public/usage-examples/graphics/push_clip/push-clip-1-simple.cpp b/public/usage-examples/graphics/push_clip/push-clip-1-simple.cpp new file mode 100644 index 00000000..ad336fba --- /dev/null +++ b/public/usage-examples/graphics/push_clip/push-clip-1-simple.cpp @@ -0,0 +1,33 @@ +#include "splashkit.h" + +int main() +{ + // Open a window with the specified title and dimensions + open_window("Push Clip", 800, 600); + + // Define a rectangular clipping area starting at (100, 100) with width 200 and height 200 + rectangle rect = {100, 100, 200, 200}; + + // Push a clipping area onto the window + push_clip(rect); + + // Draw a blue rectangle inside the clipping area (this will be clipped) + fill_rectangle(COLOR_BLUE, 50, 50, 300, 300); + + // Pop the clipping area to restore full screen drawing + pop_clip(); + + // Draw a red rectangle outside the clipping area (this will not be clipped) + fill_rectangle(COLOR_RED, 300, 300, 200, 200); + + // Refresh the screen to display the drawing + refresh_screen(); + + // Wait for 5 seconds to observe the changes + delay(5000); + + // Close all open windows + close_all_windows(); + + return 0; +} diff --git a/public/usage-examples/graphics/push_clip/push-clip-1-simple.png b/public/usage-examples/graphics/push_clip/push-clip-1-simple.png new file mode 100644 index 00000000..657e5b85 Binary files /dev/null and b/public/usage-examples/graphics/push_clip/push-clip-1-simple.png differ diff --git a/public/usage-examples/graphics/push_clip/push-clip-1-simple.py b/public/usage-examples/graphics/push_clip/push-clip-1-simple.py new file mode 100644 index 00000000..b7b0d7fc --- /dev/null +++ b/public/usage-examples/graphics/push_clip/push-clip-1-simple.py @@ -0,0 +1,27 @@ +from splashkit import * + +window = open_window("Push Clip", 800, 600) + +# Define the clipping area as a rectangle +r = rectangle_from(100, 100, 200, 200) + +# Push the clipping area onto the window stack +push_clip(r) + +# Draw a blue rectangle within the clipping area (will be clipped) +fill_rectangle(color_blue(), 50, 50, 300, 300) + +# Pop the clipping area from the window stack to restore full drawing capability +pop_clip() + +# Draw a red rectangle outside the clipping area (will not be clipped) +fill_rectangle(color_red(), 300, 300, 200, 200) + +# Refresh the screen to display the drawing +refresh_screen() + +# Wait for 5 seconds to observe the result +delay(5000) + +# Close the window +close_all_windows() diff --git a/public/usage-examples/graphics/push_clip/push-clip-1-simple.txt b/public/usage-examples/graphics/push_clip/push-clip-1-simple.txt new file mode 100644 index 00000000..b165004c --- /dev/null +++ b/public/usage-examples/graphics/push_clip/push-clip-1-simple.txt @@ -0,0 +1,3 @@ +#### PUSH CLIP + +The following code shows an examples of using [Push Clip](/api/graphics#push-clip) to push push a small clipping area and draw a rectangle within it, then draw outside to show contrast. \ No newline at end of file diff --git a/public/usage-examples/graphics/reset_clip/reset-clip-1-simple-oop.cs b/public/usage-examples/graphics/reset_clip/reset-clip-1-simple-oop.cs new file mode 100644 index 00000000..094be7ac --- /dev/null +++ b/public/usage-examples/graphics/reset_clip/reset-clip-1-simple-oop.cs @@ -0,0 +1,32 @@ +using SplashKitSDK; + +public class Program +{ + public static void Main() + { + // Open a window with the title "Reset Clip" and dimensions 800x600 + Window window= SplashKit.OpenWindow("Reset Clip", 800, 600); + Rectangle rectangle = SplashKit.RectangleFrom(100, 100, 600, 400); + // Set a clipping area + SplashKit.SetClip(window, rectangle); + + // Draw inside the clipping area (will be clipped) + SplashKit.FillRectangle(Color.Blue, 50, 50, 700, 500); // This will be clipped + SplashKit.RefreshScreen(); + SplashKit.Delay(1000); + + // Draw outside the clipping area (still within the clipped area, so it will be clipped) + SplashKit.FillRectangle(Color.Red, 100, 100, 200, 200); + SplashKit.RefreshScreen(); + SplashKit.Delay(1000); + + // Reset the clipping area + SplashKit.ResetClip(); + SplashKit.ClearScreen(Color.Green); // Clear the screen with a new background color + SplashKit.RefreshScreen(); // Refresh the screen to apply changes + SplashKit.Delay(5000); // Wait for 5 seconds to observe the result + + // Close the window + SplashKit.CloseAllWindows(); + } +} diff --git a/public/usage-examples/graphics/reset_clip/reset-clip-1-simple-top-level.cs b/public/usage-examples/graphics/reset_clip/reset-clip-1-simple-top-level.cs new file mode 100644 index 00000000..412c2867 --- /dev/null +++ b/public/usage-examples/graphics/reset_clip/reset-clip-1-simple-top-level.cs @@ -0,0 +1,28 @@ +using static SplashKitSDK.SplashKit; +using SplashKitSDK; + // Open a window with the title "Reset Clip" and dimensions 800x600 + Window window= OpenWindow("Reset Clip", 800, 600); + Rectangle rectangle = RectangleFrom(100, 100, 600, 400); + // Set a clipping area + SetClip(window, rectangle); + + // Draw inside the clipping area (will be clipped) + FillRectangle(Color.Blue, 50, 50, 700, 500); // This will be clipped + RefreshScreen(); + Delay(1000); + + // Draw outside the clipping area (still within the clipped area, so it will be clipped) + FillRectangle(Color.Red, 100, 100, 200, 200); + RefreshScreen(); + Delay(1000); + + // Reset the clipping area + ResetClip(); + ClearScreen(Color.Green); // Clear the screen with a new background color + RefreshScreen(); // Refresh the screen to apply changes + Delay(5000); // Wait for 5 seconds to observe the result + + // Close the window + CloseAllWindows(); + + diff --git a/public/usage-examples/graphics/reset_clip/reset-clip-1-simple.cpp b/public/usage-examples/graphics/reset_clip/reset-clip-1-simple.cpp new file mode 100644 index 00000000..84e3e440 --- /dev/null +++ b/public/usage-examples/graphics/reset_clip/reset-clip-1-simple.cpp @@ -0,0 +1,38 @@ +#include "splashkit.h" + +int main() +{ + // Open a window + open_window("Reset Clip", 800, 600); + + // Define the clipping area + rectangle rect = {100, 100, 600, 400}; + + // Push a clipping area + set_clip(rect); + + // Draw inside the clipping area (it will be clipped) + fill_rectangle(COLOR_BLUE, 50, 50, 700, 500); + refresh_screen(); // Refresh screen to apply the drawing + delay(1000); + + + + // Draw outside the clipping area (this won't be clipped) + fill_rectangle(COLOR_RED, 100, 100, 200, 200); + refresh_screen(); // Refresh screen to show the changes + delay(1000); + + // Restore the full window area + reset_clip(); // This command clears the clipping area + + // Clear screen and show changes + clear_screen(color_green()); // Change background color + refresh_screen(); // Refresh the screen to apply the change + delay(5000); // Wait for 5 seconds + + // Close all windows + close_all_windows(); + + return 0; +} diff --git a/public/usage-examples/graphics/reset_clip/reset-clip-1-simple.png b/public/usage-examples/graphics/reset_clip/reset-clip-1-simple.png new file mode 100644 index 00000000..2db9de3e Binary files /dev/null and b/public/usage-examples/graphics/reset_clip/reset-clip-1-simple.png differ diff --git a/public/usage-examples/graphics/reset_clip/reset-clip-1-simple.py b/public/usage-examples/graphics/reset_clip/reset-clip-1-simple.py new file mode 100644 index 00000000..58a3e753 --- /dev/null +++ b/public/usage-examples/graphics/reset_clip/reset-clip-1-simple.py @@ -0,0 +1,37 @@ +from splashkit import * + + +window = open_window("Reset Clip", 800, 600) + +# Define the clipping area +r = rectangle_from(100, 100, 600, 400) + +# Set the clipping area +set_clip(r) + + +# Draw a blue rectangle inside the clipping area +fill_rectangle(color_blue(), 50, 50, 700, 500) +refresh_screen() # Refresh screen to apply the drawing +delay(1000) + +# Draw a red rectangle outside the clipping area (it will not be clipped) +set_clip(r) + +# Draw a red rectangle outside the clipping area +fill_rectangle(color_red(), 100, 100, 200, 200) +refresh_screen() #Refresh screen to show the changes +delay(1000) + +# Remove the clipping area to allow full window drawing +reset_clip() + +# Clear screen and set a new background color (green) +clear_screen(color_green()) + +# Refresh screen to apply the changes +refresh_screen() +delay(5000) + +# Close all windows +close_all_windows() diff --git a/public/usage-examples/graphics/reset_clip/reset-clip-1-simple.txt b/public/usage-examples/graphics/reset_clip/reset-clip-1-simple.txt new file mode 100644 index 00000000..46a28413 --- /dev/null +++ b/public/usage-examples/graphics/reset_clip/reset-clip-1-simple.txt @@ -0,0 +1,3 @@ +#### RESET CLIP + +The following code shows an examples of using [Reset Clip](/api/graphics#reset-clip) to set a clip around a specific rectangle area and draw only within this area to emphasize a region. \ No newline at end of file diff --git a/public/usage-examples/graphics/set_clip/set-clip-1-simple-oop.cs b/public/usage-examples/graphics/set_clip/set-clip-1-simple-oop.cs new file mode 100644 index 00000000..5048acd7 --- /dev/null +++ b/public/usage-examples/graphics/set_clip/set-clip-1-simple-oop.cs @@ -0,0 +1,26 @@ +using SplashKitSDK; + +public class Program +{ + public static void Main() + { + // Open a window with the title "Set Clip" and dimensions 800x600 + Window window = SplashKit.OpenWindow("Set Clip", 800, 600); + + // Define a rectangle that will be used as the clipping area + Rectangle rectangle = SplashKit.RectangleFrom(100, 100, 600, 400); + + // Push a clipping area onto the window + SplashKit.SetClip(window, rectangle); + + // Draw a blue rectangle that will be clipped by the clipping area + SplashKit.FillRectangle(Color.Blue, 50, 50, 700, 500); // This will be clipped + + // Refresh the screen to display the drawing + SplashKit.RefreshScreen(); + SplashKit.Delay(5000); // Wait for 5 seconds to view the result + + // Close the window + SplashKit.CloseAllWindows(); + } +} diff --git a/public/usage-examples/graphics/set_clip/set-clip-1-simple-top-level.cs b/public/usage-examples/graphics/set_clip/set-clip-1-simple-top-level.cs new file mode 100644 index 00000000..12c6a47e --- /dev/null +++ b/public/usage-examples/graphics/set_clip/set-clip-1-simple-top-level.cs @@ -0,0 +1,22 @@ +using static SplashKitSDK.SplashKit; +using SplashKitSDK; + + // Open a window with the title "Set Clip" and dimensions 800x600 + Window window = OpenWindow("Set Clip", 800, 600); + + // Define a rectangle that will be used as the clipping area + Rectangle rectangle = RectangleFrom(100, 100, 600, 400); + + // Push a clipping area onto the window + SetClip(window, rectangle); + + // Draw a blue rectangle that will be clipped by the clipping area + FillRectangle(Color.Blue, 50, 50, 700, 500); // This will be clipped + + // Refresh the screen to display the drawing + RefreshScreen(); + Delay(5000); // Wait for 5 seconds to view the result + + // Close the window + CloseAllWindows(); + diff --git a/public/usage-examples/graphics/set_clip/set-clip-1-simple.cpp b/public/usage-examples/graphics/set_clip/set-clip-1-simple.cpp new file mode 100644 index 00000000..a92efac3 --- /dev/null +++ b/public/usage-examples/graphics/set_clip/set-clip-1-simple.cpp @@ -0,0 +1,27 @@ +#include "splashkit.h" + +int main() +{ + // Open a window with the title "Set Clip" and dimensions of 800x600 pixels + open_window("Set Clip", 800, 600); + + // Define a clipping area with a rectangle (x, y, width, height) + rectangle rect = {100, 100, 600, 400}; + + // Set the clipping area to restrict drawing to the specified rectangle + set_clip(rect); + + // Draw a large rectangle; since it exceeds the clipping area, it will be clipped + fill_rectangle(COLOR_BLUE, 50, 50, 700, 500); + + // Refresh the screen to display the drawing + refresh_screen(); + + // Wait for 5 seconds to observe the effect of the clipping + delay(5000); + + // Close the window + close_all_windows(); + + return 0; +} diff --git a/public/usage-examples/graphics/set_clip/set-clip-1-simple.png b/public/usage-examples/graphics/set_clip/set-clip-1-simple.png new file mode 100644 index 00000000..96a385c5 Binary files /dev/null and b/public/usage-examples/graphics/set_clip/set-clip-1-simple.png differ diff --git a/public/usage-examples/graphics/set_clip/set-clip-1-simple.py b/public/usage-examples/graphics/set_clip/set-clip-1-simple.py new file mode 100644 index 00000000..e2029312 --- /dev/null +++ b/public/usage-examples/graphics/set_clip/set-clip-1-simple.py @@ -0,0 +1,22 @@ +from splashkit import * + +# Open a window with the title "Set Clip" and dimensions of 800x600 pixels +window = open_window("Set Clip", 800, 600) + +# Define the clipping area with a rectangle (x, y, width, height) +r = rectangle_from(100, 100, 600, 400) + +# Set the clipping area to restrict drawing within the specified rectangle +set_clip(r) + +# Draw a large blue rectangle; it will be clipped to the set area +fill_rectangle(color_blue(), 50, 50, 700, 500) + +# Refresh the screen to display the drawing +refresh_screen() + +# Delay for 5 seconds to observe the effect of the clipping +delay(5000) + +# Close all windows +close_all_windows() diff --git a/public/usage-examples/graphics/set_clip/set-clip-1-simple.txt b/public/usage-examples/graphics/set_clip/set-clip-1-simple.txt new file mode 100644 index 00000000..e9139d76 --- /dev/null +++ b/public/usage-examples/graphics/set_clip/set-clip-1-simple.txt @@ -0,0 +1,3 @@ +#### SET CLIP + +The following code shows an examples of using [Set Clip](/api/graphics#set-clip) to set multiple clip areas, then reset and fill the entire window with a single color to show restoration. \ No newline at end of file