Skip to content

Commit 8d10608

Browse files
committed
Updates for p5py 0401 removal of autoglobal and some cosmetic fixes.
Change Number_003_A_Hodgin to re-use `setup()` instead of having a separate `init()`. Closer to fixing gravity_color.
1 parent 0dee61a commit 8d10608

File tree

33 files changed

+314
-337
lines changed

33 files changed

+314
-337
lines changed

(Software) Structures personal interpretations/Number_003_A_Alkov/Number_003_A_Alkov.pyde

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
'''
2-
Modified
3-
Structure 3
4-
5-
A surface filled with one hundred medium to small sized circles.
6-
Each circle has a different size and direction, but moves at the
7-
same slow rate.
8-
Display:
9-
A. The instantaneous intersections of the circles
10-
B. The aggregate intersections of the circles
11-
12-
Implemented by Casey Reas <http://groupc.net>
13-
8 March 2004
14-
Processing v.68 <http://processing.org>
15-
2+
Modified
3+
Structure 3
4+
5+
A surface filled with one hundred medium to small sized circles.
6+
Each circle has a different size and direction, but moves at the
7+
same slow rate.
8+
Display:
9+
A. The instantaneous intersections of the circles
10+
B. The aggregate intersections of the circles
11+
12+
Implemented by Casey Reas <http://groupc.net>
13+
8 March 2004
14+
Processing v.68 <http://processing.org>
1615
'''
1716
from circle import Circle
1817

@@ -21,6 +20,7 @@ circles = None
2120

2221

2322
def setup():
23+
global circles
2424
size(1280, 720, P3D)
2525
# random x, y based on index value
2626
circles = [Circle(random(width), height / NumCircles * i,

(Software) Structures personal interpretations/Number_003_B_01_Alkov/Number_003_B_01_Alkov.pyde

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
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.
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.
55
6-
Display the aggregate intersections of the circles.
6+
Display the aggregate intersections of the circles.
77
8-
Implemented by J. Tarbell <http://levitated.net>
9-
8 April 2004
10-
Processing v.68
8+
Implemented by J. Tarbell <http://levitated.net>
9+
8 April 2004
10+
Processing v.68
1111
12-
Port to Processing.py/Processing 2.0 by Ben Alkov 10 July 2014
13-
"""
12+
Port to Processing.py/Processing 2.0 by Ben Alkov 10 July 2014
13+
'''
1414
from disc import Disc
1515

1616
# Object array.
@@ -21,6 +21,7 @@ Passes = 11
2121
NumDiscs = 100
2222

2323
def setup():
24+
global discs
2425
size(700, 700, P3D)
2526
ellipseMode(RADIUS)
2627
background(64)

(Software) Structures personal interpretations/Number_003_B_02_Alkov/Number_003_B_02_Alkov.pyde

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
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.
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.
55
6-
Display the aggregate intersections of the circles.
6+
Display the aggregate intersections of the circles.
77
8-
Implemented by J. Tarbell <http://levitated.net>
9-
8 April 2004
10-
Processing v.68
8+
Implemented by J. Tarbell <http://levitated.net>
9+
8 April 2004
10+
Processing v.68
1111
12-
Port to Processing.py/Processing 2.0 by Ben Alkov 10 July 2014
13-
"""
12+
Port to Processing.py/Processing 2.0 by Ben Alkov 10 July 2014
13+
'''
1414
from disc import Disc
1515

1616
# Object array.
@@ -22,6 +22,7 @@ Passes = 11
2222
NumDiscs = 100
2323

2424
def setup():
25+
global discs
2526
size(700, 700)
2627
ellipseMode(RADIUS)
2728
smooth(4)

Contributed Libraries in Python/punktiert/Behavior_BSeek.pyde

+13-21
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,27 @@
33
# This library is developed through and for an architectural context.
44
# Based on my teaching experiences over the past couple years.
55
# (c) 2012 Daniel Köhler, [email protected]
6-
76
# here: seek (part of flocking) function as behavior
8-
97
from punktiert.math import Vec
108
from punktiert.physics import VPhysics, VParticle, BCollision, BSeek
119

10+
1211
# world object
1312
world = None
1413
mouse = None
15-
1614
# number of particles in the scene
17-
amount = 100
15+
Amount = 100
1816

1917

2018
def setup():
19+
global world, mouse
2120
size(800, 600)
2221
smooth()
2322
fill(0, 255)
24-
25-
global world, mouse
2623
world = VPhysics()
2724
mouse = Vec(width * 0.5, height * 0.5)
28-
2925
# world.setfriction(.99f)
30-
31-
for i in range(amount):
26+
for i in range(Amount):
3227
# val for arbitrary radius
3328
rad = random(2, 20)
3429
# vector for position
@@ -57,16 +52,13 @@ def drawRectangle(p):
5752
rad = p.getRadius()
5853
deform = map(deform, 0, 1.5, rad, 0)
5954
deform = max(rad * 0.2, deform)
60-
6155
rotation = p.getVelocity().heading()
62-
63-
pushMatrix()
64-
translate(p.x(), p.y())
65-
rotate(HALF_PI * 0.5 + rotation)
66-
beginShape()
67-
vertex(-rad, +rad)
68-
vertex(deform, deform)
69-
vertex(rad, -rad)
70-
vertex(-deform, -deform)
71-
endShape(CLOSE)
72-
popMatrix()
56+
with pushMatrix():
57+
translate(p.x(), p.y())
58+
rotate(HALF_PI * 0.5 + rotation)
59+
beginShape()
60+
vertex(-rad, +rad)
61+
vertex(deform, deform)
62+
vertex(rad, -rad)
63+
vertex(-deform, -deform)
64+
endShape(CLOSE)

Contributed Libraries in Python/toxic/DLASpiral.pyde

+16-11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ isOctreeVisible = True
99

1010

1111
def setup():
12+
global dla
13+
global listener
1214
size(640, 480, P3D)
1315
# compute spiral key points (every 45 degrees)
1416
points = []
@@ -26,7 +28,6 @@ def setup():
2628
guides = DLAGuideLines()
2729
guides.addCurveStrip(Spline3D(points).computeVertices(8))
2830
# create DLA 3D simulation space 128 units wide (cubic)
29-
global dla
3031
dla = DLA(128)
3132
# use default configuration
3233
dla.setConfig(DLAConfiguration())
@@ -35,7 +36,6 @@ def setup():
3536
# set leaf size of octree
3637
dla.getParticleOctree().setMinNodeSize(1)
3738
# add a listener for simulation events
38-
global listener
3939
listener = DLAListener()
4040
dla.addListener(listener)
4141
textFont(createFont("SansSerif", 12))
@@ -81,10 +81,10 @@ def drawOctree(node, doShowGrid, col):
8181
def drawBox(node):
8282
noFill()
8383
stroke(0, 24)
84-
pushMatrix()
85-
translate(node.x, node.y, node.z)
86-
box(node.getSize())
87-
popMatrix()
84+
with pushMatrix():
85+
## BROKEN - Can't convert args to float
86+
translate(node.x, node.y, node.z)
87+
box(node.getSize())
8888

8989

9090
def keyPressed():
@@ -96,16 +96,21 @@ def keyPressed():
9696
if key == 'o':
9797
isOctreeVisible = not isOctreeVisible
9898
if key == 's':
99-
listener.save()
99+
listener.save(dla)
100100

101101

102102
class DLAListener(DLAEventAdapter):
103103

104+
def __init__(self):
105+
pass
106+
104107
# self method will be called when all guide segments
105108
# have been processed
106-
def dlaAllSegmentsProcessed(dla):
109+
@staticmethod
110+
def dlaAllSegmentsProcessed(thisDLA):
107111
println("all done, saving...")
108-
save()
112+
save(thisDLA)
109113

110-
def save():
111-
dla.save(sketchPath("spiral.dla"), False)
114+
@staticmethod
115+
def save(thisDLA):
116+
thisDLA.save(sketchPath("spiral.dla"), False)

Demos/Graphics/PBallDroppings/PBallDroppings.pyde

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
'''
22
u or U undo
33
e or E delete picked vertex
44
r frequency range -
@@ -13,7 +13,7 @@ b or B move ball "emitter"
1313
p toggle pause
1414
0 reset all variables
1515
' ' reset balls & lines
16-
"""
16+
'''
1717

1818
import config
1919
from java.util import Vector
@@ -30,6 +30,7 @@ def setup():
3030

3131

3232
def draw():
33+
global closestBounceLine
3334
background(0)
3435
config.newball_xlag += (config.newball_x - config.newball_xlag) / 10.0
3536
config.newball_ylag += (config.newball_y - config.newball_ylag) / 10.0
@@ -313,6 +314,7 @@ def resetBounceLines():
313314

314315

315316
def deletePickedVertex():
317+
global closestBounceLine
316318
if (config.closestBounceLineDistance <
317319
config.closestBounceLine_maxPickingDistance):
318320
# Register undoable.

HYPE examples/hype imports.py

+16-51
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,18 @@
1-
from hype.core.util import H
2-
from hype.core.util import HBundle
3-
from hype.core.util import HCapture
4-
from hype.core.util import HColors
5-
from hype.core.util import HConstants
6-
from hype.core.behavior import HBehavior
7-
from hype.core.behavior import HBehaviorRegistry
8-
from hype.core.behavior import HTrigger
9-
from hype.core.collection import HLinkedHashSet
10-
from hype.core.collection import HLinkedList
11-
from hype.core.collection import HNode
1+
from hype.core.util import H, HBundle, HCapture, HColors, HConstants
2+
from hype.core.behavior import HBehavior, HBehaviorRegistry, HTrigger
3+
from hype.core.collection import HLinkedHashSet, HLinkedList, HNode
124
from hype.core.colorist import HColorist
13-
from hype.core.drawable import HDrawable
14-
from hype.core.drawable import HDrawable3D
15-
from hype.core.drawable import HStage
16-
from hype.core.interfaces import HCallback
17-
from hype.core.interfaces import HDirectable
18-
from hype.core.interfaces import HHittable
19-
from hype.core.interfaces import HImageHolder
20-
from hype.core.interfaces import HLocatable
21-
from hype.core.interfaces import HRotatable
5+
from hype.core.drawable import HDrawable, HDrawable3D, HStage
6+
from hype.core.interfaces import (HCallback, HDirectable, HHittable,
7+
HImageHolder, HLocatable, HRotatable)
228
from hype.core.layout import HLayout
23-
from hype.core.util import HMath
24-
from hype.core.util import HMouse
25-
from hype.core.util import HVector
26-
from hype.core.util import HWarnings
27-
from hype.extended.behavior import HFollow
28-
from hype.extended.behavior import HMagneticField
29-
from hype.extended.behavior import HOscillator
30-
from hype.extended.behavior import HRandomTrigger
31-
from hype.extended.behavior import HRotate
32-
from hype.extended.behavior import HSwarm
33-
from hype.extended.behavior import HTimer
34-
from hype.extended.behavior import HTween
35-
from hype.extended.behavior import HVelocity
36-
from hype.extended.colorist import HColorField
37-
from hype.extended.colorist import HColorPool
38-
from hype.extended.colorist import HColorTransform
39-
from hype.extended.colorist import HPixelColorist
40-
from hype.extended.drawable import HBox
41-
from hype.extended.drawable import HCanvas
42-
from hype.extended.drawable import HEllipse
43-
from hype.extended.drawable import HGroup
44-
from hype.extended.drawable import HImage
45-
from hype.extended.drawable import HPath
46-
from hype.extended.drawable import HRect
47-
from hype.extended.drawable import HShape
48-
from hype.extended.drawable import HSphere
49-
from hype.extended.drawable import HText
50-
from hype.extended.layout import HGridLayout
51-
from hype.extended.layout import HShapeLayout
52-
from hype.extended.util import HDrawablePool
53-
from hype.extended.util import HVertex
9+
from hype.core.util import HMath, HMouse, HVector, HWarnings
10+
from hype.extended.behavior import (HFollow, HMagneticField, HOscillator,
11+
HRandomTrigger, HRotate, HSwarm, HTimer,
12+
HTween, HVelocity)
13+
from hype.extended.colorist import (HColorField, HColorPool, HColorTransform,
14+
HPixelColorist)
15+
from hype.extended.drawable import (HBox, HCanvas, HEllipse, HGroup, HImage,
16+
HPath, HRect, HShape, HSphere, HText)
17+
from hype.extended.layout import HGridLayout, HShapeLayout
18+
from hype.extended.util import HDrawablePool, HVertex

OrbitingSquares_HYPE/OrbitingSquares_HYPE.pyde

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# add_library('hype')
22
'''
3-
1. One hundred `HRect`
4-
2. Of randomly-selected size
5-
3. Each having semi-tranparent fill and stroke
6-
4. Each colored according to an underlying `HColorField`
7-
5. Each rotating around its own center with a randomly-selected speed and
8-
direction
9-
6. Randomly distributed around the circumference of
10-
7. One of several concentric circles
11-
8. All squares rotating at a randomly-selected speed and direction around
12-
a common center point
13-
14-
Implementation by Ben Alkov 7-12 August 2014
3+
1. One hundred `HRect`
4+
2. Of randomly-selected size
5+
3. Each having semi-tranparent fill and stroke
6+
4. Each colored according to an underlying `HColorField`
7+
5. Each rotating around its own center with a randomly-selected speed and
8+
direction
9+
6. Randomly distributed around the circumference of
10+
7. One of several concentric circles
11+
8. All squares rotating at a randomly-selected speed and direction around
12+
a common center point
13+
14+
Implementation by Ben Alkov 7-12 August 2014
1515
1616
'''
1717
from hype.core.util import H
@@ -48,6 +48,6 @@ def setup():
4848

4949
def draw():
5050
H.drawStage()
51-
saveFrame('C:/Users/IBM_ADMIN/Documents/frames/####.tif')
52-
if frameCount == 900:
53-
exit()
51+
# saveFrame('C:/Users/IBM_ADMIN/Documents/frames/####.tif')
52+
# if frameCount == 900:
53+
# exit()

OrbitingSquares_HYPE/parentcallback.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
`draw()` loop callback for the invisible parent `HGroup`s.
2+
`draw()` loop callback for the invisible parent `HGroup`s.
33
'''
44
from hype.core.util import H
55
from hype.core.interfaces import HCallback

OrbitingSquares_HYPE/rectcallback.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
`draw()` loop callback for the visible squares.
2+
`draw()` loop callback for the visible squares.
33
'''
44
from hype.core.util import H
55
from hype.core.interfaces import HCallback

0 commit comments

Comments
 (0)