Skip to content
Newer
Older
100644 127 lines (85 sloc) 5.44 KB
fb77487 @jdf Fix broken images.
authored
1 # Python Mode for Processing #
52ccb15 @google-feinberg markdown README
google-feinberg authored
2
013cfcb @jdf New build!
authored
3 Write real [Processing](http://processing.org/) sketches in Python.
91f4aa8 @jdf working on regression tests, and the beginnings of a fix for bug #1
authored
4
b3a4335 @jdf Update docs and build number for 3.x build.
authored
5 * Based on [Processing 3.0](http://processing.org/), and compatible with most [3rd party libraries](http://www.processing.org/reference/libraries/).
9fc890d @ralfbiedert Updated README.
ralfbiedert authored
6 * Source compatible with [Python 2.7.3](http://python.org).
e593710 @google-feinberg Remove obsolete known issues reference.
google-feinberg authored
7
b3a4335 @jdf Update docs and build number for 3.x build.
authored
8 Tested on Mac OS 10.10 and Ubuntu 14.
91f4aa8 @jdf working on regression tests, and the beginnings of a fix for bug #1
authored
9
86f2aef @jdf Add cute Travis badge.
authored
10 [![Build Status](https://travis-ci.org/jdf/processing.py.svg?branch=master)](https://travis-ci.org/jdf/processing.py)
11
f26f5cb @jdf minor tweaks
authored
12 ## Quick Start ##
3a04d0e @google-feinberg apply benfry suggestions
google-feinberg authored
13
edd6a97 @federicobond Fix typo in README.markdown
federicobond authored
14 ### Processing Development Environment ###
bc8a4c0 @jdf Update project README.
authored
15
16 If you're looking to write Processing sketches in Python, your best bet is to use
17 Python Mode. The project is still in its early days, and documentation is lacking,
18 but there are many example sketches to get you started. In general, the Processing
19 reference works just fine for Python mode.
20
21 First, [download Processing](http://processing.org/download). Then, install
22 Python Mode:
23
fb77487 @jdf Fix broken images.
authored
24 <img src="http://py.processing.org/add_mode.png"/>
25 <img src="http://py.processing.org/install.png"/>
bc8a4c0 @jdf Update project README.
authored
26
d2faadc @jdf Nice first sketch copypaste for README.
authored
27 Then try your first sketch:
28
29 ```python
30 def setup():
31 size(600, 600)
e035bdb @jdf Fix first sketch copypaste for README.
authored
32 colorMode(HSB)
d2faadc @jdf Nice first sketch copypaste for README.
authored
33 noStroke()
34
35
36 def draw():
37 fill(0x11000000)
38 rect(0, 0, width, height)
39 fill(frameCount % 255, 255, 255)
40 ellipse(mouseX, mouseY, 20, 20)
41 ```
bc8a4c0 @jdf Update project README.
authored
42
9fc890d @ralfbiedert Updated README.
ralfbiedert authored
43
5838eaf @jdf Further work on examples and documentation.
authored
44 ## Using Processing Libraries ##
9fc890d @ralfbiedert Updated README.
ralfbiedert authored
45
b3a4335 @jdf Update docs and build number for 3.x build.
authored
46 Python Mode is implemented in Java, and is designed to be compatible with the existing ecosystem of [Processing libraries](http://processing.org/reference/libraries/).
3a04d0e @google-feinberg apply benfry suggestions
google-feinberg authored
47
b3a4335 @jdf Update docs and build number for 3.x build.
authored
48 Many libraries need a reference to "the current PApplet", and that's what
49 `this` is for. Of course, there's no such thing as `this` in Python; it's just something that processing.py provides for you for compatibility with such libraries.
a7ab1a1 @jdf New upload URLs
authored
50
5838eaf @jdf Further work on examples and documentation.
authored
51 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).
3a04d0e @google-feinberg apply benfry suggestions
google-feinberg authored
52
5838eaf @jdf Further work on examples and documentation.
authored
53 ## FAQ ##
96be640 @jdf removing folder
authored
54
013cfcb @jdf New build!
authored
55 * __How do I report bugs or request new features?__
56
57 Please report any issue in the [bug tracker](http://github.com/jdf/processing.py/issues).
58
59 * __How can I create a launcher for my sketch?__
a7ab1a1 @jdf New upload URLs
authored
60
9fc890d @ralfbiedert Updated README.
ralfbiedert authored
61 Add these lines near the top of your script:
62
63 import launcher
64 launcher.create()
65
66 * __How can I use Ani, or any other library that modifies fields?__
a7ab1a1 @jdf New upload URLs
authored
67
9fc890d @ralfbiedert Updated README.
ralfbiedert authored
68 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).
a7ab1a1 @jdf New upload URLs
authored
69
9fc890d @ralfbiedert Updated README.
ralfbiedert authored
70 To solve this problem we instead create a mutable `PrimitiveFloat` object. This object has a field `.value`, which you can use for these purposes.
52ccb15 @google-feinberg markdown README
google-feinberg authored
71
9fc890d @ralfbiedert Updated README.
ralfbiedert authored
72 import jycessing.primitives.PrimitiveFloat as Float
73 x = Float(100.0)
74 Ani.to(x, 200, "value", 50); # "value" is the name of the Float's internal field
75
76 In case you need other primitive values, please [let us know](http://github.com/jdf/processing.py/issues)!
77
78 * __Why was this project created?__
79
013cfcb @jdf New build!
authored
80 I ([Jonathan](http://MrFeinberg.com/)) recently gave a talk about Processing to a group of rather bright 8th-graders,
9fc890d @ralfbiedert Updated README.
ralfbiedert authored
81 as part of a computer-programming summer camp they were attending at my office.
82 Their curriculum up to that point had been in Python, which is an eminently
83 sensible choice, given the
84 [pedagogical roots](http://en.wikipedia.org/wiki/ABC_%28programming_language%29)
85 of the language.
86
87 The kids were really turned on by the demos--I showed them the
88 [white glove](http://whiteglovetracking.com/), and
89 [Golan Levin](http://flong.com/)'s
90 [New Year's cards](http://www.flong.com/storage/experience/newyear/newyear10/)--but
91 they were bogged down by Processing's C-like syntax, which really seems arcane
92 and unnecessarily complex when you're used to Python.
93
94 I shared my experience with Processing creators
95 [Ben Fry](http://benfry.com/) and [Casey Reas](http://reas.com/), and they
96 told me that, indeed, the original Processing was a fork of
97 ["Design By Numbers"](http://dbn.media.mit.edu/), with Python and Scheme
98 support hacked in. Support for a multi-lingual programming
99 environment was always part of the plan, so they were enthusiastic
100 about any new attempt at the problem.
101
102 I was able to hack up a proof of concept in a couple of hours, and have
103 managed to create something worth sharing in a couple of weeks. I was only
104 able to do it at all thanks to the brilliant and beautiful
105 [Jython](http://www.jython.org/) project.
106
107 At the time of Processing's first public release, August of 2001,
108 Jython was too young a project to be used in this way. But now, having done
109 absolutely no work to profile and optimize, I can get hundreds of frames
110 per second of 3D graphics on my linux box. So, kudos to the Processing
111 project, and kudos to Jython!
6eb14d2 @ralfbiedert Updated the README.
ralfbiedert authored
112
113
114 ## Credits ##
115
a7ab1a1 @jdf New upload URLs
authored
116 Written by [Jonathan Feinberg](http://mrfeinberg.com) &lt;[jdf@pobox.com](mailto:jdf@pobox.com)&gt;
117 Launcher & many improvements by [Ralf Biedert](http://xr.io) &lt;[rb@xr.io](mailto:rb@xr.io)&gt;
6eb14d2 @ralfbiedert Updated the README.
ralfbiedert authored
118
b4a7a63 @jdf Better wording to describe Luca's contribution.
authored
119 Much of the work in achieving compatibility with Processing 3.x was
120 was done by Luca Damasco
b3a4335 @jdf Update docs and build number for 3.x build.
authored
121 (Google Summer of Code student), under the supervision of Golan Levin,
122 with additional support from the Frank-Ratchye STUDIO for Creative Inquiry at Carnegie
123 Mellon University. Without Luca, the porject may well have died.
124
9fc890d @ralfbiedert Updated README.
ralfbiedert authored
125 Also, [YourKit, LLC](http://www.yourkit.com) was so kind to sponsor a license for their excellent [YourKit Java Profiler](http://www.yourkit.com/java/profiler/index.jsp). Thank you very much!
47be091 @google-feinberg new small example for home page
google-feinberg authored
126
Something went wrong with that request. Please try again.