You can use the surfaceLib library, which can handle all you needs. Creating a sphere and then adding an array of the colors you need for every horizontal stripe. Here is a small code example.
Quote:
import processing.opengl.*;
import surface.calculation.*;
import surface.*;
Sphere s;
void setup(){
size(500,500, OPENGL);
s=new Sphere(g, 51,51);
int[] colors = new int[51];
for(int i = 0; i<colors.length; i++){
if(i < 25) {
colors[i]=color(58, 102, 132);
}
if(i == 25) {
colors[i]=color(125);
}
if(i > 25){
colors[i]=color(102, 102, 0);
}
}
s.initHorizontalColors(colors);
noStroke();
smooth();
}
void draw(){
background(255);
translate(width/2,height/2);
rotateX(radians(frameCount));
rotateY(radians(frameCount));
s.setScale(mouseX);
s.draw();
}
Or you to it like that and draw different parts of the sphere consecutively:
Quote:
import processing.opengl.*;
import surface.calculation.*;
import surface.*;
Sphere s;
void setup(){
size(500,500, OPENGL);
s=new Sphere(g, 51,51);
noStroke();
smooth();
}
void draw(){
background(255);
translate(width/2,height/2);
rotateX(radians(frameCount));
rotateY(radians(frameCount));
s.setScale(mouseX);
fill(58, 102, 132);
s.drawPart(0,51,0,25);
fill(125);
s.drawPart(0,51,25,26);
fill(102, 102, 0);
s.drawPart(0,51,26,51);
}