Permalink
Browse files

Further work on examples and documentation.

  • Loading branch information...
1 parent cab9fe7 commit 5838eaf897fb65c3f0cd11e8a872afc211d8fbe6 @jdf committed Sep 1, 2013
View
@@ -2,10 +2,10 @@
Write Processing sketches in Python.
- * Based on [Processing 2.0](http://processing.org/), runtime compatible with most [3rd party libraries](http://www.processing.org/reference/libraries/).
+ * Based on [Processing 2.0](http://processing.org/), and compatible with most [3rd party libraries](http://www.processing.org/reference/libraries/).
* Source compatible with [Python 2.7.3](http://python.org).
-Tested on Mac OS 10.8.3, Windows XP and Ubuntu 12.10.
+Tested on Mac OS 10.8.3, Windows XP, Windows 7, and Ubuntu 12.10.
## Quick Start ##
@@ -25,29 +25,25 @@ Then, paste this code into a file, e.g., `mysketch.py`.
def draw():
ellipse(mouseX, mouseY, 10, 10)
-
-Eventually, you can run the code by drag-dropping your sketch onto one of these files according to your platform:
+Drag and drop your sketch onto one of these files according to your platform:
<img src="http://py.processing.org/howtolaunch.jpg"/>
-If that does not work for one of your platforms (such as Linux), you can run the sketch either semi-manually (with automated JRE detection) ...
-
- $ ./processing-py.sh mysketch.py
-
-... or fully by hand.
+If that does not work for you, run the sketch either with the included launcher script (on linux and OS X):
- $ java -jar processing-py.jar mysketch.py
+ $ ./processing-py.sh path/to/mysketch.py
+or using your own Java runtime environment:
+ $ java -jar processing-py.jar path/to/mysketch.py
## Documentation ##
To learn Processing.py check out these resources:
-
* Built-in [Processing 2.0 functions](http://processing.org/reference/) for rendering and interaction.
- * The [Python 2.7.3 library](http://docs.python.org/2/index.html).
- * And of course the [Java 6.x / 7.x library](http://docs.oracle.com/javase/6/docs/api/).
+ * The [Python 2.7 documentation](http://docs.python.org/2/index.html).
+ * And of course the [Java 7 API documentation](http://docs.oracle.com/javase/7/docs/api/).
In addition, we are a great fan of learning by doing, and a number of converted examples outline how to use Processing.py:
@@ -56,35 +52,40 @@ In addition, we are a great fan of learning by doing, and a number of converted
$ processing-py.sh examples.py/3D/Typography/KineticType.py
$ processing-py.sh examples.py/3D/Textures/TextureCube.py
-As always, on Windows use `processing-py.bat` instead, on Mac the `processing-py` app, or simply drag-drop the example on the launcher / batch.
+On Windows use `processing-py.bat` instead. On Mac OS X, use the `processing-py` app, or simply drag and drop an example script onto the app.
-## FAQ ##
+## Using Processing Libraries ##
- * __Can I use all of the existing Processing libraries?__
+Processing.py is implemented in Java, and is meant to be compatible with the existing ecosystem of [Processing libraries](http://processing.org/reference/libraries/).
+* Put processing extension libraries in the `libraries` subdirectory of your processing.py installation.
- Yes! Processing.py is implemented in Java, and is meant to be compatible with the whole existing ecosystem of [Processing libraries](http://processing.org/reference/libraries/).
+* Import them in one of the usual Python ways, as in these snippets:
- * Put processing extension libraries in the `libraries` subdirectory of your processing.py installation.
+ from peasy import PeasyCam
+ # or
+ import peasy.PeasyCam
+ # or
+ import peasy.PeasyCam as PeasyCam
- * Import them in on of the usual Python ways, as in these snippets:
+ Unfortunately, `from foo import *` is not supported.
+* In your `setup()` method
- from peasy import PeasyCam # or
- import peasy.PeasyCam # or
- import peasy.PeasyCam as PeasyCam
+ cam = PeasyCam(this, 200)
- Unfortunately, `from foo import *` is not supported.
+ Many libraries need a reference to "the current PApplet", and that's what
+ `this` is for.
- * In your `setup()` method
+## Included Libraries ##
- cam = PeasyCam(this, 200)
+Some Processing libraries may not work with processing.py right out of the box. In particular, any library that uses Java reflection to call specially-named functions in your sketch will not work. However, we're happy to modify processing.py to work with any of the official Processing libraries. Here are the libraries that have required special handling in processing.py, and are included in the processing.py download:
+ * [Fisica](http://www.ricardmarxer.com/fisica/), by [Ricard Marxer](http://www.ricardmarxer.com/). Included under the terms of the LGPLv3, and with the kind cooperation of Mr. Marxer. See [examples.py/Fisica](https://github.com/jdf/processing.py/tree/master/examples.py/Fisica) for examples.
- Use `this` to refer to the PApplet you're in, as in the examples above.
- Many libraries need a reference to "the current PApplet", and that's what
- `this` is for.
+If you find that some Processing library doesn't work as expected with processing.py, please let us know in the [bug tracker](http://github.com/jdf/processing.py/issues).
+## FAQ ##
* __How can I create a wrapper?__
@@ -101,7 +102,6 @@ As always, on Windows use `processing-py.bat` instead, on Mac the `processing-py
In that case, processing.py will try to search `data.txt` always where your script resides.
-
* __How can I use Ani, or any other library that modifies fields?__
Some libraries such as [Ani](http://www.looksgood.de/libraries/Ani/) require you to specify a variable name for animation. Unfortunately they cannot access Python variables directly (and Java's built in classes are immutable).
@@ -112,17 +112,14 @@ As always, on Windows use `processing-py.bat` instead, on Mac the `processing-py
x = Float(100.0)
Ani.to(x, 200, "value", 50); # "value" is the name of the Float's internal field
-
In case you need other primitive values, please [let us know](http://github.com/jdf/processing.py/issues)!
* __I found a bug, what should I do?__
Please report any issue in the [bug tracker](http://github.com/jdf/processing.py/issues).
-
* __Why was this project created?__
-
I (Jonathan) recently gave a talk about Processing to a group of rather bright 8th-graders,
as part of a computer-programming summer camp they were attending at my office.
Their curriculum up to that point had been in Python, which is an eminently
@@ -1,35 +1,36 @@
-"""
- * Ortho vs Perspective.
- *
+"""
+ * Ortho vs Perspective.
+ *
* Click to see the difference between orthographic projection
* and perspective projection as applied to a simple box.
- * The ortho() function sets an orthographic projection and
- * defines a parallel clipping volume. All objects with the
- * same dimension appear the same size, regardless of whether
- * they are near or far from the camera. The parameters to this
- * function specify the clipping volume where left and right
- * are the minimum and maximum x values, top and bottom are the
- * minimum and maximum y values, and near and far are the minimum
+ * The ortho() function sets an orthographic projection and
+ * defines a parallel clipping volume. All objects with the
+ * same dimension appear the same size, regardless of whether
+ * they are near or far from the camera. The parameters to this
+ * function specify the clipping volume where left and right
+ * are the minimum and maximum x values, top and bottom are the
+ * minimum and maximum y values, and near and far are the minimum
* and maximum z values.
"""
-def setup():
+def setup():
size(640, 360, P3D)
noStroke()
fill(204)
-def draw():
+
+def draw():
background(0)
lights()
-
+
if mousePressed:
- fov = PI / 3.0
- cameraZ = (height / 2.0) / tan(PI * fov / 360.0)
+ fov = PI / 3.0
+ cameraZ = (height / 2.0) / tan(PI * fov / 360.0)
perspective(fov, float(width) / float(height),
- cameraZ / 2.0, cameraZ * 2.0)
+ cameraZ / 2.0, cameraZ * 2.0)
else:
- ortho(-width / 2, width / 2, -height / 2, height / 2, -10, 10)
-
-
+ ortho(-width / 2, width / 2, -height / 2, height / 2, -10, 10)
+
+
translate(width / 2, height / 2, 0)
- rotateX(-PI / 6)
- rotateY(PI / 3)
- box(160)
+ rotateX(-PI / 6)
+ rotateY(PI / 3)
+ box(160)
@@ -1,22 +1,23 @@
"""
- * Perspective.
- *
+ * Perspective.
+ *
* Move the mouse left and right to change the field of view (fov).
* Click to modify the aspect ratio. The perspective() function
- * sets a perspective projection applying foreshortening, making
- * distant objects appear smaller than closer ones. The parameters
- * define a viewing volume with the shape of truncated pyramid.
- * Objects near to the front of the volume appear their actual size,
- * while farther objects appear smaller. This projection simulates
- * the perspective of the world more accurately than orthographic projection.
- * The version of perspective without parameters sets the default
- * perspective and the version with four parameters allows the programmer
+ * sets a perspective projection applying foreshortening, making
+ * distant objects appear smaller than closer ones. The parameters
+ * define a viewing volume with the shape of truncated pyramid.
+ * Objects near to the front of the volume appear their actual size,
+ * while farther objects appear smaller. This projection simulates
+ * the perspective of the world more accurately than orthographic projection.
+ * The version of perspective without parameters sets the default
+ * perspective and the version with four parameters allows the programmer
* to set the area precisely.
"""
-def setup():
+def setup():
size(640, 360, P3D)
noStroke()
-def draw():
+
+def draw():
lights()
background(204)
cameraY = height / 2.0
@@ -25,9 +26,9 @@ def draw():
aspect = float(width) / float(height)
if mousePressed:
aspect = aspect / 2.0
-
+
perspective(fov, aspect, cameraZ / 10.0, cameraZ * 10.0)
-
+
translate(width / 2 + 30, height / 2, 0)
rotateX(-PI / 6)
rotateY(PI / 3 + mouseY / float(height) * PI)
@@ -7,7 +7,7 @@ def __init__(self, _texto):
self.textOffset = textAscent() - self.getHeight()/2
def draw(self, applet):
- self.super__draw(applet)
+ FBox.draw(self, applet)
self.preDraw(applet)
fill(0)
stroke(0)
View
@@ -1,2 +1,2 @@
-Extract any Processing 2.0 plug-in into the "processing" folder.
-
+Extract any Processing 2.0 plug-in into this directory, or any subdirectory
+of this directory.
@@ -1,2 +1,2 @@
#Sat, 06 Jul 2013 16:18:15 -0400
-buildnumber=0200
+buildnumber=0201

0 comments on commit 5838eaf

Please sign in to comment.