Skip to content
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

fix: enhance colour palette support #30

Merged
merged 1 commit into from
Dec 9, 2024
Merged

Conversation

MungaSoftwiz
Copy link
Owner

PR: Terminal Screen Rendering with Enhanced Colour Palette Support
close #29

Description
This PR improves the screen rendering system by introducing robust handling of three colour modes (Monochrome, 16 Colours, 256 Colours) and better-organised palette management. The system now supports:

  • Accurate RGB-based palette definitions.
  • Dynamic generation of the 256-colour palette, including the 6x6x6 colour cube and grayscale ramp.
  • Improved error handling and more reusable rendering logic.

Key Changes

Palette Definitions:

  • Monochrome: Two colours ({r:0, g:0, b:0} and {r:255, g:255, b:255}).
  • 16 Colours: Includes the base ANSI palette (Black, Blue, Green, etc.).
  • 256 Colours: Dynamically generated:
  1. First 16 indices mirror the 16-colour palette.
  2. Indices 16–231 represent a 6x6x6 RGB colour cube.
  3. Indices 232–255 form a grayscale ramp.

Screen Setup:

Validation of screen dimensions and colour modes.
Palette initialisation based on the supplied mode.

Error Handling:

Added exceptions for invalid inputs, e.g., unsupported colour modes or out-of-range indices.

Documentation:

  • Clear comments explaining palette definitions and rendering logic.
  • Examples of how indices map to colours.

Known Issues/Limitations

  • Non-ANSI terminals may not render the colours accurately.
  • Customisation of the palette is not currently supported but could be considered for future enhancements.

Screenshot:

  • Shows a 256 Colours mode which is now supported.
    image

image

@MungaSoftwiz MungaSoftwiz merged commit 6b6df75 into main Dec 9, 2024
1 check passed
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.

Bug: Incorrect Palette length and colour handling
1 participant