User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » coloring pixels in java Page [1]  
Novicane
All American
15411 Posts
user info
edit post

im running this for-loops with the following methods:


for (h=0; h < HEIGHT; h++){

for (w=0; w < WIDTH; w++){
y = yUpperLeft - (h * xStep);
x = xUpperLeft + (w * yStep);

im = yUpperLeft - (y*yStep);
re = xUpperLeft + (x* xStep);

Complex c = new Complex(re, im);
pD = pixelDiverges(c,ITERATIONS);

Color myColor;

myColor = new Color(pD,pD,pD);

pic.setColor((int)x,(int)y,myColor);


HEIGHT and WIDTH are final static values. These loops should run through, check to see if the x,y fits the set, then color.

on compiling I get a black screen and no colors. It seems to be running through the loops but not coloring. I know my other methods are correct, im not sure on obtaining x and y. Any hints?

11/27/2005 5:17:11 PM

dakota_man
All American
26584 Posts
user info
edit post

manually set x and y

11/27/2005 5:48:59 PM

philihp
All American
8349 Posts
user info
edit post

YAY 4 DEBUGGING

11/27/2005 6:05:18 PM

Novicane
All American
15411 Posts
user info
edit post

actually setting any pixel (x and y) colors it the right color. The loops won't run through the size of the picture coloring each one.

11/27/2005 6:08:46 PM

GenghisJohn
bonafide
10234 Posts
user info
edit post

Tip:

Java sucks.

11/28/2005 1:30:10 AM

marilynlov7
All American
650 Posts
user info
edit post

^

11/28/2005 9:27:31 AM

Aficionado
Suspended
22518 Posts
user info
edit post

^^

11/28/2005 10:28:37 AM

dakota_man
All American
26584 Posts
user info
edit post

^^^

11/28/2005 11:56:12 AM

philihp
All American
8349 Posts
user info
edit post

^, ^^, ^^^, ^^^^: did not make A+s in CSC116

11/28/2005 9:33:14 PM

marilynlov7
All American
650 Posts
user info
edit post

^ did too

11/28/2005 10:31:59 PM

GenghisJohn
bonafide
10234 Posts
user info
edit post

Yeah, I did.

And then I got an internship in the real world, where java is fucking pointless.

11/29/2005 1:59:19 PM

philihp
All American
8349 Posts
user info
edit post

heh, sophomore in csc still thinks he's the shit

11/30/2005 2:47:04 AM

Perlith
All American
7620 Posts
user info
edit post

Novicane, did you ever solve your problem?

Don't want this thread to turn into another Java/C++/Pick a Language sucks because XXXX thread.

11/30/2005 5:44:29 AM

Novicane
All American
15411 Posts
user info
edit post

yes

pretty much I switched my HEIGHT and WIDTH loops around, and my y and x conversion was tremendously off. I then realized that x and y ARE the real and imaginary numbers needed to determine if its part of the mandlebrot set.

something like this is what I needed:




for (w= 0; w < WIDTH; w++) {

for (h= 0; h < HEIGHT; h++) {

x = xUpperLeft + w * xStep;
y = yUpperLeft + height - (h * yStep);

Complex c = new Complex(x, y);
pD = pixelDiverges(c,ITERATIONS);

Color myColor;
myColor = new Color(pD,pD,pD);
pic.setColor((int)x,(int)y,myColor);
}
}
pic.show();


produces a very cool mandlebrot image with the classes provided. Adjusting the iterations and xycenter's you can get all kinds of crazy fractals. Also you can implement a save method to save your image a jpg to your c:/



[Edited on November 30, 2005 at 9:16 AM. Reason : dd]

11/30/2005 9:12:33 AM

Aficionado
Suspended
22518 Posts
user info
edit post

Quote :
"did not make A+s in CSC116"


nope, you are wrong, i got an A in a real language: FORTRAN

11/30/2005 10:24:53 AM

Novicane
All American
15411 Posts
user info
edit post

time line:

cave man creates fire -> FORTRAN -> wheel is invented -> present day

11/30/2005 11:59:06 AM

JonHGuth
Suspended
39171 Posts
user info
edit post

haha
you have to really try to not make an A in FORTRAN

11/30/2005 12:04:43 PM

Perlith
All American
7620 Posts
user info
edit post

Quote :
"you have to really try to make an A not fall asleep show up be interested in FORTRAN [fill in something here] "


[Edited on November 30, 2005 at 12:43 PM. Reason : .]

11/30/2005 12:43:10 PM

 Message Boards » Tech Talk » coloring pixels in java Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.