-
Notifications
You must be signed in to change notification settings - Fork 0
/
Repellor.pde
147 lines (129 loc) · 4.06 KB
/
Repellor.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
class Repellor {
Particle p;
float xPos, yPos;
float size;
float alphaval;
float time;
boolean alive;
float count;
float div1, div2, m1, m2;
color colour;
PShape ring;
PImage[] video;
PImage disk;
PVector prevPos;
float diff;
float buffer;
Repellor(float xPos, float yPos, color colour, PShape ring) {
this.ring = ring;
prevPos = new PVector(0,0);
out.shapeMode(CENTER);
count = random(0, 360);
div1 = random(5, 2);
div2 = random(5, 2);
m1 = random(0.1, 0.5);
m2 = random(0.1, 0.5);
alive = true;
alphaval = 255;
time = 0.5;
size = 200;
this.xPos = xPos;
this.yPos = yPos;
this.colour = colour;
p = physics.makeParticle(1, xPos, yPos, size+10);
p.makeFixed();
disk = loadImage("Disk.png");
video = new PImage[450];
for (int i = 0; i < video.length; i ++){
video[i] = loadImage("LineLoop/" + i + ".png");
}
}
void create() {
out.pushMatrix();
out.pushStyle();
out.noFill();
out.strokeWeight(10);
out.stroke(255);
mandala(p.position().x(), p.position().y(), size*2);
out.popStyle();
out.popMatrix();
}
void mandala(float x, float y, float radius){
//DEBUG
stroke(255);
text(abs(map(prevPos.x, 0, out.width, 0, video.length)), 10, 10);
text(abs(map(x, 0, out.width, 0, video.length)), 10, 25);
//END DEBUG
out.pushMatrix();
out.imageMode(CENTER);
bufferCheck(x,y,25);
out.image(video[(int)map(x - buffer, 0, out.width, 0, video.length*2) % video.length],out.width/2, out.height/2);
//out.blendMode(MULTIPLY);
out.popMatrix();
}
void bufferCheck(float x, float y, float thresh){
if(abs(map(x, 0, out.width, 0, video.length) - map(prevPos.x, 0, out.width, 0, video.length)) < thresh ){
buffer = map(x, 0, out.width, 0, video.length) - map(prevPos.x, 0, out.width, 0, video.length);
}
}
//void mandala(float x, float y, float radius, float wiggle, int pNum){
// out.pushMatrix();
// out.translate(x,y);
// out.rotate(frameCount*0.01);
// for (int i = 0; i < pNum; i ++){
// out.stroke(map(i,0,pNum,200,150),255,255,255);
// //rotate(frameCount*0.01);
// out.point(sin((TWO_PI/pNum)*i) * (radius + (cos((TWO_PI/pNum/2)*frameCount*0.1))* wiggle),
// cos((TWO_PI/pNum)*i) * (radius + (cos((TWO_PI/pNum/2)*frameCount*0.1))* wiggle));
// }
// out.rotate(HALF_PI+(frameCount*0.001));
// for (int i = 0; i < pNum; i ++){
// out.stroke(map(i,0,pNum,150,200),255,255,255);
// out.point((sin((TWO_PI/pNum)*i) * (radius + (sin((TWO_PI/pNum/2)*((frameCount*0.12)))* wiggle))),
// (cos((TWO_PI/pNum)*i) * (radius + (sin((TWO_PI/pNum/2)*((frameCount*0.12)))* wiggle))));
// }
// out.popMatrix();
//}
void update() {
if (alphaval > 0) {
alphaval -= time;
} else {
//physics.removeParticle(p);
alive = false;
}
//p.position().setX(p.position().x()+(sin(radians(count * m1)) /div1) );
//p.position().setY(p.position().y()+(cos(radians(count * m2)) /div2) );
p.position().setX(lerp (p.position().x(), depthPlane.t.x + depthPlane.leftRight, 0.1));
p.position().setY(lerp (p.position().y(), depthPlane.t.y + depthPlane.upDown, 0.1));
//count += 0.00000000000000001;
}
void run() {
create();
update();
}
void dashedCircle(float radius, int dashWidth, int dashSpacing) {
int steps = 200;
int dashPeriod = dashWidth + dashSpacing;
boolean lastDashed = false;
for (int i = 0; i < steps; i++) {
boolean curDashed = (i % dashPeriod) < dashWidth;
if (curDashed && !lastDashed) {
out.beginShape();
}
if (!curDashed && lastDashed) {
out.endShape();
}
if (curDashed) {
float theta = map(i, 0, steps, 0, TWO_PI);
out.vertex(cos(theta) * radius, sin(theta) * radius);
}
lastDashed = curDashed;
}
if (lastDashed) {
out.endShape();
}
}
float getDistanceSq(float x1, float x2, float y1, float y2) {
return sq(x2-x1) + sq(y2-y1);
}
}