Important alert: (current site time 7/15/2013 3:20:47 PM EDT)
 

VB icon

Algorithmic Image Generator

Email
Submitted on: 3/14/2001 12:40:26 PM
By: Blaine Sahazian 
Level: Intermediate
User Rating: By 1 Users
Compatibility: Java (JDK 1.2)
Views: 18679
 
     To show my prof. that i know math. hah check it out it's not that cool but you can learn something about floating point arithmetic. just like i said i wanted to upload the project files but the server isn't responding
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: Algorithmic Image Generator
// Description:To show my prof. that i know math. hah check it out it's not that cool but you can learn something about floating point arithmetic. just like i said i wanted to upload the project files but the server isn't responding
// By: Blaine Sahazian
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=2136&lngWId=2//for details.//**************************************

/*
	Algorithmic Image Generation
	(c)Trenton Miller 2001,
	Student ID: 3221220
One thing if you move it the image goes away
*/
import java.io.*;
import java.awt.*;
import java.awt.image.*;
class Mandelbrot {
	
public static void main(String[] args) {
	new MandelWindow();
}}
//------------------------------------------
class MandelWindow extends Frame {
	
Image	img;
int		w = 256;
int		h = 256;
int[]	pix = new int[w * h];
MandelWindow() {
	
int index = 0;
int iter;
double p,q, psq, qsq, pnew, qnew;
double a,b;			//real and imaginary axis
//Make sure you check out some music by my band you won't be unimpressed
//sorry had to put that in there
resize(260,300);
show();
Graphics g = getGraphics();
double WIDTH_STEP = 4.0/w;
double HEIGHT_STEP = 4.0/h;
//P.s Colleges come up with st*pid projects i guess you didn't know that =P 
//Hey i had to put that in there i'm trenton not a nerd
for (int y=0; y < h; y++) {		b = ((double)(y - 128))/64; //whew all this math i hate floating point
	for (int x=0; x < w; x++) {		a = ((double)(x - 128))/64;
	//whew all this math i hate floating point
	
		p=q=0;
		iter = 0;
		while (iter < 32) { //see if point a,b in the set
			psq = p*p; qsq = q*q;
			if (psq+qsq >= 4.0)break;
			pnew = psq - qsq + a;
			qnew = 2 * p*q + b;
			p = pnew;
			q = qnew;
			iter++; //oh increment oh increment
		}
		if (iter == 32) {
			pix[index] = 255<<24 | 255; //Thos crazy || i'll never understand why they mean what they do
		}
		index++;
	}
}
for (float i =0.0F; i< 1.0F; i+=0.01F) { //Ohh soo pretty
	g.setColor(new Color(1,0,0));
	g.drawLine(0,0, (int)(300*Math.cos(i*1.5)), (int)(300*Math.sin(i*1.5))
);
	}
	img = createImage(new MemoryImageSource(w, h, pix, 0, w));
	g.drawImage(img, 0, 0, null);
	System.out.println("Algorithmic Image Generation");
	System.out.println("(c)Trenton Miller 2001");
	System.out.println("Student ID:3221220");
}}


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

3/14/2001 12:46:31 PMTrenton

Rawr!!!!!!!!!
(If this comment was disrespectful, please report it.)

 
3/6/2005 10:47:06 PM

codes
(If this comment was disrespectful, please report it.)

 
9/3/2007 2:14:25 AMAlina

dear sir,
We are the student of kec nepal we are doing a finel year project title is fingerprint authentication system so we required a reference project for that please help us

(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.