-
Notifications
You must be signed in to change notification settings - Fork 78
Replace all usage example #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| using SplashKitSDK; | ||
|
|
||
| public class Program | ||
| { | ||
| public static void Main() | ||
| { | ||
| // Store the sentence to update | ||
| string text = "foo is here, foo is there, foo is everywhere."; | ||
|
|
||
| // Replace every "foo" with "bar" | ||
| string result = SplashKit.ReplaceAll(text, "foo", "bar"); | ||
|
|
||
| // Show the updated sentence | ||
| SplashKit.WriteLine(result); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using SplashKitSDK; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For top-level C#, use |
||
|
|
||
| // Store the sentence to update | ||
| string text = "foo is here, foo is there, foo is everywhere."; | ||
|
|
||
| // Replace every "foo" with "bar" | ||
| string result = SplashKit.ReplaceAll(text, "foo", "bar"); | ||
|
|
||
| // Show the updated sentence | ||
| SplashKit.WriteLine(result); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #include "splashkit.h" | ||
| using namespace std; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need |
||
|
|
||
| int main() | ||
| { | ||
| // Store the sentence to update | ||
| string text = "foo is here, foo is there, foo is everywhere."; | ||
|
|
||
| // Replace every "foo" with "bar" | ||
| string result = replace_all(text, "foo", "bar"); | ||
|
|
||
| // Show the updated sentence | ||
| write_line(result); | ||
|
|
||
| return 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| from splashkit import * | ||
|
|
||
| # Store the sentence to update | ||
| text = "foo is here, foo is there, foo is everywhere." | ||
|
|
||
| # Replace every "foo" with "bar" | ||
| result = replace_all(text, "foo", "bar") | ||
|
|
||
| # Show the updated sentence | ||
| write_line(result) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Replace all occurrences of one word in a sentence |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| [ | ||
| "Camera", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This capitalisation change ( |
||
| "Graphics", | ||
| "animations", | ||
| "audio", | ||
| "beyond-splashkit", | ||
| "camera", | ||
| "color", | ||
| "graphics", | ||
| "input", | ||
| "interface", | ||
| "json", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,31 @@ | |
| ] | ||
| } | ||
| ], | ||
| "color": [ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
| { | ||
| "funcKey": "saturation_of", | ||
| "title": "Draws a rectangle in a random colour. The colour's saturation value is displayed on screen", | ||
| "url": "/api/color/#saturation-of", | ||
| "functions": [ | ||
| "open_window", | ||
| "random_rgb_color", | ||
| "round", | ||
| "rectangle_from", | ||
| "clear_screen", | ||
| "color_white", | ||
| "fill_rectangle_record", | ||
| "draw_text_no_font_no_size", | ||
| "color_black", | ||
| "red_of", | ||
| "green_of", | ||
| "blue_of", | ||
| "alpha_of", | ||
| "refresh_screen", | ||
| "delay", | ||
| "close_all_windows" | ||
| ] | ||
| } | ||
| ], | ||
| "geometry": [ | ||
| { | ||
| "funcKey": "center_point", | ||
|
|
@@ -524,6 +549,32 @@ | |
| "close_window" | ||
| ] | ||
| }, | ||
| { | ||
| "funcKey": "rectangle_around", | ||
| "title": "A perpetually moving circle which increases and decreases in size, surrounded by a rectangle shape", | ||
| "url": "/api/geometry/#rectangle-around", | ||
| "functions": [ | ||
| "open_window", | ||
| "create_timer", | ||
| "start_timer", | ||
| "quit_requested", | ||
| "point_at", | ||
| "cosine", | ||
| "sine", | ||
| "circle_at", | ||
| "timer_ticks", | ||
| "reset_timer", | ||
| "process_events", | ||
| "clear_screen_to_white", | ||
| "draw_rectangle_record", | ||
| "color_black", | ||
| "rectangle_around_circle", | ||
| "fill_circle_record", | ||
| "color_red", | ||
| "refresh_screen", | ||
| "close_all_windows" | ||
| ] | ||
| }, | ||
| { | ||
| "funcKey": "same_point", | ||
| "title": "Point 2D Guessing Game", | ||
|
|
@@ -561,6 +612,24 @@ | |
| "close_all_windows" | ||
| ] | ||
| }, | ||
| { | ||
| "funcKey": "bitmap_center", | ||
| "title": "Draw a bitmap with a red dot at its center\r", | ||
| "url": "/api/graphics/#bitmap-center", | ||
| "functions": [ | ||
| "open_window", | ||
| "load_bitmap", | ||
| "clear_screen", | ||
| "color_white", | ||
| "draw_bitmap", | ||
| "fill_circle_record", | ||
| "color_red", | ||
| "circle_at", | ||
| "refresh_screen", | ||
| "delay", | ||
| "close_all_windows" | ||
| ] | ||
| }, | ||
| { | ||
| "funcKey": "clear_screen", | ||
| "title": "Background Color", | ||
|
|
@@ -597,6 +666,26 @@ | |
| "SplashKit" | ||
| ] | ||
| }, | ||
| { | ||
| "funcKey": "draw_circle", | ||
| "title": "Circle Showcase", | ||
| "url": "/api/graphics/#draw-circle", | ||
| "functions": [ | ||
| "open_window", | ||
| "clear_screen", | ||
| "color_white", | ||
| "fill_circle", | ||
| "color_red", | ||
| "color_blue", | ||
| "color_green", | ||
| "color_orange", | ||
| "color_purple", | ||
| "random_rgb_color", | ||
| "refresh_screen", | ||
| "delay", | ||
| "close_all_windows" | ||
| ] | ||
| }, | ||
| { | ||
| "funcKey": "draw_circle_on_bitmap", | ||
| "title": "Creating a Red Planet", | ||
|
|
@@ -1189,6 +1278,25 @@ | |
| "close_all_windows" | ||
| ] | ||
| }, | ||
| { | ||
| "funcKey": "get_font_style", | ||
| "title": "The program automatically cycles through font styles for a given font (also displaying example text), with the numerical value of each style being shown on screen\r", | ||
| "url": "/api/graphics/#get-font-style", | ||
| "functions": [ | ||
| "open_window", | ||
| "font_named", | ||
| "quit_requested", | ||
| "process_events", | ||
| "set_font_style", | ||
| "clear_screen_to_white", | ||
| "draw_text_no_font_no_size", | ||
| "color_black", | ||
| "draw_text", | ||
| "refresh_screen", | ||
| "delay", | ||
| "close_all_windows" | ||
| ] | ||
| }, | ||
| { | ||
| "funcKey": "has_font", | ||
| "title": "Checking for Font using Variable", | ||
|
|
@@ -1730,6 +1838,14 @@ | |
| "write_line" | ||
| ] | ||
| }, | ||
| { | ||
| "funcKey": "replace_all", | ||
| "title": "Replacing all occurrences of a word in a sentence", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The functions list here just has |
||
| "url": "/api/utilities/#replace-all", | ||
| "functions": [ | ||
| "print" | ||
| ] | ||
| }, | ||
| { | ||
| "funcKey": "rnd", | ||
| "title": "Coin Flip", | ||
|
|
@@ -1790,5 +1906,30 @@ | |
| "write_line" | ||
| ] | ||
| } | ||
| ], | ||
| "windows": [ | ||
| { | ||
| "funcKey": "close_window", | ||
| "title": "Starts a countdown to close the window at the push of a button.", | ||
| "url": "/api/windows/#close-window", | ||
| "functions": [ | ||
| "open_window", | ||
| "create_timer", | ||
| "quit_requested", | ||
| "process_events", | ||
| "clear_window", | ||
| "color_white", | ||
| "button_at_position", | ||
| "rectangle_from", | ||
| "start_timer", | ||
| "draw_text_font_as_string", | ||
| "color_black", | ||
| "timer_ticks", | ||
| "reset_timer", | ||
| "draw_interface", | ||
| "refresh_window", | ||
| "close_all_windows" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap this in a namespace per convention, e.g.: