Permalink
Browse files

Initial import.

  • Loading branch information...
1 parent aeef36e commit f93b14f3e0e691f88bea4676994e3df4bbfdb08f @jdf committed Jan 12, 2009
View
7 .classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JDK 5"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/processing-head"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
17 .project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Patchy</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
12 .settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Mon Jan 12 15:48:57 EST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
View
12 examples/HelloPatchy/HelloPatchy.pde
@@ -0,0 +1,12 @@
+import patchy.*;
+
+Patch patch;
+
+void setup() {
+ size(200,200,P3D);
+
+}
+void draw() {
+}
+
+
View
199 resources/build.xml
@@ -0,0 +1,199 @@
+<project name="processingLibs" default="build" basedir="../">
+
+ <description>
+ Patchy build
+ </description>
+
+ <property name="processing" location="c:/Documents and Settings/Administrator/Desktop/processing-1.0.1/libraries" />
+
+ <property name="libraryClasspath" location="${processing}/../lib" />
+ <path id="library-classpath">
+ <fileset dir="${libraryClasspath}">
+ <include name="core.jar" />
+ </fileset>
+ </path>
+
+ <property name="javaVersion" value="1.5" />
+
+ <property name="author" value="Jonathan Feinberg" />
+ <property name="copyright" value="(c) 2008" />
+ <property name="libraryName" value="Patchy" />
+ <property name="versionNumber" value="0.1.0" />
+ <property name="yourLink" value="http://mrfeinberg.com/" />
+ <property name="keywords" value="3D,camera,rotation" />
+ <property name="tested:platform" value="Windows" />
+ <property name="tested:processingVersion" value="1.0.1" />
+ <property name="tested:dependencies" value="" />
+ <property name="source:host" value="google code" />
+ <property name="source:url" value="http://code.google.com/p/patchy" />
+ <property name="source:repository" value="http://code.google.com/p/patchy/source/browse/" />
+
+
+ <!-- no changes or adjustments required below -->
+
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties">
+ <classpath>
+ <pathelement location="./resources/code/ant-contrib-1.0b3.jar" />
+ </classpath>
+ </taskdef>
+ <property name="jarFile" value="${libraryName}.jar" />
+ <property name="src" location="src" />
+ <property name="bin" location="bin" />
+ <property name="reference" location="reference" />
+ <property name="dist" location="distribution" />
+
+
+
+ <target name="init">
+ <echo>Properties initialized.
+ src path ${src}
+ bin path ${bin}
+ libraryClasspath ${libraryClasspath}
+ processing Libraries ${processing}
+ java version ${javaVersion}
+ </echo>
+ <echo>building library ...</echo>
+ <!-- Create the time stamp -->
+ <tstamp>
+ <format property="date" pattern="MM/dd/yyyy" offset="0" unit="hour" />
+ </tstamp>
+ <mkdir dir="${dist}" />
+ </target>
+
+ <!-- compile the library -->
+ <target name="compile" depends="init" description="compile the source">
+ <javac destdir="${bin}" source="${javaVersion}">
+ <classpath>
+ <path refid="library-classpath" />
+ </classpath>
+ <src path="${src}" />
+ </javac>
+ </target>
+
+ <!-- build the distribution of the library -->
+ <target name="build" depends="compile" description="generate the distribution">
+ <!-- delete the previous content of the ${dist} folder -->
+ <delete dir="${dist}" />
+
+ <!-- build the structure for ${dist} -->
+ <mkdir dir="${dist}" />
+
+ <property name="realDist" value="${dist}/patchy"/>
+ <mkdir dir="${realDist}" />
+
+ <mkdir dir="${realDist}/library" />
+ <mkdir dir="${realDist}/examples" />
+ <mkdir dir="${realDist}/reference" />
+ <mkdir dir="${realDist}/src" />
+ <jar jarfile="${realDist}/library/${jarFile}" basedir="${bin}" />
+ <copy todir="${realDist}/examples">
+ <fileset dir="examples" />
+ </copy>
+ <copy todir="${realDist}/src">
+ <fileset dir="src" />
+ </copy>
+ <copy todir="web" file="${realDist}/library/${jarFile}"/>
+
+ <!-- create the java reference of the library -->
+ <mkdir dir="${reference}" />
+ <javadoc bottom="processing library ${libraryName} by ${author}. ${copyright}" classpath="${libraryClasspath}/core.jar" destdir="${reference}" verbose="false" stylesheetfile="resources/stylesheet.css" doctitle="Javadocs: ${libraryName}" public="true" version="false" windowtitle="Javadocs: ${libraryName}">
+ <taglet name="ExampleTaglet" path="resources/code" />
+ <fileset dir="${src}" defaultexcludes="yes">
+ <!-- #### (9) add packages to be added to reference. #### -->
+ <include name="**/*" />
+ </fileset>
+ </javadoc>
+
+ <copy todir="${realDist}/reference">
+ <fileset dir="${reference}" />
+ </copy>
+
+ <!-- copy the jar file to processing's libraries -->
+ <copy todir="${processing}">
+ <fileset dir="${dist}" />
+ </copy>
+
+ <!-- zip the distribution of the library -->
+ <zip destfile="${dist}/${libraryName}.zip" basedir="${dist}" excludes="**/_DS.Store" />
+
+ <rename src="${dist}/${libraryName}.zip" dest="${dist}/${libraryName}_${versionNumber}.zip" />
+
+ <!-- organize the ${dist} folder -->
+ <mkdir dir="${dist}/web" />
+ <move todir="${dist}/web/reference">
+ <fileset dir="${realDist}/reference" />
+ </move>
+
+ <move todir="${dist}/web/examples">
+ <fileset dir="${realDist}/examples" />
+ </move>
+
+ <delete dir="${dist}/library" />
+
+ <copy todir="${dist}/web">
+ <fileset dir="web" />
+ </copy>
+
+ <!--
+ format the index.html file.
+ regular expressions are used to parse the web index.html file.
+ key words starting and ending with ## are replaced by values
+ defined earlier in the beginning of this build file.
+ -->
+
+ <replaceregexp file="${dist}/web/index.html" match="##yourLibrary##" replace="${libraryName}" flags="g" />
+
+ <replaceregexp file="${dist}/web/index.html" match="##author##" replace="${author}" flags="g" />
+
+ <replaceregexp file="${dist}/web/index.html" match="##versionNumber##" replace="${versionNumber}" flags="g" />
+
+ <replaceregexp file="${dist}/web/index.html" match="##yourLink##" replace="${yourLink}" flags="g" />
+
+ <replaceregexp file="${dist}/web/index.html" match="##date##" replace="${date}" flags="g" />
+
+ <replaceregexp file="${dist}/web/index.html" match="##keywords##" replace="${keywords}" flags="g" />
+
+
+
+ <replaceregexp file="${dist}/web/index.html" match="##tested:platform##" replace="${tested:platform}" flags="g" />
+ <replaceregexp file="${dist}/web/index.html" match="##tested:processingVersion##" replace="${tested:processingVersion}" flags="g" />
+ <replaceregexp file="${dist}/web/index.html" match="##tested:dependencies##" replace="${tested:dependencies}" flags="g" />
+ <replaceregexp file="${dist}/web/index.html" match="##source:host##" replace="${source:host}" flags="g" />
+ <replaceregexp file="${dist}/web/index.html" match="##source:url##" replace="${source:url}" flags="g" />
+ <replaceregexp file="${dist}/web/index.html" match="##source:repository##" replace="${source:repository}" flags="g" />
+
+
+ <echo>---------------------</echo>
+ <antcall target="processExamples" />
+ <echo>---------------------</echo>
+
+ <replaceregexp file="${dist}/web/index.html" match="##examples##" replace="" flags="g" />
+
+
+ <!-- finish organizating library's distribution -->
+ <mkdir dir="${dist}/web/download" />
+ <copy file="${dist}/${libraryName}_${versionNumber}.zip" todir="${dist}/web/download" />
+
+ <copy todir="${processing}/${libraryName}/reference">
+ <fileset dir="${reference}" />
+ </copy>
+
+ <!-- done, finished. -->
+ <echo>done, finished.</echo>
+ </target>
+
+
+
+ <!-- parsing the examples folder -->
+ <target name="processExamples">
+ <dirset id="examples.contents" dir="examples" excludes="*/*" />
+ <property name="examples.list" refid="examples.contents" />
+ <foreach list="${examples.list}" target="addExamples" param="exampleDir" delimiter=";">
+ </foreach>
+ </target>
+
+ <target name="addExamples">
+ <replaceregexp file="${dist}/web/index.html" match="(##examples##)" replace="&lt;li&gt;&lt;a href=&quot;examples/${exampleDir}/${exampleDir}.pde&quot;&gt;${exampleDir}&lt;/a&gt;&lt;/li&gt; \1" flags="g" />
+ </target>
+</project>
+
View
231 resources/code/ExampleTaglet.java
@@ -0,0 +1,231 @@
+/*
+ * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * -Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * -Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
+ * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR
+ * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR
+ * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
+ * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
+ * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
+ * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
+ * THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that Software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ */
+
+import com.sun.tools.doclets.Taglet;
+import com.sun.javadoc.*;
+import java.util.Map;
+import java.io.*;
+/**
+ * A sample Taglet representing @example. This tag can be used in any kind of
+ * {@link com.sun.javadoc.Doc}. It is not an inline tag. The text is displayed
+ * in yellow to remind the developer to perform a task. For
+ * example, "@example Hello" would be shown as:
+ * <DL>
+ * <DT>
+ * <B>To Do:</B>
+ * <DD><table cellpadding=2 cellspacing=0><tr><td bgcolor="yellow">Fix this!
+ * </td></tr></table></DD>
+ * </DL>
+ *
+ * @author Jamie Ho
+ * @since 1.4
+ */
+
+public class ExampleTaglet implements Taglet {
+
+ private static final String NAME = "example";
+ private static final String HEADER = "example To Do:";
+
+ /**
+ * Return the name of this custom tag.
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /**
+ * Will return true since <code>@example</code>
+ * can be used in field documentation.
+ * @return true since <code>@example</code>
+ * can be used in field documentation and false
+ * otherwise.
+ */
+ public boolean inField() {
+ return true;
+ }
+
+ /**
+ * Will return true since <code>@example</code>
+ * can be used in constructor documentation.
+ * @return true since <code>@example</code>
+ * can be used in constructor documentation and false
+ * otherwise.
+ */
+ public boolean inConstructor() {
+ return true;
+ }
+
+ /**
+ * Will return true since <code>@example</code>
+ * can be used in method documentation.
+ * @return true since <code>@example</code>
+ * can be used in method documentation and false
+ * otherwise.
+ */
+ public boolean inMethod() {
+ return true;
+ }
+
+ /**
+ * Will return true since <code>@example</code>
+ * can be used in method documentation.
+ * @return true since <code>@example</code>
+ * can be used in overview documentation and false
+ * otherwise.
+ */
+ public boolean inOverview() {
+ return true;
+ }
+
+ /**
+ * Will return true since <code>@example</code>
+ * can be used in package documentation.
+ * @return true since <code>@example</code>
+ * can be used in package documentation and false
+ * otherwise.
+ */
+ public boolean inPackage() {
+ return true;
+ }
+
+ /**
+ * Will return true since <code>@example</code>
+ * can be used in type documentation (classes or interfaces).
+ * @return true since <code>@example</code>
+ * can be used in type documentation and false
+ * otherwise.
+ */
+ public boolean inType() {
+ return true;
+ }
+
+ /**
+ * Will return false since <code>@example</code>
+ * is not an inline tag.
+ * @return false since <code>@example</code>
+ * is not an inline tag.
+ */
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ /**
+ * Register this Taglet.
+ * @param tagletMap the map to register this tag to.
+ */
+ public static void register(Map tagletMap) {
+ ExampleTaglet tag = new ExampleTaglet();
+ Taglet t = (Taglet) tagletMap.get(tag.getName());
+ if (t != null) {
+ tagletMap.remove(tag.getName());
+ }
+ tagletMap.put(tag.getName(), tag);
+ }
+
+ /**
+ * Given the <code>Tag</code> representation of this custom
+ * tag, return its string representation.
+ * @param tag the <code>Tag</code> representation of this custom tag.
+ */
+ public String toString(Tag tag) {
+ return createHTML(readFile(tag.text()));
+ }
+
+
+ /**
+ * Given an array of <code>Tag</code>s representing this custom
+ * tag, return its string representation.
+ * @param tags the array of <code>Tag</code>s representing of this custom tag.
+ */
+ public String toString(Tag[] tags) {
+ if (tags.length == 0) {
+ return null;
+ }
+ return createHTML(readFile(tags[0].text()));
+ }
+
+
+
+ String createHTML(String theString) {
+ if(theString!=null) {
+ String dd = "<script type=\"text/javascript\">\n" +
+ "<!--\n"+
+ "document.getElementsByTagName('html')[0].className = 'isjs';" +
+ "function toggle(dt) { var display, dd=dt; do{ dd = dd.nextSibling } while(dd.tagName!='DD'); toOpen =!dd.style.display;" +
+ "dd.style.display = toOpen? 'block':''; dt.getElementsByTagName('span')[0].innerHTML = toOpen? '-':'+' ; }\n" +
+ "-->\n</script>";
+
+ return dd+"\n<div id=\"test\" class=\"toggleList\">" +
+ "<dl><dt onclick=\"toggle(this);\"><span>+</span>Example</dt>" +
+ "<dd><pre>"+theString+"</pre>" +
+ "</dd></dl></div>";
+ }
+ return "";
+ }
+
+
+ /**
+ * check if the examples directory exists and return the example as given in the tag.
+ * @param theExample the name of the example
+ */
+ String readFile(String theExample) {
+ String record = "";
+ String myResult = "";
+ int recCount = 0;
+ String myDir = "../examples";
+ File file=new File(myDir);
+ if(file.exists()==false) {
+ myDir = "./examples";
+ }
+ try {
+ FileReader fr = new FileReader(myDir+"/"+theExample+"/"+theExample+".pde");
+ BufferedReader br = new BufferedReader(fr);
+ record = new String();
+ while ((record = br.readLine()) != null) {
+ myResult += record+"\n";
+ }
+ } catch (IOException e) {
+ System.out.println(e);
+ return null;
+ }
+ return myResult;
+ }
+}
+
+
View
BIN resources/code/ant-contrib-1.0b3.jar
Binary file not shown.
View
18 resources/code/doc.sh
@@ -0,0 +1,18 @@
+# a shell script to create a java documentation
+# for a processing library.
+#
+# make changes to the variables below so they
+# fit the structure of your library
+
+# the package name of your library
+package=peasy;
+
+# source folder location
+src=../src;
+
+# the destination folder of your documentation
+dest=../documentation;
+
+
+# compile the java documentation
+javadoc -d $dest -stylesheetfile ./stylesheet.css -sourcepath ${src} ${package}
View
310 resources/stylesheet.css
@@ -0,0 +1,310 @@
+/* Javadoc style sheet */
+/* Define colors, fonts and other style attributes here to override the defaults */
+/* processingLibs style by andreas schlegel, sojamo */
+
+
+body {
+ margin : 0;
+ padding : 0;
+ padding-left : 10px;
+ padding-right : 8px;
+ background-color : #FFFFFF;
+ font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-size : 100%;
+ font-size : 0.7em;
+ font-weight : normal;
+ line-height : normal;
+ margin-bottom:30px;
+}
+
+
+
+
+/* Headings */
+h1, h2, h3, h4, h5, th {
+ font-family :Arial, Helvetica, sans-serif;
+ font-size:1.2em;
+}
+
+
+p {
+ font-size : 1em;
+ width:80%;
+}
+
+pre, code {
+ font-family : "Courier New", Courier, monospace;
+ font-size : 12px;
+ line-height : normal;
+}
+
+
+
+table {
+ border:0;
+ margin-bottom:10px;
+ margin-top:10px;
+}
+
+
+tr, td {
+ border-top: 0px solid;
+ border-left: 0px solid;
+ padding-top:8px;
+ padding-bottom:8px;
+}
+
+
+
+hr {
+ border:0;
+ height:1px;
+ padding:0;
+ margin:0;
+ margin-bottom:4px;
+
+}
+
+
+
+dd, th, td, font {
+ font-size:1.0em;
+ line-height:1.0em;
+}
+
+
+
+dt {
+ margin-bottom:0px;
+}
+
+
+
+dd {
+ margin-top:2px;
+ margin-bottom:4px;
+}
+
+
+
+a {
+ text-decoration: underline;
+ font-weight: normal;
+}
+
+a:hover,
+a:active {
+ text-decoration: underline;
+ font-weight: normal;
+}
+
+a:visited,
+a:link:visited {
+ text-decoration: underline;
+ font-weight: normal;
+}
+
+
+img {
+ border: 0px solid #000000;
+}
+
+
+
+/* Navigation bar fonts */
+.NavBarCell1 {
+ border:0;
+}
+
+.NavBarCell1Rev {
+ border:0;
+}
+
+.NavBarFont1 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:1.1em;
+}
+
+
+.NavBarFont1 b {
+ font-weight:normal;
+}
+
+
+
+.NavBarFont1:after, .NavBarFont1Rev:after {
+ font-weight:normal;
+ content: " \\";
+}
+
+
+.NavBarFont1Rev {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:1.1em;
+}
+
+.NavBarFont1Rev b {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:1.1em;
+ font-weight:normal;
+}
+
+.NavBarCell2 {
+ font-family: Arial, Helvetica, sans-serif;
+}
+
+.NavBarCell3 {
+ font-family: Arial, Helvetica, sans-serif;
+}
+
+
+
+font.FrameItemFont {
+ font-family: Helvetica, Arial, sans-serif;
+ font-size:1.1em;
+ line-height:1.1em;
+}
+
+font.FrameHeadingFont {
+ font-family: Helvetica, Arial, sans-serif;
+ line-height:32px;
+}
+
+/* Font used in left-hand frame lists */
+.FrameTitleFont {
+ font-family: Helvetica, Arial, sans-serif
+}
+
+
+.toggleList {
+ padding:0;
+ margin:0;
+ margin-top:12px;
+}
+
+.toggleList dt {
+ font-weight:bold;
+ font-size:12px;
+ font-family:arial,sans-serif;
+ padding:0px;
+ margin:10px 0px 10px 0px;
+}
+
+.toggleList dt span {
+ font-family: monospace;
+ padding:0;
+ margin:0;
+}
+
+
+.toggleList dd {
+ margin:0;
+ padding:0;
+}
+
+html.isjs .toggleList dd {
+ display: none;
+}
+
+.toggleList pre {
+ padding: 4px 4px 4px 4px;
+}
+
+
+
+
+
+/* COLORS */
+
+pre, code {
+ color: #000000;
+}
+
+
+body {
+ color : #333333;
+ background-color :#FFFFFF;
+}
+
+
+h1, h2, h3, h4, h5, h6 {
+ color:#555;
+}
+
+a,
+.toggleList dt {
+ color: #1a7eb0;
+}
+
+a:hover,
+a:active {
+ color: #1a7eb0;
+}
+
+a:visited,
+a:link:visited {
+ color: #1a7eb0;
+}
+
+td,tr {
+ border-color: #999999;
+}
+
+hr {
+ color:#999999;
+ background:#999999;
+}
+
+
+.TableHeadingColor {
+ background: #dcdcdc;
+ color: #555;
+}
+
+
+.TableSubHeadingColor {
+ background: #EEEEFF
+}
+
+.TableRowColor {
+ background: #FFFFFF
+}
+
+
+.NavBarCell1 {
+ background-color:#dcdcdc;
+ color:#000;
+}
+
+.NavBarCell1 a {
+ color:#333;
+}
+
+
+.NavBarCell1Rev {
+ background-color:transparent;
+}
+
+.NavBarFont1 {
+ color:#333;
+}
+
+
+.NavBarFont1Rev {
+ color:#fff;
+}
+
+.NavBarCell2 {
+ background-color:#999;
+}
+
+.NavBarCell2 a {
+ color:#fff;
+}
+
+
+
+.NavBarCell3 {
+ background-color:#dcdcdc;
+}
+
View
155 src/patchy/Bicubic.java
@@ -0,0 +1,155 @@
+package patchy;
+
+import processing.core.PVector;
+
+/*
+
+ This file started out as Ken Perlin's superb Cubic class, available here:
+
+ http://mrl.nyu.edu/~perlin/cubic/Cubic_java.html
+
+ I have modified it extensively, but include his attribution, with
+ gratitude and respect.
+
+ Java class to implement cubic and bicubic splines
+ by Ken Perlin @ NYU, 1998, 2004.
+ You have my permission to use freely, as long as you keep the attribution. - Ken Perlin
+
+ */
+/*
+ The Patchy Processing library, which provides an easy-to-use
+ bicubic patch object for 3D graphics.
+
+ Copyright 2008 Jonathan Feinberg
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+public class Bicubic
+{
+ public static final double[][] BEZIER = { // Bezier basis matrix
+ { -1, 3, -3, 1 }, //
+ { 3, -6, 3, 0 }, //
+ { -3, 3, 0, 0 }, //
+ { 1, 0, 0, 0 } };
+ public static final double[][] BSPLINE = { // BSpline basis matrix
+ { -1. / 6, 3. / 6, -3. / 6, 1. / 6 }, //
+ { 3. / 6, -6. / 6, 3. / 6, 0. },//
+ { -3. / 6, 0., 3. / 6, 0. }, //
+ { 1. / 6, 4. / 6, 1. / 6, 0. } };
+ public static final double[][] CATMULL_ROM = { // Catmull-Rom basis matrix
+ { -0.5, 1.5, -1.5, 0.5 }, //
+ { 1, -2.5, 2, -0.5 }, //
+ { -0.5, 0, 0.5, 0 }, //
+ { 0, 1, 0, 0 } };
+ public static final double[][] HERMITE = { // Hermite basis matrix
+ { 2, -2, 1, 1 }, //
+ { -3, 3, -2, -1 }, //
+ { 0, 0, 1, 0 }, //
+ { 1, 0, 0, 0 } };
+
+ final double[][] C = new double[4][4];
+
+ public Bicubic(final double[][] basis, final double[][] controlPoints)
+ {
+ double[][] T = new double[4][4];
+
+ for (int i = 0; i < 4; i++)
+ // T = G MT
+ for (int j = 0; j < 4; j++)
+ for (int k = 0; k < 4; k++)
+ T[i][j] += controlPoints[i][k] * basis[j][k];
+
+ for (int i = 0; i < 4; i++)
+ // C = M T
+ for (int j = 0; j < 4; j++)
+ for (int k = 0; k < 4; k++)
+ C[i][j] += basis[i][k] * T[k][j];
+
+ // C = multiply(basis, multiply(controlPoints, basis));
+ }
+
+ private static class EvalResult
+ {
+ public final float value, du, dv;
+
+ public EvalResult(final double value, final double du, final double dv)
+ {
+ this.value = (float) value;
+ this.du = (float) du;
+ this.dv = (float) dv;
+ }
+ }
+
+ public static VertexWithNormal eval(final Bicubic x, final Bicubic y,
+ final Bicubic z, final double u, final double v)
+ {
+ final EvalResult xr = x.eval(u, v);
+ final EvalResult yr = y.eval(u, v);
+ final EvalResult zr = z.eval(u, v);
+ final PVector vertex = new PVector(xr.value, yr.value, zr.value);
+ final PVector normal = new PVector(xr.du, yr.du, zr.du).cross(
+ new PVector(xr.dv, yr.dv, zr.dv)).normalize(null);
+ return new VertexWithNormal(vertex, normal);
+ }
+
+ public EvalResult eval(final double u, final double v)
+ {
+ final double usquare = u * u;
+ final double[][] U = new double[][] { { usquare * u, usquare, u, 1 } };
+ final double vsquare = v * v;
+ final double[][] V = new double[][] { { vsquare * v }, { vsquare }, { v }, { 1 } };
+ final double[][] dU = new double[][] { { 3 * usquare, 2 * u, 1, 0 } };
+ final double[][] dV = new double[][] { { 3 * vsquare }, { 2 * v }, { 1 }, { 0 } };
+ final double[][] cv = multiply(C, V);
+ final double value = multiply0_0(U, cv);
+ final double du = multiply0_0(dU, cv);
+ final double dv = multiply0_0(U, multiply(C, dV));
+ return new EvalResult(value, du, dv);
+ }
+
+ private static double[][] multiply(final double[][] a, final double[][] b)
+ {
+ final int nRows = a.length;
+ final int nCols = b[0].length;
+ final int nSum = a[0].length;
+ double[][] outData = new double[nRows][nCols];
+ for (int row = 0; row < nRows; row++)
+ {
+ for (int col = 0; col < nCols; col++)
+ {
+ double sum = 0;
+ for (int i = 0; i < nSum; i++)
+ sum += a[row][i] * b[i][col];
+ outData[row][col] = sum;
+ }
+ }
+ return outData;
+ }
+
+ private static double multiply0_0(final double[][] a, final double[][] b)
+ {
+ final int nSum = a[0].length;
+ double sum = 0;
+ for (int i = 0; i < nSum; i++)
+ sum += a[0][i] * b[i][0];
+ return sum;
+ }
+
+ public static void main(final String[] args)
+ {
+ final double[][] cpX = new double[][] { { 23, 41, 59, 77 }, { 23, 41, 59, 77 },
+ { 23, 41, 59, 77 }, { 23, 41, 59, 77 } };
+ Bicubic cubic = new Bicubic(BSPLINE, cpX);
+ System.err.println(cubic.eval(0, 0).value);
+ }
+}
View
125 src/patchy/BoundingVolume.java
@@ -0,0 +1,125 @@
+/*
+ The Patchy Processing library, which provides an easy-to-use
+ bicubic patch object for 3D graphics.
+
+ Copyright 2008 Jonathan Feinberg
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+package patchy;
+
+import java.text.DecimalFormat;
+
+import processing.core.PVector;
+
+/**
+ * Immutable
+ * @author jdf
+ *
+ */
+public class BoundingVolume
+{
+ /**
+ * Immutable
+ * @author jdf
+ */
+ public static class Range
+ {
+ public final double min;
+ public final double max;
+
+ Range()
+ {
+ min = Double.MAX_VALUE;
+ max = -Double.MAX_VALUE;
+ }
+
+ private Range(final double min, final double max)
+ {
+ this.min = min;
+ this.max = max;
+ }
+
+ Range with(final double value)
+ {
+ return new Range(value < min ? value : min, value > max ? value : max);
+ }
+
+ public float center()
+ {
+ return (float) (min + ((max - min) / 2.0));
+ }
+
+ public float length()
+ {
+ return (float) (max - min);
+ }
+
+ private static final DecimalFormat F = new DecimalFormat("0.0");
+
+ @Override
+ public String toString()
+ {
+ return "[" + F.format(min) + "," + F.format(max) + "]";
+ }
+ }
+
+ public final Range x, y, z;
+
+ BoundingVolume()
+ {
+ this(new Range(), new Range(), new Range());
+ }
+
+ private BoundingVolume(final Range x, final Range y, final Range z)
+ {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ BoundingVolume with(final PVector v)
+ {
+ return with(v.x, v.y, v.z);
+ }
+
+ BoundingVolume with(final double xv, final double yv, final double zv)
+ {
+ return new BoundingVolume(x.with(xv), y.with(yv), z.with(zv));
+ }
+
+ public float maxDimension()
+ {
+ double max = x.length();
+ max = Math.max(max, y.length());
+ max = Math.max(max, z.length());
+ return (float) max;
+ }
+
+ public PVector center()
+ {
+ return new PVector(x.center(), y.center(), z.center());
+ }
+
+ public float boundingSphereRadius()
+ {
+ final double m = maxDimension();
+ return (float) Math.sqrt(2 * m * m);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "x:" + x + ", y:" + y + ", z:" + z;
+ }
+}
View
283 src/patchy/Patch.java
@@ -0,0 +1,283 @@
+/*
+ The Patchy Processing library, which provides an easy-to-use
+ bicubic patch object for 3D graphics.
+
+ Copyright 2008 Jonathan Feinberg
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+package patchy;
+
+import processing.core.PApplet;
+import processing.core.PConstants;
+import processing.core.PVector;
+
+/**
+ * Provides an easy-to-use bicubic patch for Processing.
+ *
+ * You construct it with a 4x4 collection of control points, then
+ * simply call its <code>draw()</code> method as needed.
+ *
+ * The control points can be given as a 4x4 array of PVectors,
+ * 3 4x4 arrays of floats (interprested as the x, y, and z coordinates
+ * respectively), or 3 4x4 arrays of doubles (interpreted like the
+ * floats). All internal operations are done in double-precision,
+ * which is then rounded down for drawing in PApplet.
+ *
+ * A Patch has a BoundingVolume, which is useful for scaling and
+ * positioning when drawing.
+ *
+ * This class is not thread-safe. In particular, if you modify a Patch's
+ * control points while another thread is calling <code>draw()</code> on the
+ * same instance, results are undefined.
+ *
+ * @author jdf
+ *
+ */
+public class Patch
+{
+ private static final int DEFAULT_GRID_STEPS = 20;
+
+ public static final double[][] BEZIER = Bicubic.BEZIER;
+ public static final double[][] BSPLINE = Bicubic.BSPLINE;
+ public static final double[][] CATMULL_ROM = Bicubic.CATMULL_ROM;
+ public static final double[][] HERMITE = Bicubic.HERMITE;
+
+ // What kind of patch?
+ private double[][] basis;
+
+ // The control points decomposed into x, y, and z coords
+ private final double[][] cpX;
+ private final double[][] cpY;
+ private final double[][] cpZ;
+
+ private boolean dirty = true;
+ private BoundingVolume bounds = null;
+ private int gridSteps;
+
+ private VertexWithNormal[][] rasterizedPoints;
+
+ public static Patch create(final double[][] basis, final PVector[][] controlPoints)
+ {
+ return create(basis, controlPoints, DEFAULT_GRID_STEPS);
+ }
+
+ public static Patch create(final double[][] basis, final PVector[][] controlPoints,
+ final int gridSteps)
+ {
+ if (basis.length != 4 || basis[0].length != 4)
+ throw new IllegalArgumentException("basis must be a 4x4 matrix");
+ if (controlPoints.length != 4 || controlPoints[0].length != 4)
+ throw new IllegalArgumentException("controlPoints must be a 4x4 matrix");
+
+ final double[][] cpX = new double[4][4];
+ final double[][] cpY = new double[4][4];
+ final double[][] cpZ = new double[4][4];
+
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 4; j++)
+ {
+ cpX[i][j] = controlPoints[i][j].x;
+ cpY[i][j] = controlPoints[i][j].y;
+ cpZ[i][j] = controlPoints[i][j].z;
+ }
+ return new Patch(basis, gridSteps, cpX, cpY, cpZ, false);
+ }
+
+ public static Patch create(final double[][] basis, final float[][] cpX,
+ final float[][] cpY, final float[][] cpZ)
+ {
+ return create(basis, cpX, cpY, cpZ, DEFAULT_GRID_STEPS);
+ }
+
+ public static Patch create(final double[][] basis, final float[][] cpX,
+ final float[][] cpY, final float[][] cpZ, final int gridSteps)
+ {
+ if (basis.length != 4 || basis[0].length != 4)
+ throw new IllegalArgumentException("basis must be a 4x4 matrix");
+ if (cpX.length != 4 || cpX[0].length != 4)
+ throw new IllegalArgumentException("cpX must be a 4x4 matrix");
+ if (cpY.length != 4 || cpY[0].length != 4)
+ throw new IllegalArgumentException("cpY must be a 4x4 matrix");
+ if (cpZ.length != 4 || cpZ[0].length != 4)
+ throw new IllegalArgumentException("cpZ must be a 4x4 matrix");
+
+ final double[][] dcpX = new double[4][4];
+ final double[][] dcpY = new double[4][4];
+ final double[][] dcpZ = new double[4][4];
+
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 4; j++)
+ {
+ dcpX[i][j] = cpX[i][j];
+ dcpY[i][j] = cpY[i][j];
+ dcpZ[i][j] = cpZ[i][j];
+ }
+ return new Patch(basis, gridSteps, dcpX, dcpY, dcpZ, false);
+ }
+
+ public static Patch create(final double[][] basis, final double[][] cpX,
+ final double[][] cpY, final double[][] cpZ)
+ {
+ return create(basis, cpX, cpY, cpZ, DEFAULT_GRID_STEPS);
+ }
+
+ public static Patch create(final double[][] basis, final double[][] cpX,
+ final double[][] cpY, final double[][] cpZ, final int gridSteps)
+ {
+ if (basis.length != 4 || basis[0].length != 4)
+ throw new IllegalArgumentException("basis must be a 4x4 matrix");
+ if (cpX.length != 4 || cpX[0].length != 4)
+ throw new IllegalArgumentException("cpX must be a 4x4 matrix");
+ if (cpY.length != 4 || cpY[0].length != 4)
+ throw new IllegalArgumentException("cpY must be a 4x4 matrix");
+ if (cpZ.length != 4 || cpZ[0].length != 4)
+ throw new IllegalArgumentException("cpZ must be a 4x4 matrix");
+ return new Patch(basis, gridSteps, cpX, cpY, cpZ, true);
+ }
+
+ private Patch(final double[][] basis, final int gridSteps, final double[][] cpX,
+ final double[][] cpY, final double[][] cpZ, final boolean clone)
+ {
+ this.basis = basis.clone();
+ this.gridSteps = gridSteps;
+ this.cpX = clone ? cpX.clone() : cpX;
+ this.cpY = clone ? cpY.clone() : cpY;
+ this.cpZ = clone ? cpZ.clone() : cpZ;
+ rasterize();
+ }
+
+ public BoundingVolume getBounds()
+ {
+ if (dirty)
+ rasterize();
+ return bounds;
+ }
+
+ private void rasterize()
+ {
+ bounds = new BoundingVolume();
+
+ final Bicubic cX = new Bicubic(basis, cpX);
+ final Bicubic cY = new Bicubic(basis, cpY);
+ final Bicubic cZ = new Bicubic(basis, cpZ);
+ rasterizedPoints = new VertexWithNormal[gridSteps + 1][gridSteps + 1];
+ for (int i = 0; i <= gridSteps; i++)
+ {
+ final double u = (double) i / gridSteps;
+ for (int j = 0; j <= gridSteps; j++)
+ {
+ final double v = (double) j / gridSteps;
+ rasterizedPoints[i][j] = Bicubic.eval(cX, cY, cZ, u, v);
+ bounds = bounds.with(rasterizedPoints[i][j].vertex);
+ }
+ }
+ dirty = false;
+ }
+
+ public void set(final int row, final int col, final double x, final double y,
+ final double z)
+ {
+ cpX[row][col] = x;
+ cpY[row][col] = y;
+ cpZ[row][col] = z;
+ dirty = true;
+ }
+
+ public void set(final int row, final int col, final PVector cp)
+ {
+ set(row, col, cp.x, cp.y, cp.z);
+ }
+
+ public void setX(final int row, final int col, final double val)
+ {
+ cpX[row][col] = val;
+ dirty = true;
+ }
+
+ public void setY(final int row, final int col, final double val)
+ {
+ cpY[row][col] = val;
+ dirty = true;
+ }
+
+ public void setZ(final int row, final int col, final double val)
+ {
+ cpZ[row][col] = val;
+ dirty = true;
+ }
+
+ public void setBasis(final double[][] basis)
+ {
+ this.basis = basis.clone();
+ dirty = true;
+ }
+
+ public void draw(final PApplet p)
+ {
+ draw(p, true);
+ }
+
+ public void draw(final PApplet p, final boolean norm)
+ {
+ if (dirty)
+ rasterize();
+ final VertexWithNormal[][] rp = rasterizedPoints;
+ for (int i = 0; i < gridSteps; i++)
+ for (int j = 0; j < gridSteps; j++)
+ {
+ final PVector normA = rp[i][j].normal;
+ final PVector vertA = rp[i][j].vertex;
+ final PVector normB = rp[i + 1][j].normal;
+ final PVector vertB = rp[i + 1][j].vertex;
+ final PVector normC = rp[i][j + 1].normal;
+ final PVector vertC = rp[i][j + 1].vertex;
+ final PVector normD = rp[i + 1][j + 1].normal;
+ final PVector vertD = rp[i + 1][j + 1].vertex;
+
+ p.beginShape();
+ if (norm)
+ p.normal(normA.x, normA.y, normA.z);
+ p.vertex(vertA.x, vertA.y, vertA.z);
+ if (norm)
+ p.normal(normB.x, normB.y, normB.z);
+ p.vertex(vertB.x, vertB.y, vertB.z);
+ if (norm)
+ p.normal(normC.x, normC.y, normC.z);
+ p.vertex(vertC.x, vertC.y, vertC.z);
+ p.endShape(PConstants.CLOSE);
+ p.beginShape();
+ if (norm)
+ p.normal(normB.x, normB.y, normB.z);
+ p.vertex(vertB.x, vertB.y, vertB.z);
+ if (norm)
+ p.normal(normD.x, normD.y, normD.z);
+ p.vertex(vertD.x, vertD.y, vertD.z);
+ if (norm)
+ p.normal(normC.x, normC.y, normC.z);
+ p.vertex(vertC.x, vertC.y, vertC.z);
+ p.endShape(PConstants.CLOSE);
+ }
+ }
+
+ public void drawControlPoints(final PApplet p)
+ {
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 4; j++)
+ {
+ p.translate((float) cpX[i][j], (float) cpY[i][j], (float) cpZ[i][j]);
+ p.box(.5f);
+ p.translate((float) -cpX[i][j], (float) -cpY[i][j], (float) -cpZ[i][j]);
+ }
+ }
+}
View
33 src/patchy/VertexWithNormal.java
@@ -0,0 +1,33 @@
+/*
+ The Patchy Processing library, which provides an easy-to-use
+ bicubic patch object for 3D graphics.
+
+ Copyright 2008 Jonathan Feinberg
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+package patchy;
+
+import processing.core.PVector;
+
+class VertexWithNormal
+{
+ final PVector vertex;
+ final PVector normal;
+
+ VertexWithNormal(final PVector vertex, final PVector normal)
+ {
+ this.vertex = vertex;
+ this.normal = normal;
+ }
+}
View
BIN web/core.jar
Binary file not shown.
View
253 web/index.html
@@ -0,0 +1,253 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+<title>##yourLibrary##</title>
+<meta name="description" content="a library for the programming environment processing" />
+<meta name="keywords" content="processing.org, library" />
+<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+<meta http-equiv="Content-Language" content="en-us" />
+<meta name="ROBOTS" content="index,follow,archive" />
+<meta http-equiv="imagetoolbar" content="false" />
+<meta name="MSSmartTagsPreventParsing" content="true" />
+<meta name="author" content="##author##" />
+<meta name="Rating" content="General" />
+<meta name="revisit-after" content="7 Days" />
+<meta name="doc-class" content="Living Document" />
+<link rel="stylesheet" type="text/css" href="./stylesheet.css">
+</head>
+<body>
+ <div id="container">
+
+ <div id="header">
+ <h1>##yourLibrary## v##versionNumber##</h1>
+ </div>
+
+ <div id="menu" class="clear">
+ <ul>
+ <li><a href="#about">About</a> \ </li>
+ <li><a href="#download">Download</a> \ </li>
+ <li><a href="#download">Installation</a> \ </li>
+ <!-- <li><a href="#examples">Examples</a> \ </li>-->
+ <li><a href="#demos">Demo</a> \ </li>
+ <li><a href="./reference/index.html" target="_blank">Reference</a></li>
+ <!-- <li><a href="#misc">Misc</a> \ </li> -->
+ <!-- <li><a href="#images">Images</a> \ </li> -->
+ </ul>
+ </div>
+
+ <div id="content" class="clear">
+
+ <div id="demos" class="clear">
+ <h2>demo</h2>
+ <table><tr>
+ <td>
+ <!--[if !IE]> -->
+ <object classid="java:HelloPeasy.class"
+ type="application/x-java-applet"
+ archive="HelloPeasy.jar,PeasyCam.jar,core.jar"
+ width="200" height="200"
+ standby="Loading Processing software..." >
+
+ <param name="archive" value="HelloPeasy.jar,PeasyCam.jar,core.jar" />
+
+ <param name="mayscript" value="true" />
+ <param name="scriptable" value="true" />
+
+ <param name="image" value="loading.gif" />
+ <param name="boxmessage" value="Loading Processing software..." />
+ <param name="boxbgcolor" value="#FFFFFF" />
+
+ <param name="test_string" value="outer" />
+ <!--<![endif]-->
+
+ <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
+ codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0_15-windows-i586.cab"
+ width="200" height="200"
+ standby="Loading Processing software..." >
+
+ <param name="code" value="HelloPeasy" />
+ <param name="archive" value="HelloPeasy.jar,PeasyCam.jar,core.jar" />
+
+ <param name="mayscript" value="true" />
+ <param name="scriptable" value="true" />
+
+ <param name="image" value="loading.gif" />
+ <param name="boxmessage" value="Loading Processing software..." />
+ <param name="boxbgcolor" value="#FFFFFF" />
+
+ <param name="test_string" value="inner" />
+
+ <p>
+ <strong>
+ This browser does not have a Java Plug-in.
+ <br />
+ <a href="http://java.sun.com/products/plugin/downloads/index.html" title="Download Java Plug-in">
+ Get the latest Java Plug-in here.
+ </a>
+ </strong>
+ </p>
+
+ </object>
+
+ <!--[if !IE]> -->
+ </object>
+ <!--<![endif]-->
+ <p>
+ left-drag to rotate
+ <br/>
+ right-drag up and down to zoom
+ <br/>
+ middle-drag (cmd-left-drag on mac) to pan
+ <br/>
+ double-click to reset
+ </p>
+
+ </td>
+ <td>
+<pre>import peasy.*;
+
+PeasyCam cam;
+
+void setup() {
+ size(200,200,P3D);
+ cam = new PeasyCam(this, 100);
+}
+void draw() {
+ rotateX(-.5);
+ rotateY(-.5);
+ background(0);
+ fill(255,0,0);
+ box(30);
+ pushMatrix();
+ translate(0,0,20);
+ fill(0,0,255);
+ box(5);
+ popMatrix();
+}
+</pre>
+ </td>
+ </tr></table>
+ </div>
+
+
+ <div id="about">
+ <h2>##yourLibrary## v##versionNumber##</h2>
+ <p>
+ A library by <a href="##yourLink##">##author##</a> for the programming environment <a href="http://www.processing.org" target="_blank">processing</a>. Last update, ##date##.
+ </p>
+
+<p>PeasyCam provides a dead-simple mouse-driven camera for Processing. </p>
+<h3>Example</h3>
+<pre>PeasyCam camera;
+
+void setup() {
+ camera = new PeasyCam(this, 0, 0, 0, 50);
+}</pre>
+<p>
+ That's it. Now a mouse left-drag will rotate the camera around the subject,
+ a right drag will zoom in and out, and a middle-drag (command-left-drag on mac) will pan. A
+ double-click restores the camera to its original position. The shift key constrains rotation
+ and panning to one axis or the other.
+</p>
+<p>
+ The PeasyCam is positioned on a sphere whose radius is the given
+ distance from the look-at point. Rotations are around axes that
+ pass through the looked-at point.
+</p>
+
+<p>
+ PeasyCam is impervious to gimbal lock, and has no known "singularities" or
+ discontinuities in its behavior. It relies on the excellent
+ <a href="http://commons.apache.org/math/">Apache Commons Math</a>
+ <a href="http://commons.apache.org/math/userguide/geometry.html">geometry package</a>
+ for its rotations.
+</p>
+
+ <div id="download">
+ <h2>Download</h2>
+ <p>
+ Download ##yourLibrary## version ##versionNumber## in
+ <a href="./download/##yourLibrary##.zip">.zip format</a>.
+ </p>
+ <h2>Installation</h2>
+ <p>
+ Unzip and put the extracted ##yourLibrary## folder into the libraries folder of your processing sketches. Reference and examples are included in the ##yourLibrary## folder.
+ </p>
+ </div>
+
+
+<h3>Constructors</h3>
+<pre class="prettyprint">PeasyCam(PApplet parent, double lookAtX, double lookAtY, double lookAtZ, double distance);
+PeasyCam(PApplet parent, double distance); // look at 0,0,0
+</pre>
+
+<h3>Methods</h3>
+<pre class="prettyprint">camera.setMouseControlled(boolean isMouseControlled);
+camera.lookAt(double x, double y, double z);
+camera.rotateX(double angle); // rotate around the x-axis passing through the subject
+camera.rotateY(double angle); // rotate around the y-axis passing through the subject
+camera.rotateZ(double angle); // rotate around the z-axis passing through the subject
+camera.setDistance(double d); // distance from looked-at point
+camera.pan(double dx, double dy); // move the looked-at point relative to current orientation</pre>
+
+ </div>
+
+
+
+
+ <div id="resources">
+ <p><strong>Keywords</strong> ##keywords##</p>
+ <p><strong>Reference</strong>. Have a look at the javadoc reference <a href="./reference/index.html" target="_blank">here</a>. a copy of the reference is included in the .zip as well.</p>
+ <p><strong>Source</strong>. The source code of ##yourLibrary## is available at <a href="##source:url##">##source:host##</a>, and its repository can be browsed <a href="##source:repository##" target="_blank">here</a>.</p>
+ </div>
+
+ <!--
+ <div id="examples" class="clear">
+ <h2>Examples</h2>
+ <p>Find a list of examples in the current distribution of ##yourLibrary##, or have a look at them by following the links below.</p>
+ <ul>
+ ##examples##
+ </ul>
+ </div>
+ -->
+
+ <div id="info">
+ <h2>Tested</h2>
+ <p>
+ <!-- on which platform has the library been tested? -->
+ <strong>Platform</strong> ##tested:platform##
+
+ <!-- which processing version did you use for testing your library? -->
+ <br /><strong>Processing</strong> ##tested:processingVersion##
+
+ <!-- does your library depend on any other library or framework? -->
+ <br /><strong>Dependencies</strong> ##tested:dependencies##
+ </p>
+ </div>
+
+
+
+ <!-- use the misc section for other relevant information. Activate the link to the misc section in the menu above. -->
+ <!--
+ <div id="misc" class="clear">
+ <p></p>
+ </div>
+ -->
+
+ <!-- use the images/screenshots section. Activate the link to the misc section in the menu above. -->
+ <!--
+ <div id="images" class="clear">
+ </div>
+ -->
+
+
+ <br class="clear" />
+ </div>
+
+ <div id="footer">
+ <p>by ##author##, 2008.</p>
+ </div>
+ </div>
+</body>
+</html>
View
204 web/stylesheet.css
@@ -0,0 +1,204 @@
+/* processingLibs style by andreas schlegel, sojamo. */
+
+
+* {
+ margin:0;
+ padding:0;
+ border:0;
+}
+
+
+body {
+ font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-size : 100%;
+ font-size : 0.70em;
+ font-weight : normal;
+ line-height : normal;
+}
+
+
+
+#container {
+ margin-left:64px;
+ background-color:#fff;
+}
+
+#header {
+ float:left;
+ padding-top:24px;
+ padding-bottom:48px;
+}
+
+#menu {
+ margin-top:16px;
+ float:left;
+ margin-bottom:64px;
+}
+
+
+#about,
+#download,
+#examples,
+#misc {
+ width:480px;
+ float:left;
+ margin-right:24px;
+}
+
+#demos { float: right; }
+
+#resources, #info {
+ width:320px;
+ float:left;
+}
+
+
+.clear {
+ clear:both;
+}
+
+#footer {
+ margin-top:300px;
+ height:20px;
+ margin-bottom:32px;
+}
+
+
+ul {
+ list-style:none;
+ padding:0;
+ margin:0;
+}
+
+
+#menu ul li, #subMenu ul li {
+ float:left;
+ padding-right:6px;
+}
+
+
+
+
+
+
+/* Headings */
+
+h1 {
+ font-size:2em;
+ font-weight:normal;
+}
+
+
+h2, h3, h4, h5, th {
+ font-size:1.3em;
+ font-weight:normal;
+ margin-bottom:4px;
+}
+
+
+
+p {
+ font-size:1em;
+ width:90%;
+ margin-bottom:32px;
+}
+
+
+pre, code {
+ font-family:"Consolas", "Courier New", Courier, monospace;
+ font-size:1em;
+ line-height:normal;
+}
+
+pre { margin-bottom: 1em }
+
+hr {
+ border:0;
+ height:1px;
+ margin-bottom:24px;
+}
+
+
+a {
+ text-decoration: underline;
+ font-weight: normal;
+}
+
+
+a:hover,
+a:active {
+ text-decoration: underline;
+ font-weight: normal;
+}
+
+
+a:visited,
+a:link:visited {
+ text-decoration: underline;
+ font-weight: normal;
+}
+
+
+
+img {
+ border: 0px solid #000000;
+}
+
+
+
+
+
+/* COLORS */
+
+
+body {
+ color : #333;
+ background-color :#fff;
+}
+
+
+#header {
+ background-color:#fff;
+ color:#333;
+}
+
+
+
+h1, h2, h3, h4, h5, h6 {
+ color:#666;
+}
+
+
+pre, code {
+ color: #000000;
+}
+
+
+a,strong {
+ color: #333;
+}
+
+
+a:hover,
+a:active {
+ color: #333;
+}
+
+
+a:visited,
+a:link:visited {
+ color: #333;
+}
+
+
+#footer, #menu {
+ background-color:#fff;
+ color:#333;
+}
+
+
+#footer a, #menu a {
+ color:#333;
+}
+
+td { vertical-align: top; padding-right: 1em }

0 comments on commit f93b14f

Please sign in to comment.