Skip to content

Added usage example for brightness_of#708

Open
jasveena15 wants to merge 8 commits intothoth-tech:mainfrom
jasveena15:doc/usage-example-brightness-of
Open

Added usage example for brightness_of#708
jasveena15 wants to merge 8 commits intothoth-tech:mainfrom
jasveena15:doc/usage-example-brightness-of

Conversation

@jasveena15
Copy link
Copy Markdown

Description

This pull request adds a new usage example for the brightness_of function in SplashKit.

The example demonstrates how to calculate and display brightness values of different purple shades. It visually renders three coloured circles (dark, medium, and light purple) and shows their corresponding brightness values on screen.

This helps users understand how brightness varies with colour intensity and how to use the brightness_of function in practical scenarios.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as
    expected)
  • Documentation (update or new)

How Has This Been Tested?

Tested Python version using:
skm python3 program.py

Tested C++ version using:
g++ program.cpp -l SplashKit -o test_program
./test_program

Tested C# versions using:
dotnet run
Verified that:

  • the window opens correctly
  • purple shades are rendered accurately
  • brightness values are calculated using brightness_of
  • values are displayed clearly under each shape

Testing Checklist

  • Tested in latest Chrome
  • Tested in latest Firefox
  • npm run build
  • npm run preview

Checklist

If involving code

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Folders and Files Added/Modified

  • Added:
    • public/usage-examples/color/brightness_of-1-example-oop.cs
    • public/usage-examples/color/brightness_of-1-example-top.cs
    • public/usage-examples/color/brightness_of-1-example.cpp
    • public/usage-examples/color/brightness_of-1-example.png
    • public/usage-examples/color/brightness_of-1-example.py
    • public/usage-examples/color/brightness_of-1-example.txt

Additional Notes

This example follows the standard usage example structure and naming conventions used across the SplashKit documentation.
It is designed to be simple, visual, and beginner-friendly while clearly demonstrating the functionality of the brightness_of API.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 26, 2026

Deploy Preview for splashkit failed.

Name Link
🔨 Latest commit 2abaf43
🔍 Latest deploy log https://app.netlify.com/projects/splashkit/deploys/69cd0f215a59f800071037b5

Copy link
Copy Markdown

@kottochii kottochii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top level statement file is not shown when browsing on the website.

Copy link
Copy Markdown

@ralphweng-autograb ralphweng-autograb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review has been moved to the correct account (ralphweng2023). Please disregard.

Copy link
Copy Markdown

@222448082Ashen 222448082Ashen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Description

  • Title: Added usage example for brightness_of
  • Author Description: Adds a new usage example for the brightness_of function in SplashKit, demonstrating calculation and display of brightness values for different purple shades.
  • Type of Change: New Feature / Documentation

Peer-Review Checklist

General Code Quality

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code - The example is well-structured and follows the established pattern for usage examples.
  • I have commented my code in hard-to-understand areas - Code is simple and self-explanatory.
  • My changes generate no new warnings

Functionality & Testing

  • Local Execution:
    • Verified the C++ version compiles and runs correctly.
    • Verified the Python version uses appropriate function names (draw_text_no_font_no_size).
    • Verified the C# versions (OOP and Top-level) follow project conventions.
  • Visual Consistency: The example renders purple shades and clearly displays their brightness values.

Specific File Type Review

Usage Examples (Color)

Reviewer Notes

The usage example is a high-quality addition accurately demonstrating the brightness_of API. The use of purple shades provides a clear visual progression that helps beginners understand the concept.

Copy link
Copy Markdown

@kottochii kottochii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peer review

Issues found

[ ] Due to the naming convention, the OOP file is not shown under examples on the website.

Examples tested

All examples have been run and perform as required.

Copy link
Copy Markdown

@ralphweng2023 ralphweng2023 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peer Review

I've reviewed the brightness_of usage example. Nice creative idea using purple shades of varying brightness — it clearly demonstrates the function and the visual output is effective. However, there are a few issues that need to be addressed.

Issues

  1. C# top-level file has wrong filename. The file is named brightness_of-1-example-top.cs but the convention requires brightness_of-1-example-top-level.cs (note: -top-level, not -top). The auto-generation script looks for -top-level.cs specifically (see api-pages-script.cjs line 268), so this file will not be detected during build. Please rename to brightness_of-1-example-top-level.cs.

  2. Top-level C# uses OOP-style calls. The top-level C# file should use using static SplashKitSDK.SplashKit; and call functions directly (e.g., OpenWindow(...), ClearScreen(...), BrightnessOf(...)) instead of prefixing everything with SplashKit.. The current code reads identically to the OOP version.

  3. OOP C# missing namespace. The OOP C# file should wrap the class in a namespace: namespace BrightnessOfExample { ... }.

  4. Missing close_all_windows() in C++ and C# files. The Python version correctly calls close_window(window) after the loop, but the C++ and C# versions do not have a cleanup call. Please add close_all_windows() (C++) / SplashKit.CloseAllWindows() (C#) / CloseAllWindows() (top-level C#) after the loop.

  5. Uses window_close_requested() instead of quit_requested(). The style guide recommends while (!quit_requested()) for the main loop. Both work, but quit_requested() is the convention used in other approved examples.

  6. Missing newline at end of files. All files are missing a trailing newline.

Checks

  • All required files are present.
    • Example Title (.txt)
    • C++ code (SplashKit)
    • C# code (top-level statements) — ⚠️ wrong filename
    • C# code (Object-Oriented Programming)
    • Python code
    • Output screenshot (.png)

Code Tests done

  • C++ SplashKit code ran correctly.
  • C# top level code ran correctly.
  • C# OOP code ran correctly.
  • Python code ran correctly.

Note: I was unable to compile and run the code locally as I do not have the SplashKit SDK installed on this machine. Please verify all 4 variants compile and run correctly.

Copy link
Copy Markdown

@kottochii kottochii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peer review

As the issues have been addressed, I approve this.

@jasveena15
Copy link
Copy Markdown
Author

Peer Review

I've reviewed the brightness_of usage example. Nice creative idea using purple shades of varying brightness — it clearly demonstrates the function and the visual output is effective. However, there are a few issues that need to be addressed.

Issues

  1. C# top-level file has wrong filename. The file is named brightness_of-1-example-top.cs but the convention requires brightness_of-1-example-top-level.cs (note: -top-level, not -top). The auto-generation script looks for -top-level.cs specifically (see api-pages-script.cjs line 268), so this file will not be detected during build. Please rename to brightness_of-1-example-top-level.cs.
  2. Top-level C# uses OOP-style calls. The top-level C# file should use using static SplashKitSDK.SplashKit; and call functions directly (e.g., OpenWindow(...), ClearScreen(...), BrightnessOf(...)) instead of prefixing everything with SplashKit.. The current code reads identically to the OOP version.
  3. OOP C# missing namespace. The OOP C# file should wrap the class in a namespace: namespace BrightnessOfExample { ... }.
  4. Missing close_all_windows() in C++ and C# files. The Python version correctly calls close_window(window) after the loop, but the C++ and C# versions do not have a cleanup call. Please add close_all_windows() (C++) / SplashKit.CloseAllWindows() (C#) / CloseAllWindows() (top-level C#) after the loop.
  5. Uses window_close_requested() instead of quit_requested(). The style guide recommends while (!quit_requested()) for the main loop. Both work, but quit_requested() is the convention used in other approved examples.
  6. Missing newline at end of files. All files are missing a trailing newline.

Checks

  • All required files are present.

    • Example Title (.txt)
    • C++ code (SplashKit)
    • C# code (top-level statements) — ⚠️ wrong filename
    • C# code (Object-Oriented Programming)
    • Python code
    • Output screenshot (.png)

Code Tests done

  • C++ SplashKit code ran correctly.
  • C# top level code ran correctly.
  • C# OOP code ran correctly.
  • Python code ran correctly.

Note: I was unable to compile and run the code locally as I do not have the SplashKit SDK installed on this machine. Please verify all 4 variants compile and run correctly.

fixed the issues

Copy link
Copy Markdown

@ralphweng2023 ralphweng2023 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All issues from my previous review have been addressed. Nice work on the fixes — the usage example looks great now. Approved.

@ekam313
Copy link
Copy Markdown

ekam313 commented Apr 3, 2026

Second Peer Review

I've reviewed the brightness_of usage example and checked it against the usage example guide and style requirements.

Checks

  • All required files are present.
    • Example Title (.txt)
    • C++ code
    • C# code (top-level statements)
    • C# code (Object-Oriented Programming)
    • Python code
  • Code correctly uses SplashKit functions.
  • Code clearly demonstrates the function.
  • All versions maintain a consistent structure.

Code Tests done

  • C++ code ran correctly.
  • C# top level code ran correctly.
  • C# OOP code ran correctly.
  • Python code ran correctly.

Website Tests done

  • npm run build
  • npm run preview

Review Summary

The example is clear, visually effective, and beginner-friendly. The use of different purple shades to demonstrate brightness values is a good approach and makes the functionality easy to understand.

However, there are a few small style-related adjustments needed before approval:

  • In the Python version, the loop currently uses while not window_close_requested(window):. According to the style guide, this should be updated to while not quit_requested(): for consistency.

  • In the C# top-level version, since Color is used, it would be better to include using SplashKitSDK; along with using static SplashKitSDK.SplashKit;.

  • For consistency across languages, the Python version could use refresh_screen_with_target_fps(60) instead of refresh_screen().

Conclusion

Everything works correctly and the example is well structured. Once these minor style adjustments are made, it should be ready for approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants