告诉我"fill(-1,x)"中第一个数字(-1)在处理中的作用是什么?
tell me what is the role of first number(-1) in "fill(-1,x)" in processing?
你能告诉我下面代码中第一个数字(-1)在处理中的作用是什么吗?
请在下面找到简短的可执行代码。请注意,在处理中执行此代码后,会出现一个圆圈和几条线。并且它们会通过麦克风检测到的声级发生变化。
"import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
BeatDetect beat;
AudioInput player;
int r = 200;
float rad = 70;
void setup()
{
size(displayWidth, displayHeight);
minim = new Minim(this);
player = minim.getLineIn();
beat = new BeatDetect();
background(-1);
}
void draw()
{
beat.detect(player.mix);
fill(#1A1F18, 20);
noStroke();
rect(0, 0, width, height);
translate(width/2, height/2);
noFill();
fill(-1, 200);
if (beat.isOnset()) rad = rad*1.1;
else rad = 70;
ellipse(0, 0, 2*rad, 2*rad);
stroke(-1, 50);
int bsize = player.bufferSize();
for (int i = 0; i < bsize - 1; i+=5)
{
float x = (r)*cos(i*2*PI/bsize);
float y = (r)*sin(i*2*PI/bsize);
float x2 = (r + player.left.get(i)*1000)*cos(i*2*PI/bsize);
line(x, y, x2, y2);
}
}"
此致
它与 fill(255,50)
相同,只需要少输入一个字符 fill(-1,50);
(将其视为 shorthand)。
color type is stored as an unsigned integer.
这里有一个基本的草图来说明这一点:
void setup(){
println(color(254,254,254));
println(color(255,254,254));
println(color(255,255,254));
println(color(255,255,255));
println(color(255));
}
void draw(){
//same as fill(255,50);
fill(-1,50);
rect(0,0,width,height);
line(mouseX,mouseY,pmouseX,pmouseY);
}
注意控制台中打印的值。
另请注意,当您移动鼠标时,您会看到轨迹。
这是因为绘制了一个 alpha 设置为 50 的白色(color(255)
或 color(-1)
)矩形,仅部分清除了缓冲区。
你能告诉我下面代码中第一个数字(-1)在处理中的作用是什么吗?
请在下面找到简短的可执行代码。请注意,在处理中执行此代码后,会出现一个圆圈和几条线。并且它们会通过麦克风检测到的声级发生变化。
"import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
BeatDetect beat;
AudioInput player;
int r = 200;
float rad = 70;
void setup()
{
size(displayWidth, displayHeight);
minim = new Minim(this);
player = minim.getLineIn();
beat = new BeatDetect();
background(-1);
}
void draw()
{
beat.detect(player.mix);
fill(#1A1F18, 20);
noStroke();
rect(0, 0, width, height);
translate(width/2, height/2);
noFill();
fill(-1, 200);
if (beat.isOnset()) rad = rad*1.1;
else rad = 70;
ellipse(0, 0, 2*rad, 2*rad);
stroke(-1, 50);
int bsize = player.bufferSize();
for (int i = 0; i < bsize - 1; i+=5)
{
float x = (r)*cos(i*2*PI/bsize);
float y = (r)*sin(i*2*PI/bsize);
float x2 = (r + player.left.get(i)*1000)*cos(i*2*PI/bsize);
line(x, y, x2, y2);
}
}"
此致
它与 fill(255,50)
相同,只需要少输入一个字符 fill(-1,50);
(将其视为 shorthand)。
color type is stored as an unsigned integer.
这里有一个基本的草图来说明这一点:
void setup(){
println(color(254,254,254));
println(color(255,254,254));
println(color(255,255,254));
println(color(255,255,255));
println(color(255));
}
void draw(){
//same as fill(255,50);
fill(-1,50);
rect(0,0,width,height);
line(mouseX,mouseY,pmouseX,pmouseY);
}
注意控制台中打印的值。
另请注意,当您移动鼠标时,您会看到轨迹。
这是因为绘制了一个 alpha 设置为 50 的白色(color(255)
或 color(-1)
)矩形,仅部分清除了缓冲区。