Simplifying an animation to implement with blobs
in
Programming Questions
•
2 years ago
Hi all,
So I have questions about implementing a couple of aspects of my code. I'm working on a sketch that animates "dazzle camouflage" over blobs or maybe a convex hull, but at the moment I'm stuck on trying to make my code more efficient. I get how the blob detection works, but I'm stuck on animation at the moment.
Here's my code so you get an idea of the effect I'm going for. Basically, wherever it detects a blob, I want the lines to reverse direction on top of the current animated background. (I know it's small, I'm just testing...)
I'm thinking I could maybe use the blobs to create some sort of mask or alpha mask, but I'm having trouble conceptualizing what that would be like with code... Any guidance is appreciated.
-Ari
- int x1=0;
- int y1=0;
- int x2=0;
- int y2=0;
- void setup() {
- size(200,200);
- frameRate(30);
- }
- void draw() {
- stroke(255);
- strokeWeight(3);
- smooth();
- background(0);
- //draw the diagonal lines starting at x=-100,y=100 going to x=200,y=-200
- for (int i=0; i<800; i+=10){
- y1 = i;
- y2 = i;
- line(x1-100,y1+100,x2+200,y2-200);
- }
- //movement of the lines
- x1+=1;
- x2+=1;
- y1+=1;
- y2+=1;
- println(x1);
- //restart the pattern when getting to a certain number
- if (x1>10){
- x1=0;
- y1=0;
- x2=0;
- y2=0;
- }
- }
1