Mandelbrot 512 bytes (java)

De GirinoWiki

O arquivo deve se chamar F.java:

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
 
/**
 * this is the cool stuff of writing mandelbrot set applet with 
 * less than 512 bytes. But rickbit beats me with these :P
 * 
 *  
 * @author girino
 *
 */
public class F extends Applet {
 
  public void paint(Graphics g) {
	  int j = -1;
	  while(++j<300) {
		  int i = -1;
		  while(++i<300) {
			  float x = 0f;
			  float y = 0f;
			  int v = 0;
			  for(; v < 40 && (x * x + y * y)/2f < 2f; v++) {
				  float t = i/100f - 2f + x * x - y * y;
				  y = j/100f - 1.57f + x * y * 2f;
				  x = t;
			  }
			  g.setColor(new Color(0f, (v==40)?0f:(float)Math.pow(v, 1f/2f)/6.325f, 0f));
			  g.drawRect(i,j,1,1);
		  }
	  }
  }
 
 
}
Ferramentas pessoais
Social Blogging
  • StumbleUpon
  • Adicionar aos Favoritos BlogBlogs
  • Adicionar esta página no Linkk
  • Add to Technorati Favorites
patrocinadores
Espaço comercial
Compare Produtos, Lojas e Preços