Skip to content

Commit f4e5d90

Browse files
committed
update python version
1 parent 02a4112 commit f4e5d90

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This repo contains example code for those looking to experiment with py5's Hybri
44

55
## What is py5?
66

7-
py5 is a version of [**Processing**][processing] for Python 3.8+. It makes the Java [**Processing**][processing] jars available to the CPython interpreter using [**JPype**][jpype]. It can do just about all of the 2D and 3D drawing [**Processing**][processing] can do, except with Python instead of Java code.
7+
py5 is a version of [**Processing**][processing] for Python 3.9+. It makes the Java [**Processing**][processing] jars available to the CPython interpreter using [**JPype**][jpype]. It can do just about all of the 2D and 3D drawing [**Processing**][processing] can do, except with Python instead of Java code.
88

99
## Hybrid Programming
1010

processing-mode/example3/example3.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
cluster_centers = None
2828

2929

30-
def get_cluster_count():
30+
def cluster_count():
3131
# the number of clusters should be set in one place for both the Python and Java code
3232
return NUMBER_OF_CLUSTERS
3333

@@ -47,8 +47,8 @@ def cluster_boids(boid_locations):
4747
return JClass('java.lang.RuntimeException')(str(e))
4848

4949

50-
py5_tools.register_processing_mode_key("cluster_boids", cluster_boids)
51-
py5_tools.register_processing_mode_key("cluster_count", get_cluster_count)
50+
# py5_tools.register_processing_mode_key("cluster_boids", cluster_boids)
51+
# py5_tools.register_processing_mode_key("cluster_count", cluster_count)
5252

5353

5454
# run the sketch in processing mode, specifying the Java class to instantiate
8 Bytes
Binary file not shown.

processing-mode/example3/java/src/main/java/test/Boid.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public Boid(SketchBase sketch, int[] clusterColorsLUT, float x, float y) {
3333
velocity = new PVector(SketchBase.cos(angle), SketchBase.sin(angle));
3434

3535
position = new PVector(x, y);
36-
r = 2.0f;
36+
r = 5.0f;
3737
maxspeed = 2;
3838
maxforce = 0.03f;
3939
}

processing-mode/example3/java/src/main/java/test/Example3Sketch.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class Example3Sketch extends SketchBase {
2525
protected int[] clusterColorsLUT;
2626

2727
public void settings() {
28-
size(640, 360);
28+
size(1024, 1024);
2929
}
3030

3131
public void setup() {
@@ -50,11 +50,19 @@ public void setup() {
5050
// because the clustering algorithm would slow down the draw() method and
5151
// reduce the frame rate to a crawl.
5252
thread("runClustering");
53+
54+
// frameRate(60);
5355
}
5456

5557
public void draw() {
5658
background(50);
5759
flock.run();
60+
61+
// saveFrame("/tmp/frames/frame-####.png");
62+
63+
// if (frameCount > 60 * 60) {
64+
// exit();
65+
// }
5866
}
5967

6068
// Add a new boid into the System
@@ -67,6 +75,11 @@ public void runClustering() {
6775
float[][] boidLocations = flock.getBoidLocations();
6876
int[] boidClusterLabels = (int[]) callPython("cluster_boids", (Object) boidLocations);
6977
flock.setBoidClusterLabels(boidClusterLabels);
78+
// try {
79+
// Thread.sleep(100);
80+
// } catch (InterruptedException e) {
81+
// e.printStackTrace();
82+
// }
7083
}
7184
}
7285

0 commit comments

Comments
 (0)