Skip to content

Commit ca53b1c

Browse files
committed
Move personal Artport sketches. Add: River of Souls, Web of Stars, Electron Simulator, Gravity Color, nightSky, Tarbell's B Interpretation. Style changes in Tarbell's A Interpretation.
1 parent bb6f439 commit ca53b1c

File tree

34 files changed

+1904
-43
lines changed

34 files changed

+1904
-43
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""
2+
A surface filled with one hundred medium to small sized circles. Each
3+
circle has a different size and direction, but moves at the same slow
4+
rate.
5+
6+
Display the aggregate intersections of the circles.
7+
8+
Implemented by J. Tarbell <http://levitated.net>
9+
8 April 2004
10+
Processing v.68
11+
12+
Port to Processing.py/Processing 2.0 by Ben Alkov 10 July 2014
13+
"""
14+
from disc import Disc
15+
16+
# Object array.
17+
discs = None
18+
19+
# Number of passes for SandPainters to render.
20+
Passes = 11
21+
NumDiscs = 100
22+
23+
def setup():
24+
size(700, 700, P3D)
25+
ellipseMode(RADIUS)
26+
background(64)
27+
# frameRate(30)
28+
29+
# Make 100 discs, arranged linearly.
30+
discs = [Disc(i) for i in range(NumDiscs)]
31+
32+
33+
def draw():
34+
if Disc.ShowStructure:
35+
background(64)
36+
# Render circles and intersections.
37+
for disc in discs:
38+
disc.drawSelf()
39+
40+
# Move discs.
41+
for disc in discs:
42+
disc.move()
43+
disc.render(discs, Passes)
44+
45+
46+
def keyReleased():
47+
if key == ' ':
48+
background(0)
49+
Disc.ShowStructure = not Disc.ShowStructure
50+
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
from sandpainter import SandPainter
2+
from tpoint import tpoint
3+
4+
5+
# Disc object.
6+
class Disc(object):
7+
# SandPainters.
8+
NumSands = 1
9+
10+
# Display flag.
11+
ShowStructure = True
12+
13+
def __init__(self, index):
14+
self.index = index
15+
self.x = random(width)
16+
self.y = random(height)
17+
self.velocityX = random(-1.0, 1.0)
18+
self.destRadius = 20 + random(20)
19+
self.radius = 1.0
20+
21+
# Create sand painters.
22+
self.sandpainters = [SandPainter() for _ in range(Disc.NumSands)]
23+
24+
def drawSelf(self):
25+
# stroke(64)
26+
fill(64)
27+
ellipse(self.x, self.y, self.radius, self.radius)
28+
29+
def render(self, others, passes):
30+
# Find intersecting points with all ascending discs.
31+
for disc in others:
32+
if disc.index > self.index:
33+
# Find distance to other disc.
34+
distance = dist(disc.x, disc.y, self.x, self.y)
35+
36+
# intersection test
37+
if distance < (disc.radius + self.radius):
38+
39+
# complete containment test
40+
if distance > abs(disc.radius - self.radius):
41+
42+
# find circle intersection solutions
43+
a = ((self.radius**2 - disc.radius**2 + distance**2) /
44+
(2 * distance))
45+
p2x = self.x + a * (disc.x - self.x) / distance
46+
p2y = self.y + a * (disc.y - self.y) / distance
47+
hypotenuse = sqrt(self.radius * self.radius - a * a)
48+
p3ax = p2x + hypotenuse * (disc.y - self.y) / distance
49+
p3ay = p2y - hypotenuse * (disc.x - self.x) / distance
50+
p3bx = p2x - hypotenuse * (disc.y - self.y) / distance
51+
p3by = p2y + hypotenuse * (disc.x - self.x) / distance
52+
53+
if not Disc.ShowStructure:
54+
# `p3a` and `p3b` may be identical - ignore this
55+
# case (for now).
56+
tpoint((p3ax - 1), p3ay, 255, 0.21)
57+
tpoint((p3ax + 1), p3ay, 0, 0.21)
58+
tpoint((p3bx - 1), p3by, 255, 0.21)
59+
tpoint((p3bx + 1), p3by, 0, 0.21)
60+
61+
# Draw SandPainters.
62+
for sandpainter in self.sandpainters:
63+
sandpainter.render(p3ax, p3ay, p3bx, p3by, passes)
64+
65+
def move(self):
66+
# Move radius towards destination radius.
67+
if self.radius < self.destRadius:
68+
self.radius += 0.02
69+
70+
# Add velocity to position.
71+
self.x += self.velocityX
72+
self.boundsCheck()
73+
74+
def boundsCheck(self):
75+
xIncrement = width + self.radius * 2
76+
yIncrement = height + self.radius * 2
77+
constrainedX = constrain(self.x, 0 - self.radius, width + self.radius)
78+
constrainedY = constrain(self.y, 0 - self.radius, height + self.radius)
79+
prevx = self.x
80+
prevy = self.y
81+
if constrainedX != prevx:
82+
if prevx < 0:
83+
self.x += xIncrement
84+
else:
85+
self.x -= xIncrement
86+
self.y = random(height)
87+
if constrainedY != prevy:
88+
if prevy < 0:
89+
self.y += yIncrement
90+
else:
91+
self.y -= yIncrement
92+
self.x = random(width)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from tpoint import tpoint
2+
3+
4+
# SandPainter object
5+
class SandPainter(object):
6+
def __init__(self):
7+
self.p_variable = random(1.0)
8+
self.color = random(256)
9+
self.g_variable = random(0.01, 0.1)
10+
11+
def render(self, x, y, otherX, otherY, passes):
12+
# draw painting sweeps
13+
tpoint(self.calc(x, otherX, self.p_variable),
14+
self.calc(y, otherY, self.p_variable),
15+
self.color, 0.11)
16+
maxg = 0.5
17+
self.g_variable += random(-0.050, 0.050)
18+
self.p_variable += random(-0.050, 0.050)
19+
self.g_variable = constrain(self.g_variable, -maxg, maxg)
20+
self.p_variable = constrain(self.p_variable, 0, 1.0)
21+
w = self.g_variable / 10.0
22+
for i in range(passes):
23+
tpoint(self.calc(x, otherX, self.p_variable + sin(i * w)),
24+
self.calc(y, otherY, self.p_variable + sin(i * w)),
25+
self.color, 0.1 - i / 110)
26+
tpoint(self.calc(x, otherX, self.p_variable - sin(i * w)),
27+
self.calc(y, otherY, self.p_variable - sin(i * w)),
28+
self.color, 0.1 - i / 110)
29+
30+
def calc(self, coord, otherCoord, p):
31+
return otherCoord + (coord - otherCoord) * sin(p)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Draw a (tiny) translucent square.
2+
def tpoint(x, y, sandColor, opacity):
3+
noStroke()
4+
fill(sandColor, opacity * 255)
5+
rect(x, y, 1, 1)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""
2+
A surface filled with one hundred medium to small sized circles. Each
3+
circle has a different size and direction, but moves at the same slow
4+
rate.
5+
6+
Display the aggregate intersections of the circles.
7+
8+
Implemented by J. Tarbell <http://levitated.net>
9+
8 April 2004
10+
Processing v.68
11+
12+
Port to Processing.py/Processing 2.0 by Ben Alkov 10 July 2014
13+
"""
14+
from disc import Disc
15+
16+
# Object array.
17+
discs = None
18+
19+
# Number of passes for SandPainters to render.
20+
Passes = 11
21+
NumDiscs = 100
22+
23+
def setup():
24+
size(700, 700)
25+
ellipseMode(RADIUS)
26+
smooth(4)
27+
background(255)
28+
frameRate(24)
29+
30+
# Make 100 discs, arranged linearly.
31+
discs = [Disc(i) for i in range(NumDiscs)]
32+
33+
34+
def draw():
35+
fill(255, 40)
36+
rect(0, 0, width, height)
37+
38+
# Move discs.
39+
for disc in discs:
40+
disc.move()
41+
disc.render(discs, Passes)
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
from sandpainter import SandPainter
2+
from tpoint import tpoint
3+
4+
5+
# Disc object.
6+
class Disc(object):
7+
# SandPainters.
8+
NumSands = 1
9+
10+
def __init__(self, index):
11+
self.index = index
12+
self.x = random(width)
13+
self.y = random(height)
14+
self.velocityX = random(-1.0, 1.0)
15+
# self.destRadius = 20 + random(20)
16+
self.radius = 20 + random(20)
17+
18+
# Create sand painters.
19+
self.sandpainters = [SandPainter() for _ in range(Disc.NumSands)]
20+
21+
def render(self, others, passes):
22+
# Find intersecting points with all ascending discs.
23+
for disc in others:
24+
if disc.index > self.index:
25+
# Find distance to other disc.
26+
distance = dist(disc.x, disc.y, self.x, self.y)
27+
28+
# intersection test
29+
if distance < (disc.radius + self.radius):
30+
31+
# complete containment test
32+
if distance > abs(disc.radius - self.radius):
33+
34+
# find circle intersection solutions
35+
a = ((self.radius**2 - disc.radius**2 + distance**2) /
36+
(2 * distance))
37+
p2x = self.x + a * (disc.x - self.x) / distance
38+
p2y = self.y + a * (disc.y - self.y) / distance
39+
hypotenuse = sqrt(self.radius * self.radius - a * a)
40+
p3ax = p2x + hypotenuse * (disc.y - self.y) / distance
41+
p3ay = p2y - hypotenuse * (disc.x - self.x) / distance
42+
p3bx = p2x - hypotenuse * (disc.y - self.y) / distance
43+
p3by = p2y + hypotenuse * (disc.x - self.x) / distance
44+
45+
# Draw SandPainters.
46+
for sandpainter in self.sandpainters:
47+
sandpainter.render(p3ax, p3ay, p3bx, p3by, passes)
48+
49+
def move(self):
50+
# # Move radius towards destination radius.
51+
# if self.radius < self.destRadius:
52+
# self.radius += 0.02
53+
54+
# Add velocity to position.
55+
self.x += self.velocityX
56+
self.boundsCheck()
57+
58+
def boundsCheck(self):
59+
xIncrement = width + self.radius * 2
60+
yIncrement = height + self.radius * 2
61+
constrainedX = constrain(self.x, 0 - self.radius, width + self.radius)
62+
constrainedY = constrain(self.y, 0 - self.radius, height + self.radius)
63+
prevx = self.x
64+
prevy = self.y
65+
if constrainedX != prevx:
66+
if prevx < 0:
67+
self.x += xIncrement
68+
else:
69+
self.x -= xIncrement
70+
self.y = random(height)
71+
if constrainedY != prevy:
72+
if prevy < 0:
73+
self.y += yIncrement
74+
else:
75+
self.y -= yIncrement
76+
self.x = random(width)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from tpoint import tpoint
2+
3+
4+
# SandPainter object
5+
class SandPainter(object):
6+
def __init__(self):
7+
self.p_variable = random(1.0)
8+
self.color = random(234)
9+
self.g_variable = random(0.01, 0.1)
10+
11+
def render(self, x, y, otherX, otherY, passes):
12+
# draw painting sweeps
13+
tpoint(self.calc(x, otherX, self.p_variable),
14+
self.calc(y, otherY, self.p_variable),
15+
self.color, 0.11)
16+
maxg = 0.5
17+
self.g_variable += random(-0.050, 0.050)
18+
self.p_variable += random(-0.050, 0.050)
19+
self.g_variable = constrain(self.g_variable, -maxg, maxg)
20+
self.p_variable = constrain(self.p_variable, 0, 1.0)
21+
w = self.g_variable / 10.0
22+
for i in range(passes):
23+
tpoint(self.calc(x, otherX, self.p_variable + sin(i * w)),
24+
self.calc(y, otherY, self.p_variable + sin(i * w)),
25+
self.color, 0.1 - i / 110)
26+
tpoint(self.calc(x, otherX, self.p_variable - sin(i * w)),
27+
self.calc(y, otherY, self.p_variable - sin(i * w)),
28+
self.color, 0.1 - i / 110)
29+
30+
def calc(self, coord, otherCoord, p):
31+
return otherCoord + (coord - otherCoord) * sin(p)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Draw a (tiny) translucent square.
2+
def tpoint(x, y, sandColor, opacity):
3+
noStroke()
4+
fill(sandColor, opacity * 255)
5+
rect(x, y, 1, 1)

0 commit comments

Comments
 (0)