První demonstrační aplikace pro simulaci difúze

Zdrojový text metody putPoint()


// -----------------------------------------------------------------------
// Vykreslení jednoho bodu do temporální bitmapy (plošné rastrové mřížky)
// podle zvoleného tvaru bodu.
// -----------------------------------------------------------------------
private void putPoint(int x, int y) {
    if (x<3) x=3;                               // zabránit zápisum
    if (x>=width-3) x=width-4;                  // mimo pole
    if (y<3) y=3;
    if (y>=height-3) y=height-3;
    if (pointShape!=PointShape.Diamond3x3 &&
        pointShape!=PointShape.Diamond5x5) {
        pixels[y][x]=true;                      // prostřední pixel
    }
    if (pointShape==PointShape.Cross3x3 ||
        pointShape==PointShape.Diamond3x3 ||
        pointShape==PointShape.Block3x3 ||
        pointShape==PointShape.Cross5x5 ||
        pointShape==PointShape.Block5x5 ||
        pointShape==PointShape.Horizontal3 ||
        pointShape==PointShape.Horizontal5) {
        pixels[y][x-1]=true;                    // pixel nalevo
        pixels[y][x+1]=true;                    // a pixel napravo
    }                                           // od prostředního pixelu
    if (pointShape==PointShape.Horizontal5 ||
        pointShape==PointShape.Cross5x5 ||
        pointShape==PointShape.Diamond5x5 ||
        pointShape==PointShape.Block5x5) {
        pixels[y][x-2]=true;                    // druhý pixel nalevo
        pixels[y][x+2]=true;                    // druhý pixel napravo
    }
    if (pointShape==PointShape.Cross3x3 ||
        pointShape==PointShape.Diamond3x3 ||
        pointShape==PointShape.Block3x3 ||
        pointShape==PointShape.Cross5x5 ||
        pointShape==PointShape.Block5x5 ||
        pointShape==PointShape.Vertical3 ||
        pointShape==PointShape.Vertical5) {
        pixels[y-1][x]=true;                    // pixel nahoře
        pixels[y+1][x]=true;                    // pixel dole
    }
    if (pointShape==PointShape.Vertical5 ||
        pointShape==PointShape.Cross5x5 ||
        pointShape==PointShape.Diamond5x5 ||
        pointShape==PointShape.Block5x5) {
        pixels[y-1][x]=true;                    // druhý pixel nahoře
        pixels[y+1][x]=true;                    // druhý pixel dole
    }
    if (pointShape==PointShape.XCross3x3 ||
        pointShape==PointShape.Block3x3 ||
        pointShape==PointShape.XCross5x5 ||
        pointShape==PointShape.Diamond5x5 ||
        pointShape==PointShape.Block5x5) {
        pixels[y-1][x-1]=true;                  // čtyři diagonální pixely
        pixels[y+1][x-1]=true;
        pixels[y-1][x+1]=true;
        pixels[y+1][x+1]=true;
    }
    if (pointShape==PointShape.XCross5x5 ||
        pointShape==PointShape.Block5x5) {
        pixels[y-2][x-2]=true;                  // čtyři diagonální pixely
        pixels[y+2][x-2]=true;                  // ve vzdálenosti 2
        pixels[y-2][x+2]=true;
        pixels[y+2][x+2]=true;
    }
    if (pointShape==PointShape.Block5x5) {
        pixels[y-2][x-1]=true;                  // zbývajících osm pixelů
        pixels[y+2][x-1]=true;                  // v bloku 5x5
        pixels[y-2][x+1]=true;
        pixels[y+2][x+1]=true;
        pixels[y-1][x-2]=true;
        pixels[y+1][x-2]=true;
        pixels[y-1][x+2]=true;
        pixels[y+1][x+2]=true;
    }
}

// -----------------------------------------------------------------------
// Konec metody putPoint().
// -----------------------------------------------------------------------