Jellysheep
Erfahrenes Mitglied
Wenn du wirklich keine sonstigen Klassen verwenden sollst, dann probier mal folgendes:
Java:
for (int y = 0; y < height; y++) {
// Schleife ueber die x-Werte
for (int x = 0; x < width; x++) {
int pos = y * width + x; // Arrayposition bestimmen
int r, g, b;
if (x <= width / 2+1) {
r = (int) (r1 + ((r2 - r1) * (2 * x / (double) width)));
g = (int) (g1 + ((g2 - g1) * (2 * x / (double) width)));
b = (int) (b1 + ((b2 - b1) * (2 * x / (double) width)));
} else {
r = (int) (r2 + ((r3 - r2) * (2 * x / (double) width)));
g = (int) (g2 + ((g3 - g2) * (2 * x / (double) width)));
b = (int) (b2 + ((b3 - b2) * (2 * x / (double) width)));
}
// Werte zurueckschreiben
pixels[pos] = 0xFF000000 | (r << 16) | (g << 8) | b;
}
}
Zuletzt bearbeitet: