Browse files

initial import

  • Loading branch information...
0 parents commit be8bcdccccbfea8c2b13afe37af31ff34a190081 @jdf committed Jul 19, 2010
Showing with 245 additions and 0 deletions.
  1. +8 −0 .classpath
  2. +14 −0 .fatjar
  3. +6 −0 .gitignore
  4. +23 −0 .project
  5. +7 −0 .pydevproject
  6. BIN data/Univers-66.vlw
  7. +50 −0 kinetictype-fullpython.py
  8. +40 −0 kinetictype.py
  9. +1 −0 rundemo.sh
  10. +96 −0 src/jycessing/Runner.java
8 .classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/processing-core"/>
+ <classpathentry kind="lib" path="jython.jar" sourcepath="src.zip"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
14 .fatjar
@@ -0,0 +1,14 @@
+#Fat Jar Configuration File
+#Fri Jul 16 22:34:37 EDT 2010
+onejar.license.required=true
+manifest.classpath=
+manifest.removesigners=true
+onejar.checkbox=false
+jarname=python-hack.jar
+manifest.mergeall=true
+manifest.mainclass=jycessing.Runner
+manifest.file=<createnew>
+jarname.isextern=false
+onejar.expand=
+excludes=
+includes=
6 .gitignore
@@ -0,0 +1,6 @@
+bin
+cachedir
+src.zip
+python-hack.jar
+kinetic-type/
+jython.jar
23 .project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jyprocessing</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.python.pydev.PyDevBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.python.pydev.pythonNature</nature>
+ </natures>
+</projectDescription>
7 .pydevproject
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?>
+
+<pydev_project>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
+</pydev_project>
BIN data/Univers-66.vlw
Binary file not shown.
50 kinetictype-fullpython.py
@@ -0,0 +1,50 @@
+from processing.core import PApplet
+
+class KineticType(PApplet):
+ """
+ Kinetic Type
+ by Zach Lieberman.
+ Adapted to Python by Jonathan Feinberg
+ Using push() and pop() to define the curves of the lines of type.
+ """
+
+ def __init__(self):
+ self.words = [
+ "sometimes it's like", "the lines of text", "are so happy",
+ "that they want to dance", "or leave the page or jump",
+ "can you blame them?", "living on the page like that",
+ "waiting to be read..."
+ ]
+
+ def setup(self):
+ self.size(640, 360, PApplet.P3D)
+ self.textFont(self.loadFont("Univers-66.vlw"), 1.0)
+ self.fill(255)
+
+ def draw(self):
+ self.background(0)
+ self.translate(-200, -50, -450)
+ self.rotateY(0.3)
+
+ # Now animate every line object & draw it...
+ for i in range(len(self.words)):
+ f1 = self.sin((i + 1.0) * (self.millis() / 10000.0) * self.TWO_PI)
+ f2 = self.sin((8.0 - i) * (self.millis() / 10000.0) * self.TWO_PI)
+ line = self.words[i]
+ self.pushMatrix()
+ self.translate(0.0, i*75, 0.0)
+ for j in range(len(line)):
+ if j != 0:
+ self.translate(self.textWidth(line[j - 1]) * 75, 0.0, 0.0)
+ self.rotateY(f1 * 0.005 * f2)
+ self.pushMatrix()
+ self.scale(75.0)
+ self.text(line[j], 0.0, 0.0)
+ self.popMatrix()
+ self.popMatrix()
+
+KineticType().runSketch()
+try:
+ print banana
+except:
+ print "no bananas"
40 kinetictype.py
@@ -0,0 +1,40 @@
+"""
+ Kinetic Type
+ by Zach Lieberman.
+ Adapted to Python by Jonathan Feinberg
+ Using push() and pop() to define the curves of the lines of type.
+"""
+
+words = [
+ "sometimes it's like", "the lines of text", "are so happy",
+ "that they want to dance", "or leave the page or jump",
+ "can you blame them?", "living on the page like that",
+ "waiting to be read..."
+ ]
+
+def setup():
+ size(640, 360, P3D)
+ textFont(loadFont("Univers-66.vlw"), 1.0)
+ fill(255)
+
+def draw():
+ background(0)
+ translate(-200, -50, -450)
+ rotateY(0.3)
+
+ # Now animate every line object & draw it...
+ for i in range(len(words)):
+ f1 = sin((i + 1.0) * (millis() / 10000.0) * TWO_PI)
+ f2 = sin((8.0 - i) * (millis() / 10000.0) * TWO_PI)
+ line = words[i]
+ pushMatrix()
+ translate(0.0, i*75, 0.0)
+ for j in range(len(line)):
+ if j != 0:
+ translate(textWidth(line[j - 1]) * 75, 0.0, 0.0)
+ rotateY(f1 * 0.005 * f2)
+ pushMatrix()
+ scale(75.0)
+ text(line[j], 0.0, 0.0)
+ popMatrix()
+ popMatrix()
1 rundemo.sh
@@ -0,0 +1 @@
+c:\jdk6_18\bin\java -jar python-hack.jar kinetictype.py
96 src/jycessing/Runner.java
@@ -0,0 +1,96 @@
+package jycessing;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+
+import org.python.core.Py;
+import org.python.core.PyException;
+import org.python.core.PyObject;
+import org.python.core.PyString;
+import org.python.core.PyStringMap;
+import org.python.util.InteractiveConsole;
+
+import processing.core.PApplet;
+
+public class Runner {
+ private static String wrap(final Reader r) throws IOException {
+ final BufferedReader reader = new BufferedReader(r);
+ final StringBuilder sb = new StringBuilder(1024);
+ String line;
+ try {
+ while ((line = reader.readLine()) != null) {
+ sb.append(line).append("\n");
+ }
+ // sb.append("Test().runSketch()");
+ return sb.toString();
+ } finally {
+ reader.close();
+ }
+ }
+
+ public static class PSM extends PyStringMap {
+ @Override
+ public PyObject __finditem__(final String key) {
+ System.err.println("finditem: " + key);
+ return super.__finditem__(key);
+ }
+
+ }
+
+ public static void main(final String[] args) throws Exception {
+ final String pathname = "kinetictype.py";
+ final String text = wrap(new FileReader(pathname));
+
+ final InteractiveConsole interp = new InteractiveConsole(new PSM());
+ final PyStringMap locals = (PyStringMap)interp.getLocals();
+ final String path = new File(pathname).getCanonicalFile().getParent();
+ Py.getSystemState().path.insert(0, new PyString(path));
+ try {
+ locals.__setitem__(new PyString("__file__"), new PyString(pathname));
+ interp.exec(text);
+ } catch (Throwable t) {
+ Py.printException(t);
+ interp.cleanup();
+ System.exit(-1);
+ }
+
+ final PyObject setup = locals.__finditem__("setup");
+ final PyObject draw = locals.__finditem__("draw");
+ final PApplet applet = new PApplet() {
+ @Override
+ public void setup() {
+ if (setup != null) {
+ try {
+ setup.__call__();
+ } catch (PyException e) {
+ if (e.getCause() instanceof RendererChangeException) {
+ throw (RendererChangeException)e.getCause();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void draw() {
+ if (draw == null) {
+ super.draw();
+ } else {
+ draw.__call__();
+ }
+ }
+ };
+ locals.__setitem__("P3D", new PyString(PApplet.P3D));
+ locals.__setitem__("size", new PyObject() {
+ @Override
+ public PyObject __call__(final PyObject arg0, final PyObject arg1,
+ final PyObject arg2) {
+ applet.size(arg0.asInt(), arg1.asInt(), arg2.asString());
+ return Py.None;
+ }
+ });
+ PApplet.runSketch(new String[] { "Test" }, applet);
+ }
+}

0 comments on commit be8bcdc

Please sign in to comment.