FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   In order of appearence
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: In order of appearence  (Read 1676 times)
st33d

WWW Email
In order of appearence
« on: Dec 9th, 2004, 2:31am »

Various times I've been making applets I've come across the issue of what gets drawn over what. I'd assumed that later drawing requests would get placed on top. It hasn't been an issue so far because most of my programs are theoretical rather than graphical.
 
But take this for example, it's a demonstration of a bell curve function (that's also normal distribution or gaussian distribution in case anyone searches for it):
 
Code:

float E = 2.71828182845904523536;
float x = -4;
float y;
void setup(){
size(400,400);
background (250);
stroke (180);
line (200,0,200,400);
line (0,200,400,200);//why is it on top?!
stroke(0);
}
void loop(){
translate (200,200);
if (x < 4){
y=nDist(x,1,0);
point (x*20,y*400);
println ("x:"+x+"y:"+y);
x=x+0.01;
}
}
float nDist (float xx, float sigma, float mu){
return  pow(E,-(sq((xx-mu))) / (2 * sq(sigma))) / (sigma*sqrt(TWO_PI));
}//where sigma is the scale of the graph & mu shifts the location of the graph along x

 
The horizontal axis I've defined in the setup sits on top of the fresh drawing activity!
 
What is the proper method of forcing Processing to draw things in the desired stacking order? (And how do the problems like this affect an image being plotted over a long period of time?)
« Last Edit: Dec 9th, 2004, 2:37am by st33d »  

I could murder a pint.
fry


WWW
Re: In order of appearence
« Reply #1 on: Dec 9th, 2004, 6:16pm »

your intuition is correct, it's just a bug as it stands now. you might try enabling smooth() to see if that will fix it, or include a line that says "g.dimensions = 3;" (this is a hack that fixes some bugs but prolly not this one), or since they're horizontal lines, just make yourself a quick little line drawing loop.
 
miha


Re: In order of appearence
« Reply #2 on: Apr 11th, 2005, 6:36pm »

Have you found the solution to this problem?
I have an array of images. Their size changes every frame. Some get bigger some smaller. I want the bigger images to be drawn over the smaller images for them to appear closer to the screen.
 
I tried sorting the array and then displaying the images in a for loop from the smallest to the biggest.
 
It has no effect. I can't figure out what causes one image to overlap another. It sure isn't the order they were drawn in.
Thanks for any help you can give me.
 
Pages: 1 

« Previous topic | Next topic »