Skip to content

Y-dimension origin and scaling differs between default/FX2D and P2D/P3D renderer #11

Open
@ghost

Description

@ghost

Description

When drawing 2d objects origin and scaling in y-dimension behaves differently depending on the renderer used.

Expected Behaviour

An object drawn at (0,0) should always be drawn at the top left corner of the window. An object drawn at (width, height) should always be drawn at the bottom right corner.

Current Behaviour

Using the default or the FX2D renderer the behaviour is correct.

Using the P2D or the P3D renderer objects drawn at (0,0) are drawn outside the window above the top left corner. An object drawn at (width, height) is drawn a little under the bottom right corner. So both the origin and the scale are incorrect. I don't expect this behaviour to be pixel perfect, because this isn't possible with OpenGL renderers. But the offset is about 30 pixels, which is a lot.

Steps to Reproduce

void settings() {
  size(400, 300, P3D);
}

void draw(){
  rect(0, 0, 50, 50);
  rect(width-100, 50, 50, 50);
  rect(width-50, height-50, 50, 50);
  rect(50, height-100, 50, 50);
}

renderer scaling problem

My Environment

Processing version: 3.3.6
Operating system: Windows 10 Pro (Version 1703, build 15063.786)

Possible Causes / Solutions

Translating and scaling provides a workaround:

translate(0, 29);
scale(1, height/(height+33.0));

Translation and scaling values are from observations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedMany hands make light work. Please help!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions