Ejemplo n.º 1
0
 void Scene::computeColorsAntialiasing(std::function<void(int, int, ColorCRef)> paint, int threadCount, int level) {
     upto(threadCount, 1);
     downto(threadCount, 4);
     std::vector< std::vector <ColorFloat> > m(screen.width, std::vector<ColorFloat> (screen.height, ColorFloat()));
     computeColors([paint, &m](int x, int y, ColorCRef c) { m[x][y] = c; paint(x, y, c); }, threadCount);
     if (level > 1) {
         for (int x = 1; x + 1 < screen.width; x++) {
             for (int y = 1; y + 1 < screen.height; y++) {
                 int badness = 0;
                 for (int dx : {-1, 1})
                     for (int dy : {-1, 1})
                         badness += (m[x][y] - m[x + dx][y + dy]).norm();
                 if (badness > badnessLimit) {
                     paint(x, y, Color(255, 0, 0));
                 }
             }
         }
         int taskCount = 10;
         ThreadPool pool;
         for (int t = 0; t < taskCount; t++)
             pool.addTask([this, &paint, &m, level, t, taskCount]()
                          { multiThreadAntialiasePart(paint, m, level, t, taskCount); });
         pool.executeAll(threadCount);
     }
 }
Ejemplo n.º 2
0
Colormap::Colormap() {
    hue = 0.0f;
    saturation = 1.0;
    numberOfColors = COL_256;
    map.resize(COL_256);
    map[0] = BLACK;
    map[255] = WHITE;
    texture = 0;
    computeColors();
}
Ejemplo n.º 3
0
void Colormap::putColor(RGB color, unsigned int position) {
    map[position] = color;
    computeColors();
}
Ejemplo n.º 4
0
void Colormap::setNumberOfColors(int n) {
    numberOfColors = n;
    computeColors();
}
Ejemplo n.º 5
0
void Colormap::setSaturation(float s) {
    saturation = s;
    computeColors();
}
Ejemplo n.º 6
0
void Colormap::setHue(float h) {
    hue = h;
    computeColors();
}