咨询Processing中fill(-1,x)及相关代码内第一个参数-1的作用
fill(-1, x) in Processing Great questions—let’s break this down clearly:
1. What does -1 do in fill(-1, x)?
In Processing, the fill() function defines the color used to fill shapes. When you pass -1 as the first argument in a two-parameter call:
- By default, Processing uses an RGB color mode where values range from 0 (black) to 255 (white) for each channel.
-1gets interpreted as 255 (pure white) here. This quirk comes from Java (the language under Processing’s hood): negative integers wrap around when converted to unsigned bytes, and-1in binary is all 1s, which equals 255 as an 8-bit unsigned value.- The second parameter
xcontrols the fill’s alpha (transparency), where 0 is fully see-through and 255 is completely opaque.
In short: fill(-1, x) is exactly the same as writing fill(255, x)—it sets the fill color to white with an opacity level of x.
2. The -1 in your audio visualization code
Looking at your Minim-based code, that -1 is doing the same core job: setting the fill to pure white. The second parameter (which is almost certainly tied to the microphone’s detected volume) adjusts how transparent that white fill is based on audio input.
For example:
- When the volume is high, the alpha value might jump to 255, making your circle and lines bright, fully opaque white.
- When the volume drops, the alpha decreases, causing the shapes to fade into the background.
This creates the dynamic, volume-reactive visual effect you’re seeing—perfect for tying your graphics to sound!
内容的提问来源于stack exchange,提问作者Armin Afsharian Zadeh

