Using getPixel and setPixel give me strange result

Testing some pixel effect (lights simulating palette shift pixel by pixel) I’ve faced some strange behavior.
This is a test code that should point out the problem:

  for(int y=10;y<60;y+=1){
    int c=0;
    for(int x=10;x<60;x+=1){
        //take the color of the pixel before
        c=game.display.getPixel(x,y);//<< toggle this line to see the difference
       //next color
        c=(c+1)%16;
       //draw it
        game.display.drawPixel(x+1,y,c);
    }
}

Basically here I’m taking the color of the pixel in the row, and then use the next color to draw the next pixel. So I’m expecting something like this:

instead I’ve this:

Can anybody tell me where’s my error?

1 Like

Can you change the resolution and try again? I think problem is simulator

2 Likes

Bug in simulator…

2 Likes

Is something complex to fix? Does it also affect real pokitto?

No, its an easy fix. Yes affects Pokitto as well. It is not a bad thing, just reading nibbles (4 bits) in wrong order

Again, a new release of the lib that opens up this stuff is coming by Sunday. Then you can easily solve this kind of things also. Just wait a little bit

edit: by sunday I mean latest. Probably sooner

1 Like

Ok, just curious.
That’s a great new! Looking at the code will help a lot to get how things are done. Thanks for sharing.

1 Like

Now you can take a look yourself at the problem if you want. Its probably something very simple

Finally I’ve some time to spent on this issue. Thanks @jonne you really point me on the right direction, it was an easy fix with your suggestion. Just made a small PR to your repo.

Now I can experiment more with my poor texture light system:

1 Like

Merged. Thanks Filippo!

1 Like