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 & HelpSyntax Questions › translate / blend question
Page Index Toggle Pages: 1
translate / blend question (Read 273 times)
translate / blend question
Nov 9th, 2008, 9:02pm
 
I've got a case where I want to blend an image once upright, and once rotated symmetrically 180 degrees. It works OK using "image" after the translation, but not using "blend". Do I need to manually offset either my source x,y or my destination x,y? (Which set, or both, are affected by translations?)

Quote:
void oneDrawnReflected(PImage OnePic){
  int halfX = round(screen.width / 2);
  int halfY = round(screen.height / 2);
  int randX = round(random(screen.width - OnePic.width/2));
  int randY = round(random(screen.height - OnePic.height/2));

  blend(OnePic, 0, 0, OnePic.width, OnePic.height, randX, randY, OnePic.width, OnePic.height, OVERLAY);

  pushMatrix();
  translate(screen.width, screen.height);
  rotate(PI);
  blend(OnePic, 0, 0, OnePic.width, OnePic.height, randX, randY, OnePic.width, OnePic.height, OVERLAY);
  popMatrix();
}

Re: translate / blend question
Reply #1 - Nov 10th, 2008, 9:34am
 
I am not too sure about blend(), I probably doesn't have the proper context, so I went with image(). blend() should work similarly.

This works, but doesn't give a reflection, rather an inversion:
Code:
void oneDrawnInverted(PImage OnePic)
{
image(OnePic, 0, 0, OnePic.width, OnePic.height);

pushMatrix();
translate(OnePic.width, OnePic.height * 2);
rotate(PI);
image(OnePic, 0, 0, OnePic.width, OnePic.height);
popMatrix();
}

This provides the reflection:
Code:
void oneDrawnReflected(PImage OnePic)
{
image(OnePic, 0, 0, OnePic.width, OnePic.height);

pushMatrix();
translate(0, OnePic.height);
scale(1.00, -1.00);
image(OnePic, 0, -OnePic.height, OnePic.width, OnePic.height);
popMatrix();
}
Page Index Toggle Pages: 1