From 66e341a7b2d0c4e9e16c7b9ca014bb34c35cc223 Mon Sep 17 00:00:00 2001 From: dhruvjanghu Date: Mon, 6 Oct 2025 02:19:44 +1100 Subject: [PATCH 1/2] Added split_text usage example in all languages with consistent visuals and structure --- .../utilities/split_text-1-example-oop.cs | 82 ++++++++++++++++++ .../split_text-1-example-top-level.cs | 53 +++++++++++ .../utilities/split_text-1-example.cpp | 56 ++++++++++++ .../utilities/split_text-1-example.png | Bin 0 -> 6855 bytes .../utilities/split_text-1-example.py | 45 ++++++++++ .../utilities/split_text-1-example.txt | 1 + 6 files changed, 237 insertions(+) create mode 100644 public/usage-examples/utilities/split_text-1-example-oop.cs create mode 100644 public/usage-examples/utilities/split_text-1-example-top-level.cs create mode 100644 public/usage-examples/utilities/split_text-1-example.cpp create mode 100644 public/usage-examples/utilities/split_text-1-example.png create mode 100644 public/usage-examples/utilities/split_text-1-example.py create mode 100644 public/usage-examples/utilities/split_text-1-example.txt diff --git a/public/usage-examples/utilities/split_text-1-example-oop.cs b/public/usage-examples/utilities/split_text-1-example-oop.cs new file mode 100644 index 000000000..30c1af678 --- /dev/null +++ b/public/usage-examples/utilities/split_text-1-example-oop.cs @@ -0,0 +1,82 @@ +using System; +using SplashKitSDK; + +namespace SplitTextExample +{ + public class SplitText + { + private Window _window; + private string _text; + private string[] _parts; + private Color _topColor; + private Color _bottomColor; + + public SplitText() + { + // creating window + _window = new Window("Split Text Example", 800, 400); + + // I am defining the text to split + _text = "apple,banana,carrot"; + + // I am splitting the string into parts using SplashKit's split() function + _parts = SplashKit.Split(_text, ','); + + // colors for background gradient + _topColor = SplashKit.RGBColor(245, 251, 255); + _bottomColor = SplashKit.RGBColor(200, 230, 255); + } + + private Color BlendColors(Color c1, Color c2, double t) + { + // linear interpolation for RGB channels + int r = (int)((1 - t) * SplashKit.RedOf(c1) + t * SplashKit.RedOf(c2)); + int g = (int)((1 - t) * SplashKit.GreenOf(c1) + t * SplashKit.GreenOf(c2)); + int b = (int)((1 - t) * SplashKit.BlueOf(c1) + t * SplashKit.BlueOf(c2)); + return SplashKit.RGBColor(r, g, b); + } + + public void Run() + { + while (!SplashKit.QuitRequested()) + { + SplashKit.ProcessEvents(); + + // draw gradient background + for (int y = 0; y < _window.Height; y++) + { + double t = (double)y / _window.Height; + Color blended = BlendColors(_topColor, _bottomColor, t); + SplashKit.DrawLine(blended, 0, y, _window.Width, y); + } + + // display text + SplashKit.DrawText("Original string:", SplashKit.ColorDarkBlue(), "arial", 20, 60, 50); + SplashKit.DrawText(_text, SplashKit.ColorBlack(), "arial", 20, 280, 50); + + int yPos = 130; + foreach (string s in _parts) + { + SplashKit.DrawText("Token: " + s, SplashKit.ColorBlack(), "arial", 18, 60, yPos); + yPos += 40; + } + + SplashKit.DrawText("Press ESC to exit", SplashKit.ColorGray(), "arial", 14, 620, 360); + _window.Refresh(60); + + if (SplashKit.KeyTyped(KeyCode.EscapeKey)) + { + break; + } + } + + _window.Close(); + } + + public static void Main() + { + SplitText demo = new SplitText(); + demo.Run(); + } + } +} diff --git a/public/usage-examples/utilities/split_text-1-example-top-level.cs b/public/usage-examples/utilities/split_text-1-example-top-level.cs new file mode 100644 index 000000000..bf8c81b0b --- /dev/null +++ b/public/usage-examples/utilities/split_text-1-example-top-level.cs @@ -0,0 +1,53 @@ +using SplashKitSDK; +using static SplashKitSDK.SplashKit; + +Color BlendColors(Color c1, Color c2, double t) +{ + // linear interpolation for RGB channels + int r = (int)((1 - t) * RedOf(c1) + t * RedOf(c2)); + int g = (int)((1 - t) * GreenOf(c1) + t * GreenOf(c2)); + int b = (int)((1 - t) * BlueOf(c1) + t * BlueOf(c2)); + return RGBColor(r, g, b); +} + +OpenWindow("Split Text Example", 800, 400); + +// I am defining the text to split +string text = "apple,banana,carrot"; + +// I am splitting the string into parts using SplashKit's split() function +string[] parts = Split(text, ','); + +// I am drawing a gradient background manually +Color top = RGBColor(245, 251, 255); +Color bottom = RGBColor(200, 230, 255); + +for (int y = 0; y < 400; y++) +{ + double t = (double)y / 400.0; + Color blended = BlendColors(top, bottom, t); + DrawLine(blended, 0, y, 800, y); +} + +DrawText("Original string:", ColorDarkBlue(), "arial", 20, 60, 50); +DrawText(text, ColorBlack(), "arial", 20, 280, 50); + +// I am printing each token from the split result +int yPos = 130; +foreach (string s in parts) +{ + DrawText("Token: " + s, ColorBlack(), "arial", 18, 60, yPos); + yPos += 40; +} + +DrawText("Press ESC to exit", ColorGray(), "arial", 14, 620, 360); +RefreshScreen(); + +// wait for quit event +while (!QuitRequested()) +{ + ProcessEvents(); + if (KeyTyped(KeyCode.EscapeKey)) break; +} + +CloseAllWindows(); \ No newline at end of file diff --git a/public/usage-examples/utilities/split_text-1-example.cpp b/public/usage-examples/utilities/split_text-1-example.cpp new file mode 100644 index 000000000..4ecbcb380 --- /dev/null +++ b/public/usage-examples/utilities/split_text-1-example.cpp @@ -0,0 +1,56 @@ +#include "splashkit.h" +#include + +color blend_colors(color c1, color c2, double t) +{ + // linear interpolation for RGB channels + int r = (int)((1 - t) * red_of(c1) + t * red_of(c2)); + int g = (int)((1 - t) * green_of(c1) + t * green_of(c2)); + int b = (int)((1 - t) * blue_of(c1) + t * blue_of(c2)); + return rgb_color(r, g, b); +} + +int main() +{ + open_window("Split Text Example", 800, 400); + + // I am defining the text to split + string text = "apple,banana,carrot"; + + // I am splitting the string into parts using SplashKit's split() function + vector parts = split(text, ','); + + // I am drawing a gradient background manually + color top = rgb_color(245, 251, 255); + color bottom = rgb_color(200, 230, 255); + + for (int y = 0; y < 400; y++) + { + double t = static_cast(y) / 400.0; + color blended = blend_colors(top, bottom, t); + draw_line(blended, 0, y, 800, y); + } + + draw_text("Original string:", color_dark_blue(), "arial", 20, 60, 50); + draw_text(text, color_black(), "arial", 20, 280, 50); + + int y = 130; + for (string s : parts) + { + draw_text("Token: " + s, color_black(), "arial", 18, 60, y); + y += 40; + } + + draw_text("Press ESC to exit", color_gray(), "arial", 14, 620, 360); + + refresh_screen(); + + while (!quit_requested()) + { + process_events(); + if (key_typed(ESCAPE_KEY)) break; + } + + close_all_windows(); + return 0; +} diff --git a/public/usage-examples/utilities/split_text-1-example.png b/public/usage-examples/utilities/split_text-1-example.png new file mode 100644 index 0000000000000000000000000000000000000000..3dbd39ff10ed601614a7ec71b9ec84b7f82bb45b GIT binary patch literal 6855 zcmb7Id0bOh+P)4gbc#YPwF(GKwbikp2#A0z(TZqCfhvSWmRJ!%!y-c111O&*$dX!$ z2pG_zf)F7FWJ`d6vYD{T5+H;i5s)lEzz|4CGWQ0*-^Y~NZ{`m|F84j>yyrd7^SsX? z`3HxSTRzqL6aauN-=DHQ2LMW10I=!NC(7Vo(8m)P;IB=g=T3eHly&W#0Uti{J7#|j z0Ek%C)gM0wpZ|L8lzS)usJ(!GHnjymz61bTp5NOZbB^@pGnv>g>A1b~2vg+CFW&Nq6DscQY4{0V6dy6sD_^}9F!HSUi87Gj z`}&1CEOlmPraUsQsi~<(E|btEEIIkInSAz)TpSiKd+@Fv4E3#d48L+YI9?Rt3rCbB zCnpaR6N6jg#T|%d)tGc!(}OXA9!AQmDOtw-zXJ^~& zgEtgy)=E;>ORtX+b@8$3>0S8XiWt$X8zl~HCG2++JXbYr?&4Ci6^jOuQEvQBGT8#~k0J9#c%F7e$40M*086@Kg{ z6+K?f{R@{b?>XRE^O^SHfWPBs9}Ap{CNi@S>A`VakNi)ynH;g{XIqU-EH&VjyVAYx zr}}7Q2*&y!Mam0O1WlQ$A(Pa-TPsW^Lx>j#ifI2}v)Li@<4rqsbkcfzdn2c^{U#c3 zDEU^Dh0l&!Y&Txw4Qs?K@%H65Pj%)_cM;>H;vu5X$<*}p1Ll`@+QgcBN4~xVmRM|6 zP*4!@H3-b7%bPcEwuQq>8Mn9TQ>Rj%Pub^A(>wJdXkUmMvmVoXJIfyH6cEAVh-NO!a~!d zDj?gn8azt#cv&oOtlqMNr&F=mHp4hU z%FwebPCKn4ug%tVa+wu=j&-837=f5eXp>1LKG&}sJLKC~i>xaPr^UsTwwEtoLV3i#Rz+Yi7$p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PATCH 2/2] Added gcd usage example demonstrating greatest_common_divisor function in all languages --- .../utilities/gcd_1_example-oop.cs | 43 ++++++++++++++++++ .../utilities/gcd_1_example-top-level.cs | 35 ++++++++++++++ .../utilities/gcd_1_example.cpp | 33 ++++++++++++++ .../utilities/gcd_1_example.png | Bin 0 -> 7016 bytes .../usage-examples/utilities/gcd_1_example.py | 34 ++++++++++++++ .../utilities/gcd_1_example.txt | 1 + 6 files changed, 146 insertions(+) create mode 100644 public/usage-examples/utilities/gcd_1_example-oop.cs create mode 100644 public/usage-examples/utilities/gcd_1_example-top-level.cs create mode 100644 public/usage-examples/utilities/gcd_1_example.cpp create mode 100644 public/usage-examples/utilities/gcd_1_example.png create mode 100644 public/usage-examples/utilities/gcd_1_example.py create mode 100644 public/usage-examples/utilities/gcd_1_example.txt diff --git a/public/usage-examples/utilities/gcd_1_example-oop.cs b/public/usage-examples/utilities/gcd_1_example-oop.cs new file mode 100644 index 000000000..789cd9956 --- /dev/null +++ b/public/usage-examples/utilities/gcd_1_example-oop.cs @@ -0,0 +1,43 @@ +using SplashKitSDK; + +namespace GCDExample +{ + public class Program + { + public static void Main() + { + // open window + SplashKit.OpenWindow("Greatest Common Divisor Example", 640, 360); + + // define two numbers + int numA = 48; + int numB = 18; + + // calculate gcd using splashkit function + int result = SplashKit.GCD(numA, numB); + + while (!SplashKit.QuitRequested()) + { + SplashKit.ProcessEvents(); + SplashKit.ClearScreen(Color.White); + + // heading + SplashKit.DrawText("Calculating the Greatest Common Divisor (GCD)", Color.Blue, 60, 40); + + // numbers + SplashKit.DrawText($"Number A: {numA}", Color.Black, 80, 100); + SplashKit.DrawText($"Number B: {numB}", Color.Black, 80, 140); + + // result + SplashKit.DrawText($"GCD Result: {result}", Color.Red, 80, 200); + + // exit instructions + SplashKit.DrawText("Press ESC to exit", Color.Gray, 420, 330); + + SplashKit.RefreshScreen(); + } + + SplashKit.CloseAllWindows(); + } + } +} diff --git a/public/usage-examples/utilities/gcd_1_example-top-level.cs b/public/usage-examples/utilities/gcd_1_example-top-level.cs new file mode 100644 index 000000000..6a94b4f35 --- /dev/null +++ b/public/usage-examples/utilities/gcd_1_example-top-level.cs @@ -0,0 +1,35 @@ +using SplashKitSDK; +using static SplashKitSDK.SplashKit; + +// open window +OpenWindow("Greatest Common Divisor Example", 640, 360); + +// define two numbers +int numA = 48; +int numB = 18; + +// calculate gcd using splashkit function +int result = GCD(numA, numB); + +while (!QuitRequested()) +{ + ProcessEvents(); + ClearScreen(ColorWhite()); + + // heading + DrawText("Calculating the Greatest Common Divisor (GCD)", ColorBlue(), 60, 40); + + // numbers + DrawText($"Number A: {numA}", ColorBlack(), 80, 100); + DrawText($"Number B: {numB}", ColorBlack(), 80, 140); + + // result + DrawText($"GCD Result: {result}", ColorRed(), 80, 200); + + // exit instructions + DrawText("Press ESC to exit", ColorGray(), 420, 330); + + RefreshScreen(); +} + +CloseAllWindows(); diff --git a/public/usage-examples/utilities/gcd_1_example.cpp b/public/usage-examples/utilities/gcd_1_example.cpp new file mode 100644 index 000000000..59e97e5d7 --- /dev/null +++ b/public/usage-examples/utilities/gcd_1_example.cpp @@ -0,0 +1,33 @@ +#include "splashkit.h" + +int main() +{ + open_window("Greatest Common Divisor Example", 600, 400); + + // I am setting up two example numbers + int a = 48; + int b = 18; + + // I am calculating the GCD using the built-in SplashKit function + int gcd_value = greatest_common_divisor(a, b); + + // I am clearing the screen and showing the results + clear_screen(COLOR_WHITE); + draw_text("Calculating the Greatest Common Divisor (GCD)", COLOR_NAVY, 60, 60); + draw_text("Number A: " + std::to_string(a), COLOR_BLACK, 60, 120); + draw_text("Number B: " + std::to_string(b), COLOR_BLACK, 60, 150); + draw_text("GCD Result: " + std::to_string(gcd_value), COLOR_RED, 60, 200); + + draw_text("Press ESC to exit", COLOR_GRAY, 400, 360); + refresh_screen(); + + // Wait for ESC key to exit + while (!quit_requested()) + { + process_events(); + if (key_typed(ESCAPE_KEY)) break; + } + + close_all_windows(); + return 0; +} \ No newline at end of file diff --git a/public/usage-examples/utilities/gcd_1_example.png b/public/usage-examples/utilities/gcd_1_example.png new file mode 100644 index 0000000000000000000000000000000000000000..c431e0135e2a64ab5d56d5b5926824a0cbb371dd GIT binary patch literal 7016 zcmeHMYgm%m_J6A>XR>tcW_g{dCM#2?%v4Zm($UJarc}%eG?H0faJ(Sq1!|hoQlzQW z^2V8*)I>2$K~SJcfhkkR3^5ff2~7~l6cOceUgpF9`JWHxlv)8lVz1i!x ze!sQW%k>k%0c%%Vtp)&K?UBQNCjnr27yvA*`Fs^~h#%RQ*{Vb?=bV*H0|Z))3hj&v9WsUtiZ{9obZ+RBODs zvlI7@oKGBMG3nWAMVmptBzAylj(E-e<=Zb1Shi=#!JAUBGvl1hB{@wjr;Qbn4BE+* z#kr}r%$b<|Rk+2e30CgX_{f+(V|tYSB+4APGtdApLe|oUl z#wLp40X$tbU`Bo}z**<9GwS$(-LKC3+2Az>&I+}GH}oX#xaV4+VVix<$M5zyJC}3@ z&Z$(KdHG29yK*T>KSdJD3=&yNa$eXyZ@dozr;#k^)hu{$V>q;-Mzla%Feho+H^XpS zt;)+tIl}(JAnbnepO$J~Ro|%X?5w??U)Ov)l?O9)LoF<3-agIiUQK@U=1r!8K3P&| z>zTS;!BmUBLDA~3U%!6$-n|PjJ8SF6eR!y6#`MrF-jyp?QszGN&x_+oxd*Q0<%xd{ zusi)Ys(WrOz2nmhNB8#{C{CMM;gND**XBh%J}@KZZQBY#m|P;9L!+HD6r*ou#4vah zf&kOc5Su}4Q>8U!#(U(vySl(d5u+{P!ilhI+pwk}riEJ6?xJ5ZEC|jgqPez_u%e(y z3izaO@w)Nzqp*%`6R`07x?lLVkxkq&A$`cTVTXf*xW|1gYTdTmw{P$L_S-MFZQB-D z65WX66*WRKvY3~Oh{OOq9`7~NwcbLob>{u^+qR`_ezBl_BZ17s-OKW}B-KPtg#+l7 zX=!PDJv=rO2IH>8zwGG|rvA9mc6mKIv2pmhM!-f~&(F`krYPhN6336*>pY#EdpVk` zrh=05ey&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}C{eL%SqSc@M|6c7smw5j^?cZ$wyv8-I_YMkd h9sdHmOKXGu*MAhAYUu*{!GFhqBi{%6Q4XE?`JbzCv!(z5 literal 0 HcmV?d00001 diff --git a/public/usage-examples/utilities/gcd_1_example.py b/public/usage-examples/utilities/gcd_1_example.py new file mode 100644 index 000000000..65ebd62c2 --- /dev/null +++ b/public/usage-examples/utilities/gcd_1_example.py @@ -0,0 +1,34 @@ +from splashkit import * + +# open a window with the same title and dimensions +open_window("Greatest Common Divisor Example", 640, 360) + +# define two numbers +num_a = 48 +num_b = 18 + +# use splashkit's gcd function +result = gcd(num_a, num_b) + +# main loop +while not quit_requested(): + process_events() + + clear_screen(color_white()) + + # heading text + draw_text("Calculating the Greatest Common Divisor (GCD)", color_blue(), 60, 40) + + # numbers being used + draw_text(f"Number A: {num_a}", color_black(), 80, 100) + draw_text(f"Number B: {num_b}", color_black(), 80, 140) + + # result in red + draw_text(f"GCD Result: {result}", color_red(), 80, 200) + + # exit instructions + draw_text("Press ESC to exit", color_gray(), 420, 330) + + refresh_screen() + +close_all_windows() diff --git a/public/usage-examples/utilities/gcd_1_example.txt b/public/usage-examples/utilities/gcd_1_example.txt new file mode 100644 index 000000000..cfa6151b2 --- /dev/null +++ b/public/usage-examples/utilities/gcd_1_example.txt @@ -0,0 +1 @@ +Greatest Common Divisor Calculator \ No newline at end of file