Skip to content

Add random color generation for RendererModel#432

Open
hnpct wants to merge 1 commit into
DenverCoder1:mainfrom
hnpct:main
Open

Add random color generation for RendererModel#432
hnpct wants to merge 1 commit into
DenverCoder1:mainfrom
hnpct:main

Conversation

@hnpct

@hnpct hnpct commented Nov 22, 2025

Copy link
Copy Markdown

Summary

Type of change

  • Bug fix (added a non-breaking change which fixes an issue)
  • New feature (added a non-breaking change which adds functionality)
  • Updated documentation (updated the readme, templates, or other repo files)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

  • Ran tests with composer test
  • Added or updated test cases to test new features

Comment on lines +6 to +13
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}

@DenverCoder1 DenverCoder1 Jun 1, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Firstly, this is JavaScript code in a server-side PHP file. If this is intended to target the demo site, this change should be implemented in /src/demo/js/script.js instead of here.

Regarding the function, as this simply picks random hex characters it does not differentiate between good and ugly colors, dark and light colors. I think it would better to pick a list of different nice looking hues along a similar brightness and saturation to randomly choose from so that all the random colors look good and are readable on all backgrounds.

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.

2 participants