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

refactor: dynamic colour support #23

Merged
merged 8 commits into from
Dec 4, 2024
Merged

refactor: dynamic colour support #23

merged 8 commits into from
Dec 4, 2024

Conversation

MungaSoftwiz
Copy link
Owner

PR: Add Dynamic Colour Support and Screen Drawing Enhancements
closes #22

Summary:
This PR introduces dynamic colour handling for the 16-colour palette, adds a display_character function for flexibility, and updates the screen drawing logic to ensure compatibility with various colour modes. Additionally, the changes enhance the screen buffer visualisation and streamline character and line drawing.

Changes Made:

  1. Dynamic Colour Handling:
  • Added display_character to dynamically fetch colours from the selected palette (monochrome, sixteen & two_fifty_six palettes).
  • Allowed seamless support for 16 ANSI colours without hardcoding specific mappings.
  • Incorporated flexibility for future extensions (e.g., supporting 256-colour palettes).
  1. Enhancements to screen.ml:
  • Defined a robust mapping between colour_index values and RGB colours from palettes.
  • Improved parse_colour_mode to initialise the appropriate palette based on the mode.
  • Updated the display_character function to fetch and apply colours dynamically, using ANSI escape codes for precise rendering.
  1. Improvements in main.ml:
  • Updated screen initialisation with example_setup_data to set up a 16-colour mode.
  • Enhanced character and line drawing logic with test cases for colour validation.
  • Implemented a dynamic screen buffer rendering that accurately displays characters in their respective colours.
  1. Bug Fixes:
  • Fixed incorrect handling of colour_index for unsupported modes.
  • Resolved issues where hardcoded colour mappings caused inconsistencies in rendering.
  1. Testing:
  • Added multiple test cases in main.ml to verify dynamic colour rendering.
  • Tested all 16 colours with characters and lines to confirm palette accuracy.
  • Ensured smooth transitions between Monochrome, 16-color, and 256-color modes.

@MungaSoftwiz MungaSoftwiz merged commit 09f2c78 into main Dec 4, 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.

Add Colour Mode Support for Monochrome, 16 Colours, and 256 Colours
1 participant