- private char getAsciiChar(int pixel) {
- float brigthness = getBrightness(pixel);
- if (brigthness < 0.20) {
- return ' ';
- } else if (brigthness < 0.40) {
- return '.';
- } else if (brigthness < 0.60) {
- return '+';
- } else if (brigthness < 0.80) {
- return '*';
- } else {
- return '#';
- }
- }
-
- /**
- * Return the {@link Character} corresponding to this colour in
- * {@link Mode#DITHERING} mode.
- *
- * @param pixel
- * the colour
- *
- * @return the {@link Character} to use
- */
- private char getDitheringChar(int pixel) {
- float brigthness = getBrightness(pixel);
- if (brigthness < 0.20) {
- return ' ';
- } else if (brigthness < 0.40) {
- return '░';
- } else if (brigthness < 0.60) {
- return '▒';
- } else if (brigthness < 0.80) {
- return '▓';
- } else {
- return '█';
- }
+ private char getDitheringChar(float brightness, String cars) {
+ int index = Math.round(brightness * (cars.length() - 1));
+ return cars.charAt(index);