We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › imageMode(CENTER ) in blend()
Page Index Toggle Pages: 1
imageMode(CENTER ) in blend() (Read 547 times)
imageMode(CENTER ) in blend()
Apr 20th, 2009, 8:33pm
 
As the reference says, with the latest version of processing, the blend function ignores imageMode().

Does anyone know how to make the blend function works as under imageMode(CENTER) without using imageMode?

Thanks for your help !!!
Re: imageMode(CENTER ) in blend()
Reply #1 - Apr 20th, 2009, 9:42pm
 
you can easily determine the corners of an image if you know its size. if you draw something using imageMode(CENTER); and want to translate it later to a blend() function that considers the upper left corner instead of the center of the image as an origin, the modification would be [supposing you have an xPos and yPos for the image which refer to the position in which it is drawn having its center as origin]:

x = (xPos - (image.width/2)); // x if you consider upper left corner instead of center
y = (yPos - (image.height/2)); // y if you consider upper left corner instead of center

i am actually guessing this is what you want, based on knowledge of how imageMode() works. however i have never used it on older versions of processing and i run its latest version, so it is impossible for me to test the behavior of imageMode() associated with blend(). i hope this helps you figuring out what you want to know.
Re: imageMode(CENTER ) in blend()
Reply #2 - Apr 21st, 2009, 12:16pm
 
Thanks for your reply very much. However, I am sorry that I didn't explain myself clearly. The blend() has two parts: region to copy and the destination area. My question is about the second part, destination area. Here is part of my code.

blend(img4, 0, 0, img4.width, img4.height, i, 0, img4.width+jwidth, img4.height+jheight, MULTIPLY);

if (i < 0){
 i++;
 j = j+1;
 jwidth = int ((width*j)/height);
 jheight = int (j/2);
 }


So, variable "i" makes the image move left and right. While it is moving, I want the image to be scaled up or down and variable "j" does this job. However, since the blend() ignores imageMode(CENTER), the scaling up and down will take the upper-left corner of the image as the coordinate origin. Since the scale of the image changes from the upper-left, it affects the movement of the image. For example, when image is moving to the right, scaling down will compensate the motion toward right, vice versa. Therefore, my question is, with Blend(), how to scaling up and down an image with the coordinate origin of the center of the image?  

Thanks for your help !!!!


Page Index Toggle Pages: 1