I love being able to color-code scenes with the “label” feature. I use this to show which scene is in whose point-of-view using the labels. However, because I now have quite a few POV characters, I’ve had to use some “bright” label colors, and I now see that they are not as legible as they should be.
I’d like to recommend you use a different algorithm to compute whether to use white or black text. This algorithm computes the brightness based on the “value” in the HSV color space, reliably returning “white” or “black” for the color for the foreground text. This would improve readability significantly.
I see that you’re doing something similar to this with the label colors, but it can still result in white text with bright labels where black text would be much more readable. As an example, on the Mac version of Scrivener, assign the “green” color to a new label from the Apple color palette. The text on that label is barely readable when you use a “dark” system color theme.
I also noticed that the colors used in the Binder are always white or black, and aren’t defined independently for each background color. This is less of an issue in the binder because the background color values are shifted when you switch from dark to light system themes on the Mac, but if each value was computed separately, you wouldn’t need to change the label color values at all.
Following is a Python code example of this label color computation, converting from RGB color values to HSV for purposes of determining the label text color (white or black). I realize you don’t code Scrivener in Python, but since I don’t know what language you use, I figured it would still be useful as functional pseudocode.
def determine_foreground_color(rgb):
"""
Determine whether to use black or white as the foreground color
based on the brightness (Value) of the background RGB color.
Args:
rgb (tuple): A tuple of (R, G, B) values in the range 0-255.
Returns:
tuple: A tuple of (R, G, B) for the foreground color.
"""
# Step 1: Convert RGB to HSV
r, g, b = [x / 255.0 for x in rgb] # Normalize RGB values to the range 0-1
max_val = max(r, g, b)
min_val = min(r, g, b)
delta = max_val - min_val
# Calculate Hue
if delta == 0:
h = 0 # Undefined hue
elif max_val == r:
h = (60 * ((g - b) / delta)) % 360
elif max_val == g:
h = (60 * ((b - r) / delta)) + 120
else:
h = (60 * ((r - g) / delta)) + 240
# Calculate Saturation
s = 0 if max_val == 0 else delta / max_val
# Calculate Value (Brightness)
v = max_val
# Step 2: Determine the foreground color
if v > 0.5:
return (0, 0, 0) # Black foreground
else:
return (255, 255, 255) # White foreground
# Example usage
background_rgb = (200, 100, 50) # Replace with actual background color
foreground_rgb = determine_foreground_color(background_rgb)
print("Foreground color:", foreground_rgb)