Skip to content

Commit bb6f439

Browse files
committed
Tarbell Number 3 now 100% more runnable; Java version complete.
1 parent 64af5a1 commit bb6f439

File tree

4 files changed

+53
-47
lines changed

4 files changed

+53
-47
lines changed

Whitney Artport - (Software) Structures/#003/A/Interpretation/Number_003_A_Tarbell/Number_003_A_Tarbell.pde

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ Disc[] discs;
2020
// initialization
2121
void setup()
2222
{
23-
size(500, 500);
23+
size(500, 500, P2D);
24+
colorMode(RGB,255);
2425
ellipseMode(RADIUS);
2526
background(0);
27+
frameRate(30);
2628

2729
// make some discs
2830
discs = new Disc[num];
@@ -95,7 +97,7 @@ class Disc
9597
}
9698

9799
void drawSelf() {
98-
stroke(128, 50);
100+
stroke(0, 50);
99101
noFill();
100102
ellipse(x, y, r, r);
101103
}
@@ -176,7 +178,6 @@ class Disc
176178
PxRider() {
177179
t = random(TAU);
178180
vt = 0.0;
179-
mycharge = 64.0;
180181
}
181182

182183
void move(float x, float y, float r) {
@@ -193,14 +194,14 @@ class Disc
193194
// draw
194195
float px = x + r * cos(t);
195196
float py = y + r * sin(t);
196-
// color c = get(int(px),int(py));
197-
loadPixels();
198-
color c = pixels[int(px) + int(py) * height];
197+
color c = get(int(px),int(py));
198+
// loadPixels();
199+
// color c = pixels[int(px) + int(py) * height];
199200
if (brightness(c) > 48) {
200201
glowpoint(px, py);
201202
mycharge = 164;
202203
} else {
203-
stroke(int(mycharge));
204+
stroke(mycharge);
204205
point(px, py);
205206
mycharge *= 0.98;
206207
}
@@ -227,9 +228,9 @@ void tpoint(int x1, int y1, color myc, float a)
227228
int r, g, b;
228229
color c;
229230

230-
// c = get(x1, y1);
231-
loadPixels();
232-
c = pixels[x1 + y1 * height];
231+
c = get(x1, y1);
232+
// loadPixels();
233+
// c = pixels[x1 + y1 * height];
233234

234235
r = int(red(c) + (red(myc) - red(c)) * a);
235236
g = int(green(c) + (green(myc) - green(c)) * a);

Whitney Artport - (Software) Structures/#003/A/Interpretation/Number_003_A_Tarbell/Number_003_A_Tarbell.pyde

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,34 @@
1111
1212
Port to Processing.py/Processing 2.0 by Ben Alkov 16 June 2014
1313
"""
14+
from disc import Disc
15+
1416
num = 100
15-
time = 0
1617

1718
# Object array.
18-
# Disc[] discs
19+
discs = []
1920

2021

2122
# Initialization.
2223
def setup():
2324
size(500, 500)
2425
colorMode(RGB, 255)
25-
ellipseMode(CENTER_RADIUS)
26+
ellipseMode(RADIUS)
2627
background(0)
28+
frameRate(30)
2729

2830
# Make some discs.
29-
discs = Disc[num]
3031
# Arrange in anti - collapsing circle.
31-
for i in range(numi):
32-
fx = 0.4 * width * cos(TWO_PI * i / num)
33-
fy = 0.4 * width * sin(TWO_PI * i / num)
32+
for i in range(num):
33+
fx = 0.4 * width * cos(TAU * i / num)
34+
fy = 0.4 * width * sin(TAU * i / num)
3435
x = random(width / 2) + fx
3536
y = random(width / 2) + fy
3637
r = 5 + random(45)
3738
bt = 1
3839
if random(100) < 50:
3940
bt = -1
40-
discs[i] = Disc(i, x, y, bt * fx / 1000.0, bt * fy / 1000.0, r)
41+
discs.append(Disc(i, x, y, bt * fx / 1000.0, bt * fy / 1000.0, r))
4142

4243

4344
# Main.
@@ -50,22 +51,3 @@ def draw():
5051
disc.drawSelf()
5152
disc.render(discs)
5253
disc.renderPxRiders()
53-
54-
55-
# Methods.
56-
def glowpoint(px, py):
57-
for i in range(-2, 3):
58-
for j in range(-2, 3):
59-
a = (0.8 - i**2 * 0.1) - j**2 * 0.1
60-
tpoint(px + i, py + j, '#FFFFFF', a)
61-
62-
63-
def tpoint(x1, y1, myc, a):
64-
# Place translucent point.
65-
c = get(x1, y1)
66-
r = red(c) + (red(myc) - red(c)) * a
67-
g = green(c) + (green(myc) - green(c)) * a
68-
b = blue(c) + (blue(myc) - blue(c)) * a
69-
nc = color(r, g, b)
70-
stroke(nc)
71-
point(x1, y1)

Whitney Artport - (Software) Structures/#003/A/Interpretation/Number_003_A_Tarbell/disc.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1+
from pxrider import PxRider
2+
3+
14
# Disc object.
25
class Disc(object):
36
def __init__(self, index, centerX, centerY, vx, vy, destinationRadius):
47
# Identifier.
5-
self.id = index
8+
self.index = index
69

710
# Position.
811
self.centerX = centerX
912
self.centerY = centerY
1013

1114
# Velocity.
12-
vx = vx
13-
vy = vy
15+
self.vx = vx
16+
self.vy = vy
1417

1518
# Radius.
1619
self.destinationRadius = destinationRadius
1720
self.radius = 0
1821

1922
# Create pixel riders.
2023
maxRiders = 40
21-
pxRiders = [PxRider() for _ in range(maxRiders)]
24+
self.pxRiders = [PxRider() for _ in range(maxRiders)]
2225

2326
def drawSelf(self):
2427
stroke(0, 50)
@@ -55,9 +58,9 @@ def render(self, discs):
5558

5659
def move(self):
5760
# Add velocity to position.
58-
self.centerX += vx
59-
self.centerY += vy
60-
bound = width + self.radius + self.radius
61+
self.centerX += self.vx
62+
self.centerY += self.vy
63+
bound = width + self.radius * 2
6164

6265
# Bound check.
6366
if self.centerX + self.radius < 0:
@@ -74,5 +77,5 @@ def move(self):
7477
self.radius += 0.1
7578

7679
def renderPxRiders(self):
77-
for pxRider in pxRiders:
80+
for pxRider in self.pxRiders:
7881
pxRider.move(self.centerX, self.centerY, self.radius)

Whitney Artport - (Software) Structures/#003/A/Interpretation/Number_003_A_Tarbell/pxrider.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ def __init__(self):
66
self.deltaV = 0.0
77
self.charge = 0
88

9+
# Methods.
910
def move(self, x, y, radius):
1011
# Add velocity to theta.
1112
self.theta = (self.theta + self.deltaV + PI) % TAU - PI
@@ -18,11 +19,30 @@ def move(self, x, y, radius):
1819
# Draw.
1920
px = x + radius * cos(self.theta)
2021
py = y + radius * sin(self.theta)
21-
color = get(px, py)
22+
# color = get(px, py)
23+
loadPixels()
24+
color = pixels[int(px) + int(py) * height]
2225
if brightness(color) > 48:
23-
glowpoint(px, py)
26+
self.glowpoint(px, py)
2427
self.charge = 164
2528
else:
2629
stroke(self.charge)
2730
point(px, py)
2831
self.charge *= 0.98
32+
33+
def tpoint(x, y, myColor, trans):
34+
# Place translucent point.
35+
# color = get(x, y)
36+
loadPixels()
37+
color = pixels[x + y * height]
38+
r = red(color) + (red(myColor) - red(color)) * trans
39+
g = green(color) + (green(myColor) - green(color)) * trans
40+
b = blue(color) + (blue(myColor) - blue(color)) * trans
41+
stroke(color(r, g, b))
42+
point(x, y)
43+
44+
def glowpoint(px, py):
45+
for i in range(-2, 3):
46+
for j in range(-2, 3):
47+
a = (0.8 - i**2 * 0.1) - j**2 * 0.1
48+
self.tpoint(px + i, py + j, '#FFFFFF', a)

0 commit comments

Comments
 (0)