From 6a3eb64bd1dd2c8ebcd31436876e0ff66d921507 Mon Sep 17 00:00:00 2001
From: Jonas Wielicki Use different formulas for Color Vision Deficiency correction, as suggested by Marcus Waldvogel. Update test vectors. Clarify generation of the angle. Prioritize nicknames over bare JIDs. Add rationale for new palette mapping algorithm introduced in 0.3. Implementations may want to show a picture in connection with a contact even if the contact does not have an avatar defined (e.g. via &xep0084;). In such cases, auto-generating an avatar SHOULD happen as follows: Output: Angle in the CbCr plane. Note: The goal of this algorithm is to convert arbitrary text into a scalar value which can then be used to calculate a color. As it happens, the CbCr plane of the YCbCr space determines the color (while Y merely defines the lightness); thus, an angle in the CbCr plane serves as a good scalar value to select a color. Output: Angle in the CbCr plane. Note: This algorithm will re-map the angle to map it away from ranges which can not be distinguished by people with the respective &cvds;. Divide the angle by two. Take the angle modulo π. Note: the same effect can be achieved by forcing the most-significant bit of the angle to zero before converting to a float in Angle generation. This avoids having to perform a floating-point modulo operation. Divide the angle by two and add π/2 (half Pi). Subtract π/2 from the angle, take the result modulo π and add π/2. Note: the same effect can be achieved by setting the most-significant bit of the angle to the inverse of the second-most-significant bit before conversion to floating point in Angle generation. This avoids having to perform a floating-point modulo operation. Convert Cb and Cr to an angle:
-
-
+
An implementation may choose a different value for Y depending on whether the sink for the R, G and B values expects Gamma Encoded or Gamma Decoded values. The recommended default of 0.732 is 0.5 to the power of 0.45, that is, a Gamma Encoded 0.5.
Modifications to Y SHOULD NOT be used to correct for bright/dark backgrounds. Implementations SHOULD instead use the algorithm described in Adapting the Color for specific Background Colors for that.
+An implementation which shows the generated colors on a colored background SHOULD apply Adapting the Color for specific Background Colors. If the background is not uniformly colored, it is up to the implementation to determine an appropriate surrogate background color to correct against.
+If an implementation shows the generated colors on a grayscale (including white and black) background, it MAY apply the background color correction algorithm. It is RECOMMENDED to always apply the algorithm if the background color is changed dynamically, to avoid discontinuities between grayscale and colored backgrounds.
+Implementations SHOULD use the same background color for all generated colors. If this is not feasible, implementations SHOULD use the same background color for all generated colors within the same GUI control (for example, within a conversation and within the roster).
+As outlined above, implementations SHOULD offer the &rgblind; and &bblind; corrections as defined in the Corrections for &cvds; section. Users SHOULD be allowed to choose between:
@@ -241,7 +261,7 @@ angle = atan2(cr, cb) % (2*pi)The last option is important for users with monochromatic view.
+The last option is useful for users with monochromatic view or who find colors distracting.
Some sources on the internet indicate that people with &cvds; may profit from having larger areas of color to be able to recognize them. This should be taken into consideration when selecting font weights and line widths for colored parts.
SHA-1 is widely available. From a security point of view, the exact choice of hash function does not matter here, since it is truncated to 16 bits. At this length, any cryptographic hash function is weak.
+The palette-mapping algorithm operates on angles only and disregards the Y value except if the angles match. This has the downside that the brightness is not equal over the range of the palette mapped colors.
+The alternative would be to require Y to be close to the target Y. This has several issues:
+For the sake of having more colors available, the given algorithm was chosen which prefers many colors with hue conformance over fewer colors with hue and lightness conformance.
+This document requires no interaction with &IANA;.
@@ -279,7 +308,7 @@ angle = atan2(cr, cb) % (2*pi)This document requires no interaction with the ®ISTRAR;.
Thanks to Daniel Gultsch, Georg Lukas, and Tobias Markmann.
+Thanks to Klaus Herberth, Daniel Gultsch, Georg Lukas, Tobias Markmann, Christian Schudt, and Marcus Waldvogel for their input and feedback on this document.
This section holds test vectors for the different configurations. The test vectors are provided as Comma Separated Values. Strings are enclosed by single quotes ('). The first line contains a header. Each row contains, in that order, the original text, the text encoded as UTF-8 as hexadecimal octets, the angle in radians, and the Cb, Cr, Red, Green, and Blue values.
+'Romeo','526f6d656f',5.711682,0.500000,-0.321546,0.281,0.790,1.000
+'juliet@capulet.lit','6a756c69657440636170756c65742e6c6974',3.654901,-0.500000,-0.281855,0.337,1.000,0.000
+'😺','f09f98ba',5.780519,0.500000,-0.274885,0.347,0.756,1.000
+'council','636f756e63696c',6.283089,0.500000,-0.000048,0.732,0.560,1.000]]>
+'Romeo','526f6d656f',2.570089,-0.500000,0.321546,1.000,0.674,0.000
+'juliet@capulet.lit','6a756c69657440636170756c65742e6c6974',0.513308,0.500000,0.281855,1.000,0.359,1.000
+'😺','f09f98ba',2.638926,-0.500000,0.274885,1.000,0.708,0.000
+'council','636f756e63696c',3.141497,-0.500000,0.000048,0.732,0.904,0.000]]>
+'Romeo','526f6d656f',2.570089,-0.500000,0.321546,1.000,0.674,0.000
+'juliet@capulet.lit','6a756c69657440636170756c65742e6c6974',3.654901,-0.500000,-0.281855,0.337,1.000,0.000
+'😺','f09f98ba',2.638926,-0.500000,0.274885,1.000,0.708,0.000
+'council','636f756e63696c',3.141497,-0.500000,0.000048,0.732,0.904,0.000]]>
The used palette can be generated by sampling the RGB cube evenly with six samples on each axis (resulting in 216 colors). The resulting palette is commonly known as the palette of so-called "Web Safe" colors.
-The format of the test vectors is the same as in the full range case above.
+The used palette can be generated by sampling the RGB cube evenly with six samples on each axis (resulting in 210 colors (grayscales are excluded)). The resulting palette is commonly known as the palette of so-called "Web Safe" colors.
+Instead of the cb and cr values, the test vectors contain the best_angle as found in the palette.
+
+
+