문제

I'm making a processing application in which some data is interpolated in a separate thread from the main one. In this new thread, I have the line color aColor = color(255-(255*_hue[0]), 255, 255);. (the colorscheme is HSB).

This line causes the screen to flash red. It seems the line (who's variable aColor is never used) is causing some serious colour changes in the application window. There is no image being drawn or anything.

I am wondering if this is some sort of bug with processing, if there is a solution, or even if there is a workaround. Thanks

도움이 되었습니까?

해결책

Regardless of wether you use the aColor variable or not, you must be using fill() somewhere from your draw() loop.

By default fill() works globally: all subsequent shapes that will be drawn after a fill() call will have that colour.

To isolate fill() calls so they affect shapes drawn locally, not globally, you need to isolate such fill() calls within pushStyle()/popStyle() calls.

fill(192,0,0);//set global fill to red
rect(0,0,50,50);

pushStyle();
fill(0,192,0);//set local fill to green
rect(50,0,50,50);
popStyle();

rect(50,50,50,50);//draw using last global fill: red
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top