Skip to content

Commit 21ae3c7

Browse files
committed
- Ignore stuff.
- Add inexplicably missing file from **formula** sketch. - Add `peasycam` example. - Add port of Pearson's Traer Cloth demo.
1 parent 0a6e9ba commit 21ae3c7

File tree

6 files changed

+292
-0
lines changed

6 files changed

+292
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,6 @@ pip-log.txt
214214
#Mr Developer
215215
.mr.developer.cfg
216216
*.class
217+
HYPE examples/
218+
Circle_test/test.pyde
219+
test/test.pyde

HelloPeasy/HelloPeasy.pde

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import peasy.*;
2+
3+
PeasyCam cam;
4+
5+
void setup() {
6+
size(200,200,P3D);
7+
cam = new PeasyCam(this, 100);
8+
cam.setMinimumDistance(50);
9+
cam.setMaximumDistance(500);
10+
}
11+
void draw() {
12+
rotateX(-.5);
13+
rotateY(-.5);
14+
background(0);
15+
fill(255,0,0);
16+
box(30);
17+
pushMatrix();
18+
translate(0,0,20);
19+
fill(0,0,255);
20+
box(5);
21+
popMatrix();
22+
}
23+
24+

HelloPeasy/HelloPeasy.pyde

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from peasy import PeasyCam
2+
3+
4+
def setup():
5+
size(200, 200, P3D)
6+
cam = PeasyCam(this, 100)
7+
cam.setMinimumDistance(50)
8+
cam.setMaximumDistance(500)
9+
10+
def draw():
11+
rotateX(-0.5)
12+
rotateY(-0.5)
13+
background(0)
14+
fill(255, 0, 0)
15+
box(30)
16+
with pushMatrix():
17+
translate(0, 0, 20)
18+
fill(0, 0, 255)
19+
box(5)
+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import traer.physics.Particle;
2+
import traer.physics.ParticleSystem;
3+
import traer.physics.Vector3D;
4+
5+
float angnoise;
6+
float radiusnoise;
7+
float angle = -1.570796F;
8+
float radius;
9+
ParticleSystem physics;
10+
Particle[][] particles;
11+
int gridSizeX = 125;
12+
int gridSizeY = 75;
13+
int gridMidX;
14+
int gridMidY;
15+
int moverX;
16+
int moverY;
17+
18+
public void setup()
19+
{
20+
size(500, 300);
21+
smooth();
22+
frameRate(24.0F);
23+
strokeCap(4);
24+
gridMidX = (int)(gridSizeX / 2);
25+
gridMidY = (int)(gridSizeY / 2);
26+
restart();
27+
}
28+
29+
public void restart()
30+
{
31+
background(255);
32+
33+
angnoise = random(10.0F);
34+
radiusnoise = random(10.0F);
35+
36+
physics = new ParticleSystem(0.0F, 0.01F);
37+
38+
particles = new Particle[gridSizeY][gridSizeX];
39+
40+
float f1 = width / gridSizeX;
41+
float f2 = height / gridSizeY;
42+
float f3 = f1 / 2.0F;
43+
moverX = (int)(random(gridSizeX));
44+
moverY = (int)(random(gridSizeY));
45+
for (int i = 0; i < gridSizeY; i++) {
46+
for (int j = 0; j < gridSizeX; j++) {
47+
particles[i][j] = physics.makeParticle(0.2F, j * f1 + f3, i * f2, 0.0F);
48+
}
49+
}
50+
for (int i = 0; i < gridSizeX; i++) {
51+
for (int j = 1; j < gridSizeY; j++)
52+
{
53+
physics.makeSpring(particles[(j - 1)][i], particles[j][i], 8.0F, 0.5F, f2);
54+
if (i > 0) {
55+
physics.makeSpring(particles[j][(i - 1)], particles[j][i], 8.0F, 0.5F, f1);
56+
}
57+
}
58+
}
59+
}
60+
61+
public void clearBackground()
62+
{
63+
fill(255, 15.0F);
64+
noStroke();
65+
rect(0.0F, 0.0F, width, height);
66+
}
67+
68+
public void draw()
69+
{
70+
physics.tick(0.15F);
71+
if (frameCount % 100 == 0)
72+
{
73+
moverX = (int)(random(gridSizeX));
74+
moverY = (int)(random(gridSizeY));
75+
}
76+
clearBackground();
77+
stroke(0, 5.0F);
78+
79+
radiusnoise += 0.02F;
80+
radius = (noise(radiusnoise) * 400.0F + 100.0F);
81+
angnoise += 0.01F;
82+
angle += noise(angnoise) * 10.0F - 5.0F;
83+
if (angle > 360.0F) {
84+
angle -= 360.0F;
85+
}
86+
if (angle < 0.0F) {
87+
angle += 360.0F;
88+
}
89+
float f1 = radians(angle);
90+
float f2 = 250.0F + radius * cos(f1);
91+
float f3 = 150.0F + radius * sin(f1);
92+
93+
Particle localParticle = particles[moverY][moverX];
94+
localParticle.position().set(f2, f3, 0.0F);
95+
localParticle.velocity().set(150.0F, 150.0F, 0.0F);
96+
97+
noFill();
98+
for (int i = 0; i < gridSizeY; i++)
99+
{
100+
beginShape();
101+
for (int j = 0; j < gridSizeX; j++) {
102+
if (particles[i][j] != localParticle) {
103+
curveVertex(particles[i][j].position().x(), particles[i][j].position().y());
104+
}
105+
}
106+
endShape();
107+
}
108+
for (int i = 0; i < gridSizeX; i++)
109+
{
110+
beginShape();
111+
for (int j = 0; j < gridSizeY; j++) {
112+
if (particles[j][i] != localParticle) {
113+
curveVertex(particles[j][i].position().x(), particles[j][i].position().y());
114+
}
115+
}
116+
endShape();
117+
}
118+
}
119+
120+
public void mousePressed()
121+
{
122+
restart();
123+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
from traer.physics import ParticleSystem
2+
from traer.physics import Particle
3+
from traer.physics import Vector3D
4+
5+
angNoise = None
6+
radiusNoise = None
7+
angle = -1.570796
8+
radius = None
9+
physics = None
10+
particles = None
11+
gridSizeX = 125
12+
gridSizeY = 75
13+
gridMidX = (gridSizeX / 2.0)
14+
gridMidY = (gridSizeY / 2.0)
15+
moverX = None
16+
moverY = None
17+
18+
def setup():
19+
size(500, 300)
20+
smooth()
21+
frameRate(24)
22+
strokeCap(4)
23+
restart()
24+
25+
26+
def restart():
27+
background(255)
28+
angNoise = random(10)
29+
radiusNoise = random(10)
30+
physics = ParticleSystem(0, 0.01)
31+
forceWidth = width / gridSizeX
32+
forceHeight = height / gridSizeY
33+
forceWidthHalf = forceWidth / 2.0
34+
moverX = int(random(gridSizeX))
35+
moverY = int(random(gridSizeY))
36+
particles = [[physics.makeParticle(0.2,
37+
x * forceWidth + forceWidthHalf,
38+
y * forceHeight, 0)
39+
for x in range(gridSizeX)]
40+
for y in range(gridSizeY)]
41+
42+
for particleList in particles:
43+
for particle in particleList:
44+
if particleList.index(particle) == 0:
45+
physics.makeSpring(particles[particles.index(particleList) - 1][0],
46+
particle,
47+
8, 0.5, forceHeight)
48+
else:
49+
physics.makeSpring(particleList[particleList.index(particle) - 1],
50+
particle,
51+
8, 0.5, forceWidth)
52+
53+
54+
def clearBackground():
55+
fill(255, 15)
56+
noStroke()
57+
rect(0, 0, width, height)
58+
59+
60+
def draw():
61+
physics.tick(0.15)
62+
if frameCount % 100 == 0:
63+
moverX = int(random(gridSizeX))
64+
moverY = int(random(gridSizeY))
65+
clearBackground()
66+
stroke(0, 5)
67+
radiusNoise += 0.02
68+
radius = (noise(radiusNoise) * 400) + 100
69+
angNoise += 0.01
70+
angle += (noise(angNoise) * 10) - 5
71+
if angle > 360:
72+
angle -= 360
73+
if angle < 0:
74+
angle += 360
75+
forceWidth = radians(angle)
76+
forceHeight = 250 + radius * cos(forceWidth)
77+
forceWidthHalf = 150 + radius * sin(forceWidth)
78+
currentParticleList = particles[moverY]
79+
currentParticle = currentParticleList[moverX]
80+
currentParticle.position().set(forceHeight, forceWidthHalf, 0)
81+
currentParticle.velocity().set(150, 150, 0)
82+
noFill()
83+
for particleList in particles:
84+
with beginShape():
85+
for particle in particleList:
86+
if particle is not currentParticle:
87+
curveVertex(particle.position().x(),
88+
particle.position().y())
89+
for index in range(len(particles[0])): # The length of one list
90+
with beginShape():
91+
for particleList in particles:
92+
if particleList is not currentParticleList:
93+
curveVertex(particleList[index].position().x(),
94+
particleList[index].position().y())
95+
96+
def mousePressed():
97+
restart()

formula/tentacle.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from segment import Segment
2+
3+
4+
class Tentacle(object):
5+
'''A Tentacle made of Segments.
6+
'''
7+
# Factor to determine the distance between Segments.
8+
AltitudeOffset = 1
9+
10+
def __init__(self, timeOffset, palette):
11+
self.timeOffset = timeOffset
12+
self.palette = palette
13+
self.segments = [Segment(i, i, # Second `i` is tickOffset.
14+
Tentacle.AltitudeOffset * i + i,
15+
self.palette[i])
16+
for i in range(5)]
17+
18+
def update(self, time, Tick, sphereRadius):
19+
for segment in self.segments:
20+
segment.calc((time - self.timeOffset) -
21+
(segment.tickOffset * Tick),
22+
sphereRadius)
23+
# Don't try to draw the last segment.
24+
if segment.id is not len(self.segments) - 1:
25+
# Draw to the next segment.
26+
segment.drawSelf(self.segments[segment.id + 1])

0 commit comments

Comments
 (0)