Skip to content

createGraphics not Translating #1200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
debone opened this issue Jan 8, 2016 · 3 comments
Closed

createGraphics not Translating #1200

debone opened this issue Jan 8, 2016 · 3 comments

Comments

@debone
Copy link

debone commented Jan 8, 2016

Hello,
I've found that when we create a Graphics instance, some transformations as translate and rotate do not work, while skewX for example, works.

function setup() {
  createCanvas(200, 100);
  background(200);

  pg = createGraphics(100, 100);
  pg.background(100);
  pg.noStroke();
  pg.rect( 0, 0, 50, 50);
  image(pg, 0, 0);

  translate( 100,0 ); //Translate on canvas

  ph = createGraphics(100, 100);
  ph.background(100);
  ph.noStroke();
  ph.translate( 50, 50 ); // This line should translate ph, but has no effect anywhere
  ph.rect( 0, 0, 50, 50);
  image(ph, 0, 0);
}

This code outputs this:
downloada

When the correct should be:
downloadb

@debone
Copy link
Author

debone commented Jan 18, 2016

I found the problem, the p5.dom inserts translate() and rotate() into the p5.Element prototype and createGraphics() is returning a p5.Graphics which is a children of p5.Element, so p5.dom overwrites it to the translation of the canvas element.
Maybe this is related #645 but apparently is stalled. Anyone?

@lmccart
Copy link
Member

lmccart commented Jan 24, 2016

yes, as @debone points out, the translate() and rotate() properties are getting overridden by the p5.dom library because the p5.Graphics object extends p5.Element.

my suggestion would be that we remove the p5.Element.rotate() and p5.Element.translate() methods since these are already supported in the p5.Element.style() method.
http://p5js.org/reference/#p5.Element/style

here's the thread where these were added and some discussion around it.
#745

sound ok? @shiffman @futuremarc

@shiffman
Copy link
Member

shiffman commented Feb 2, 2016

Sorry to be slow here, but yes agree that these should be removed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants