processing / processing4-javafx

JavaFX library for Processing 4
14 stars 5 forks source link

FX2D only accepts last call to tint() for a given frame #8

Open ZachSundberg opened 8 years ago

ZachSundberg commented 8 years ago

This sketch demonstrates the error:

PImage testImage;
int clicker = 200;
color[] colors = new color[8];

void setup()
{
  size(800, 100, FX2D);
  testImage = loadImage("test.png");
  imageMode(CENTER);

  colors[0] = color(0,0,0); // not used
  colors[1] = color(0,255,0);
  colors[2] = color(0,0,255);
  colors[3] = color(255,255,0);
  colors[4] = color(0,255,255);
  colors[5] = color(100,0,100);
  colors[6] = color(100,100,0);
  colors[7] = color(255,0,255);
}

void draw()
{
  clicker++;
  if (clicker>120)
  {
    for (int i=1; i<8; i++)
    {
      tint(colors[i]);
      image(testImage, i*100, 50, 50, 50);
    }
    clicker=0;
  }
}

We should see 7 differently tinted images. Instead all seven are tinted to colors[7]. Change the size call to

size(800, 100, P2D);

And the bug goes away.

ZachSundberg commented 8 years ago

Has anybody seen this?

mikeaustin commented 5 years ago

Yes, I was happy with FX2D performance, but then I implemented different colored particles, and they all only change color every few seconds, instead of every particle changing color. Guess I'll go back to P2D.