Color.st
changeset 8112 0825f3c6a0cb
parent 8109 017a2867ba53
child 8123 099bb6b94798
equal deleted inserted replaced
8111:c20fb44519e3 8112:0825f3c6a0cb
  1094      Color hue:120 light:50 saturation:50    - greyish dark green
  1094      Color hue:120 light:50 saturation:50    - greyish dark green
  1095      Color hue:120 light:50 saturation:0     - b&w television dark green
  1095      Color hue:120 light:50 saturation:0     - b&w television dark green
  1096     "
  1096     "
  1097 
  1097 
  1098     "Modified: 23.4.1996 / 13:22:22 / cg"
  1098     "Modified: 23.4.1996 / 13:22:22 / cg"
       
  1099 !
       
  1100 
       
  1101 luma:y chromaBlue:cb chromaRed:cr
       
  1102     "return a color from Y-Cb-Cr components.
       
  1103      See https://en.wikipedia.org/wiki/YCbCr
       
  1104      and ITU-R BT.601"
       
  1105 
       
  1106     |r g b|
       
  1107 
       
  1108     r := y + (1.400 * cr).
       
  1109     g := y - (0.343 * (cb-128)) - (0.711 * (cr-128)).
       
  1110     b := y + (1.765 * (cb-128)).
       
  1111 
       
  1112     ^ self redByte:r greenByte:g blueByte:b
       
  1113 
       
  1114     "
       
  1115      Color luma:0 chromaBlue:128 chromaRed:128 
       
  1116      Color luma:1 chromaBlue:128 chromaRed:128 
       
  1117      Color luma:0.5 chromaBlue:128 chromaRed:128
       
  1118     "
       
  1119 
       
  1120     "Created: / 26-08-2017 / 21:33:52 / cg"
  1099 !
  1121 !
  1100 
  1122 
  1101 name:colorName
  1123 name:colorName
  1102     "Return a named color (either exact or dithered).
  1124     "Return a named color (either exact or dithered).
  1103      Report an error, if aString is not a valid color name.
  1125      Report an error, if aString is not a valid color name.