package sample.web3d;

import static util.Generic3DUtil.*;

public class Gradation3D {
	private static final double r = 240;
	private static final int n = 12;
	public static void main(String[] args) {	
		start();
		fill(hsl1(0, 0, 0.5));
		sphere(20);
		for (int i=0; i<n; i++) {
			double y = - r + i * r / (n-1); 
			for (int j=0; j<=2*i+1; j++) {
				double theta = PI * j / (i+1) + i * PHYLLOTAXIS;
				double x = i * r / (n-1) * Math.cos(theta);
				double z = i * r / (n-1) * Math.sin(theta);
				pushMatrix();
				translate(x, y, z);
				fill(hsl1(theta/2/PI, 1, (double)0.5*i/(n-1)));
				sphere(20);
				popMatrix();		
			}
		}
		for (int i=0; i<n-1; i++) {
			double y = r - i * r / (n-1); 
			for (int j=0; j<=2*i+1; j++) {
				double theta = PI * j / (i+1)  + (2*n-2-i) * PHYLLOTAXIS;
				double x = i * r / (n-1)* Math.cos(theta);
				double z = i * r / (n-1) * Math.sin(theta);
				pushMatrix();
				translate(x, y, z);
				fill(hsl1(theta/2/PI, 1, 1-(double)0.5*i/(n-1)));
				sphere(20);
				popMatrix();		
			}
		}
		finish();
	}
}
