Loading...
Logo
Processing Forum

noSmooth() with P2D?

in Programming Questions  •  2 years ago  
Is it possible to disable smoothing with the P2D renderer? E.g., this code (which should switch between smooth/nosmooth on mouse click) never uses nearest-neighbor:

PImage sprite;

void setup()
{
  size(256,256,P2D);
  background(0);
 
  sprite = loadImage("test.png");
}

boolean smoothing = true;

void draw()
{
  background(0);
 
  if(smoothing)
    smooth();
  else
    noSmooth();
 
  image(sprite,0,0,mouseX, mouseY);
}

void mouseClicked()
{
  smoothing = !smoothing;
}

It works fine with the JAVA2D renderer, but for what I'm doing the Java2D render is much too slow.