prth prth - 1 year ago 138
Java Question

Constant CENTER couldn't be resolved for rectMode() in Processing

public void show(PGraphics pg, float x, float y)
{
pg.rectMode(CENTER);

}


I'm calling
rectMode
with the parameter
CENTER
, which should be a constant of type
int
according to the docs, but
CENTER
couldn't be resolved.

Moreover,
META-INF/MANIFEST.MF
of the
processing.core
jar doesn't specify its version.

Answer Source

The method PGraphics.rectMode(mode) takes a mode as parameter. These modes are defined in the class PConstants.

To reference the mode CENTER, you should:

  • use the code pg.rectMode(PConstants.CENTER); and add the following import: import processing.core.PConstants;
  • keep your method as-is and make the following static import: import static processing.core.PConstants.CENTER

The syntax rectMode(CENTER) draws the image from its center point and uses the third and forth parameters of rect() to specify the image's width and height.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download