* Bildpunkte in einem Rechteck (CSS-Pixel), deren staerkster Kanal deutlich * Blau ist, wie die geteilte CALLS-Farbe #579fc7 oder das Blaugrau #85b4c5 * der aus Quelltext gebauten Dienste, und solche, die deutlich * gruen sind wie die Aufruffarbe der Palette.
(image, rect)
| 140 | * gruen sind wie die Aufruffarbe der Palette. |
| 141 | */ |
| 142 | function hueCounts(image, rect) { |
| 143 | let blue = 0; let green = 0; |
| 144 | for (let y = Math.max(0, Math.round(rect.top * SCALE)); y < Math.min(image.height, Math.round(rect.bottom * SCALE)); y++) { |
| 145 | for (let x = Math.max(0, Math.round(rect.left * SCALE)); x < Math.min(image.width, Math.round(rect.right * SCALE)); x++) { |
| 146 | const at = (y * image.width + x) * image.channels; const r = image.pixels[at]; const g = image.pixels[at + 1]; const b = image.pixels[at + 2]; |
| 147 | if (b - g >= 12 && b - r >= 40) blue += 1; |
| 148 | if (g - b >= 25 && g - r >= 60) green += 1; |
| 149 | } |
| 150 | } |
| 151 | return { blue, green }; |
| 152 | } |
| 153 | |
| 154 | /* ------------------------------------------------------------------ */ |
| 155 | /* Seite */ |