Fill(-1,10)


#1

in below program use fill(-1,10) .may I use negative number for fill in processing?
import ddf.minim.;
import ddf.minim.analysis.
;

Minim minim;
AudioPlayer player;
AudioMetaData meta;
BeatDetect beat;
int r = 200;
float rad = 70;
void setup()
{
size(displayWidth, displayHeight);
// size(600, 400);
minim = new Minim(this);

player = minim.loadFile(“hessam.mp3”);
meta = player.getMetaData();
beat = new BeatDetect();
player.loop();
//player.play();
background(-1);
noCursor();
}

void draw()
{
float t = map(mouseX, 0, width, 0, 1);
beat.detect(player.mix);
fill(#1A1F18, 20);
noStroke();
rect(0, 0, width, height);
translate(width/2, height/2);
noFill();
fill(-225, 100);
if (beat.isOnset()) rad = rad0.9;
else rad = 70;
ellipse(0, 0, 2
rad, 2rad);
stroke(-1, 50);
int bsize = player.bufferSize();
for (int i = 0; i < bsize - 1; i+=5)
{
float x = ®cos(i2
PI/bsize);
float y = ®sin(i2*PI/bsize);
float x2 = (r + player.left.get(i)100)cos(i2PI/bsize);
float y2 = (r + player.left.get(i)100)sin(i2PI/bsize);
line(x, y, x2, y2);
}
beginShape();
noFill();
stroke(-1, 50);
for (int i = 0; i < bsize; i+=30)
{
float x2 = (r + player.left.get(i)100)cos(i2PI/bsize);
float y2 = (r + player.left.get(i)100)sin(i2PI/bsize);
vertex(x2, y2);
pushStyle();
stroke(-1);
strokeWeight(2);
point(x2, y2);
popStyle();
}
endShape();
// if (flag)
// showMeta();
}

void showMeta() {
int time = meta.length();
textSize(50);
textAlign(CENTER);
text( (int)(time/1000-millis()/1000)/60 + “:”+ (time/1000-millis()/1000)%60, -7, 21);
}

boolean flag =false;
void mousePressed() {
if (dist(mouseX, mouseY, width/2, height/2)<150) flag =!flag;
}

//

void keyPressed() {
if(key==’ ')exit();
if(key==‘s’)saveFrame("###.jpeg");
}


#2

if I can use negative number what is that meaning?
tnx


#3

Please link between crossposts. This question has already been answered on Stack Overflow here.

But taking a step back, I’d recommend putting together a shorter example sketch. Something like this:

background(-1);

This is a full program that draws a background with a specific color. What color is that? Run the program to find out!

Then try it with different values. What happens with background(-100)?

George’s answer already explained that Processing stores color values as unsigned ints, so I won’t go into much more detail here.

But I will say that I would personally stay away from using negative color arguments, for exactly the reason you’ve found: it makes the code harder to understand.


#4

thanks for your response