forked from splashkit/splashkit.io-starlight
-
Notifications
You must be signed in to change notification settings - Fork 78
Added usage example for brightness_of #708
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
Open
jasveena15
wants to merge
8
commits into
thoth-tech:main
Choose a base branch
from
jasveena15:doc/usage-example-brightness-of
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
189a621
Added usage example for brightness_of
jasveena15 da7433a
Rename brightness_of-1-example-top.cs to brightness_of-1-example-top-…
jasveena15 62d633e
Update brightness_of-1-example-top-level.cs
jasveena15 14e9434
Update brightness_of-1-example-oop.cs
jasveena15 a9a0cbe
Update brightness_of-1-example-top-level.cs
jasveena15 a2127b7
Update brightness_of-1-example.cpp
jasveena15 b16187b
Update brightness_of-1-example-oop.cs
jasveena15 2abaf43
Update brightness_of-1-example.py
jasveena15 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
public/usage-examples/color/brightness_of-1-example-oop.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| using SplashKitSDK; | ||
|
|
||
| namespace BrightnessOfExample | ||
| { | ||
| public class Program | ||
| { | ||
| public static void Main() | ||
| { | ||
| // Open the window for the usage example | ||
| SplashKit.OpenWindow("Purple Shade Brightness", 800, 400); | ||
|
|
||
| Color[] shades = | ||
| { | ||
| SplashKit.RGBAColor(70, 30, 100, 255), | ||
| SplashKit.RGBAColor(140, 70, 180, 255), | ||
| SplashKit.RGBAColor(210, 170, 240, 255) | ||
| }; | ||
|
|
||
| string[] names = { "Dark Purple", "Medium Purple", "Light Purple" }; | ||
|
|
||
| while (!SplashKit.QuitRequested()) | ||
| { | ||
| SplashKit.ProcessEvents(); | ||
|
|
||
| // Draw the background and instructions | ||
| SplashKit.ClearScreen(Color.White); | ||
| SplashKit.DrawText("Brightness values of purple shades", Color.Black, 210, 40); | ||
|
|
||
| // Draw each shade and its brightness value | ||
| for (int i = 0; i < 3; i++) | ||
| { | ||
| double value = SplashKit.BrightnessOf(shades[i]); | ||
|
|
||
| SplashKit.FillCircle(shades[i], 150 + i * 240, 180, 55); | ||
| SplashKit.DrawText(names[i], Color.Black, 105 + i * 240, 260); | ||
| SplashKit.DrawText("Brightness: " + value.ToString(), Color.Black, 75 + i * 240, 300); | ||
| } | ||
|
|
||
| SplashKit.RefreshScreen(60); | ||
| } | ||
|
|
||
| SplashKit.CloseAllWindows(); | ||
| } | ||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
public/usage-examples/color/brightness_of-1-example-top-level.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| using static SplashKitSDK.SplashKit; | ||
|
|
||
| // Open the window for the usage example | ||
| OpenWindow("Purple Shade Brightness", 800, 400); | ||
|
|
||
| Color[] shades = | ||
| { | ||
| RGBAColor(70, 30, 100, 255), | ||
| RGBAColor(140, 70, 180, 255), | ||
| RGBAColor(210, 170, 240, 255) | ||
| }; | ||
|
|
||
| string[] names = { "Dark Purple", "Medium Purple", "Light Purple" }; | ||
|
|
||
| while (!QuitRequested()) | ||
| { | ||
| ProcessEvents(); | ||
|
|
||
| // Draw the background and instructions | ||
| ClearScreen(Color.White); | ||
| DrawText("Brightness values of purple shades", Color.Black, 210, 40); | ||
|
|
||
| // Draw each shade and its brightness value | ||
| for (int i = 0; i < 3; i++) | ||
| { | ||
| double value = BrightnessOf(shades[i]); | ||
|
|
||
| FillCircle(shades[i], 150 + i * 240, 180, 55); | ||
| DrawText(names[i], Color.Black, 105 + i * 240, 260); | ||
| DrawText("Brightness: " + value.ToString(), Color.Black, 75 + i * 240, 300); | ||
| } | ||
|
|
||
| RefreshScreen(60); | ||
| } | ||
|
|
||
| CloseAllWindows(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #include "splashkit.h" | ||
|
|
||
| int main() | ||
| { | ||
| // Open the window for the usage example | ||
| open_window("Purple Shade Brightness", 800, 400); | ||
|
|
||
| color shades[] = { | ||
| rgba_color(70, 30, 100, 255), | ||
| rgba_color(140, 70, 180, 255), | ||
| rgba_color(210, 170, 240, 255) | ||
| }; | ||
|
|
||
| string names[] = { | ||
| "Dark Purple", | ||
| "Medium Purple", | ||
| "Light Purple" | ||
| }; | ||
|
|
||
| while (!quit_requested()) | ||
| { | ||
| process_events(); | ||
|
|
||
| // Draw the background and instructions | ||
| clear_screen(COLOR_WHITE); | ||
| draw_text("Brightness values of purple shades", COLOR_BLACK, 210, 40); | ||
|
|
||
| // Draw each shade and its brightness value | ||
| for (int i = 0; i < 3; i++) | ||
| { | ||
| double value = brightness_of(shades[i]); | ||
|
|
||
| fill_circle(shades[i], 150 + i * 240, 180, 55); | ||
| draw_text(names[i], COLOR_BLACK, 105 + i * 240, 260); | ||
| draw_text("Brightness: " + std::to_string(value), COLOR_BLACK, 75 + i * 240, 300); | ||
| } | ||
|
|
||
| refresh_screen(60); | ||
| } | ||
|
|
||
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| from splashkit import * | ||
|
|
||
| # Open the window for the usage example | ||
| window = open_window("Purple Shade Brightness", 800, 400) | ||
|
|
||
| shades = [ | ||
| rgba_color(70, 30, 100, 255), | ||
| rgba_color(140, 70, 180, 255), | ||
| rgba_color(210, 170, 240, 255) | ||
| ] | ||
|
|
||
| names = ["Dark Purple", "Medium Purple", "Light Purple"] | ||
|
|
||
| while not window_close_requested(window): | ||
| process_events() | ||
|
|
||
| # Draw the background and instructions | ||
| clear_screen(color_white()) | ||
| draw_text_no_font_no_size("Brightness values of purple shades", color_black(), 210, 40) | ||
|
|
||
| # Draw each shade and its brightness value | ||
| for i in range(3): | ||
| value = brightness_of(shades[i]) | ||
|
|
||
| fill_circle(shades[i], 150 + i * 240, 180, 55) | ||
| draw_text_no_font_no_size(names[i], color_black(), 105 + i * 240, 260) | ||
| draw_text_no_font_no_size("Brightness: " + str(value), color_black(), 75 + i * 240, 300) | ||
|
|
||
| refresh_screen() | ||
|
|
||
| close_window(window) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Purple Shade Brightness |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.