Really basic little Java experiment I just wrote… messing around with cos and sin
http://skehin.com/misc/CycleExperiment
import java.awt.*;
import java.applet.*;
public class CycleExperiment extends Applet {
public void paint(Graphics g) {
this.setBackground(new Color(0,0,0));
int height = this.getHeight();
int width = this.getWidth();
for(int i = 0; i < width; i+=3){
for(int j = 0; j < height; j+=3){
float red = Math.abs(round(5, Math.cos(i + j)));
float green = Math.abs(round(5, Math.sin(i * j)));
float blue = Math.abs(round(5, Math.cos(i * (j/(i+0.1)))));
System.out.println("Red: " + red + " Green: " + green + " Blue: "+ blue);
g.setColor(new Color(red, green, blue));
g.drawRect(i, j, 1, 1);
}
}
}
private static float round(int numPlaces, double num){
return (float) Math.round(num*(numPlaces*10))/(numPlaces*10);
}
}
//Copyright njs 2004
(it’s Java, but the PHP mode provides alright highlighting for C style languages like Java)