import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.*; import java.io.File; import java.io.IOException; class Main { static final int X = 512, Y = 512; static final int terms = 32; static final double pi = Math.PI; static final double t = pi/6; static final int colors[] = {0xffffff, 0xff00ff, 0xff80ff, 0xffff, 0x80ffff, 0xffff00}; static final double coef[] = new double[terms]; static BufferedImage I = new BufferedImage(X, Y, BufferedImage.TYPE_3BYTE_BGR); static double cos(double x) {return Math.cos(x);} static double clip(double x) {return x<-1?-1:x>1?1:x;} static void pl(int i, double y, int col) { I.setRGB(i, (int)((clip(-y*.7)+1)*Y/2), col);} static public void main(String[] args){ final int cm = colors.length; for(int j = 0; j0?-1:1)*cos(t*k)/k; System.out.println(" a["+k+"] = "+coef[j]);} for (int i = 0; i 0) try { File file = new File(args[0]); ImageIO.write(I, "png", file );} catch (IOException e) {System.err.println("image not saved.");} }} class MainCanvas extends Canvas{ public void paint(Graphics g){ g.drawImage(Main.I, 0, 0, Color.red, null);}}