Colors PGraphics设置不同的颜色模式不工作

Colors PGraphics设置不同的颜色模式不工作,colors,processing,rgb,hsb,pgraphics,Colors,Processing,Rgb,Hsb,Pgraphics,我有以下代码: 导入处理。视频。*; 进口oscP5.*; 导入netP5.*; //将数据发送到wekinator int numPixelsOrig,numPixels,boxWidth=64,boxHeight=48,numHoriz=640/boxWidth,numVert=480/boxHeight; 颜色[]downPix=新颜色[numHoriz*numVert]; 图形缓冲区; 捕获视频; OscP5-oscSend; //接收来自wekinatorino的数据 ArrayLis

我有以下代码:

导入处理。视频。*;
进口oscP5.*;
导入netP5.*;
//将数据发送到wekinator
int numPixelsOrig,numPixels,boxWidth=64,boxHeight=48,numHoriz=640/boxWidth,numVert=480/boxHeight;
颜色[]downPix=新颜色[numHoriz*numVert];
图形缓冲区;
捕获视频;
OscP5-oscSend;
//接收来自wekinatorino的数据
ArrayList blobs=新的ArrayList();
国际金额=5;
int cons1=200,cons2=150;
浮动X速度,Y速度,半径;
浮点数p1、p2、p3、p4、p5、p6;
OscP5-OSReceive;
NetAddress dest;
无效设置(){
彩色模式(RGB,100);
尺寸(600,600,P2D);
缓冲区=createGraphics(600600,P3D);
buffer.beginDraw();
缓冲区颜色模式(HSB,100);
endDraw();
String[]cameras=Capture.list();
如果(摄像机==null){
视频=新捕获(这是640480);
} 
if(cameras.length==0){
退出();
}否则{
视频=新捕获(这是640480);
video.start();
numPixelsOrig=video.width*video.height;
}
oscSend=新的OscP5(此为9000);
oscRecieve=新的OscP5(这是12000);
dest=新的NetAddress(“127.0.0.1”,6448);
}
作废提款(){
//println(blobs.size());
如果(video.available()==true){
video.read();
loadPixels();
int-boxNum=0;
int tot=箱宽*箱高;
用于(int x=0;x<640;x+=boxWidth){
对于(整数y=0;y<480;y+=boxHeight){
浮动红=0,绿=0,蓝=0;
对于(int i=0;i=0;i--){
如果(blobs.size()>amt){
去除(i);
}
}
buffer.beginDraw();
loadPixels();
对于(int x=0;x宽度| |位置x<0){
x级*=-1;
}
如果(位置y>高度| |位置y<0){
y级*=-1;
}
}
无效更新算法(浮动vx、浮动vy、浮动nr){
x级=vx;
y级=vy;
r=nr;
}
}
然后在缓冲区元素中创建一些图形。但是图形没有使用我的HSB颜色模式,结果我只看到蓝色和白色。。。 因此,如何更正代码,或将
PGraphics
元素的
colorMode
更改为HSB?

根据以下内容:

beginDraw()和endDraw()方法(参见上面的示例)是 需要设置缓冲区并完成它

因此,您应该尝试以下方法:

buffer = createGraphics(600, 600, P3D);
buffer.beginDraw();
buffer.colorMode(HSB, 100);
buffer.endDraw();
下面是要运行和比较的完整测试草图:

PGraphics buffer; 
void setup(){
   colorMode(RGB, 100);
   size(600, 600, P2D);

   //draw test gradient in RGB buffer
   noStroke();
   for(int i = 0 ; i < 10; i++){
     fill(i * 10,100,100);
     rect(0,i * 60,width,60);
   }

   buffer = createGraphics(600, 600, P3D);
   buffer.beginDraw();
     buffer.colorMode(HSB, 100);
   buffer.endDraw();

   //draw test gradient in HSB buffer
   buffer.beginDraw();
     buffer.noStroke();
     for(int i = 0 ; i < 10; i++){
       buffer.fill(i * 10,100,100);
       buffer.rect(0,i * 60,width,60);
     }
   buffer.endDraw();
   //finally render the buffer on screen, offset to the right for comparison
   image(buffer,300,0);
}
PGraphics缓冲区;
无效设置(){
彩色模式(RGB,100);
尺寸(600,600,P2D);
//在RGB缓冲区中绘制测试梯度
仰泳();
对于(int i=0;i<10;i++){
填充(i*10100100);
矩形(0,i*60,宽度,60);
}
缓冲区=createGraphics(600600,P3D);
buffer.beginDraw();
缓冲区颜色模式(HSB,100);
endDraw();
//在HSB缓冲区中绘制测试梯度
buffer.beginDraw();
buffer.noStroke();
对于(int i=0;i<10;i++){
缓冲区填充(i*10100100);
buffer.rect(0,i*60,宽度,60);
}
endDraw();
//最后在屏幕上渲染缓冲区,向右偏移以进行比较
图像(缓冲器,300,0);
}
根据以下内容:

beginDraw()和endDraw()方法(参见上面的示例)是 需要设置缓冲区并完成它

t