I made a simple audio visualisation sketch but cannot achieve an effect of a fading trace.
Here's a working snippet (without audio stuff, just drawing)
PGraphics pg; int x = 0,side = 400;
void setup() {
size(side, side,P2D);
pg = createGraphics(side, side, P2D);
}
void draw() {
pg.beginDraw();
pg.background(0,5);
pg.stroke(255);
float coord = sin(radians(x))*side/2;
pg.ellipse(width/2,height/2, coord, coord);
pg.endDraw();
image(pg, 0, 0); x++; if(x>=360) x = 0; }
That's how i thought i will get the effect:
1) draw a circle into off-screen, shifting x coordinate on every iteration.
2) making an image from buffer - image(pg,0,0);
3) shift that image -x, so that the freshly drawn circle appears in the same place and trace goes left.
But somehow it doesn't work. When i'm trying to shift an image, circle is being drawn in the same place without a trace.
Seems like there's something i don't understand about PGraphics.
I have some objects (spheres) in 3d space and i want them to activate (change strokeweight) when i move mouse into them. Im not good at geometry and cant imagine how should i process coordinates of my spheres to see their coordinates on the screen