Permalink
Browse files

Add a whole lotta stuff

  • Loading branch information...
jbuck committed Oct 27, 2011
1 parent c9867a1 commit 81edf0eb9b7948a0806dbf58523ec37e9c748ae9
Showing with 1,034 additions and 0 deletions.
  1. +30 −0 examples/basic/arm.pde
  2. +95 −0 examples/basic/arraylist.pde
  3. +13 −0 examples/basic/color.pde
  4. +44 −0 examples/basic/colorwheel.pde
  5. +33 −0 examples/basic/coollines.pde
  6. +27 −0 examples/basic/coordinatesystem.pde
  7. +17 −0 examples/basic/createimage.pde
  8. BIN examples/basic/eames.jpg
  9. +30 −0 examples/basic/easing.pde
  10. +13 −0 examples/basic/fillstrokeweight.pde
  11. +22 −0 examples/basic/functions.pde
  12. +2 −0 examples/basic/google-code-prettify/lang-apollo.js
  13. +18 −0 examples/basic/google-code-prettify/lang-clj.js
  14. +2 −0 examples/basic/google-code-prettify/lang-css.js
  15. +1 −0 examples/basic/google-code-prettify/lang-go.js
  16. +2 −0 examples/basic/google-code-prettify/lang-hs.js
  17. +3 −0 examples/basic/google-code-prettify/lang-lisp.js
  18. +2 −0 examples/basic/google-code-prettify/lang-lua.js
  19. +2 −0 examples/basic/google-code-prettify/lang-ml.js
  20. +4 −0 examples/basic/google-code-prettify/lang-n.js
  21. +1 −0 examples/basic/google-code-prettify/lang-proto.js
  22. +2 −0 examples/basic/google-code-prettify/lang-scala.js
  23. +2 −0 examples/basic/google-code-prettify/lang-sql.js
  24. +1 −0 examples/basic/google-code-prettify/lang-tex.js
  25. +2 −0 examples/basic/google-code-prettify/lang-vb.js
  26. +3 −0 examples/basic/google-code-prettify/lang-vhdl.js
  27. +2 −0 examples/basic/google-code-prettify/lang-wiki.js
  28. +3 −0 examples/basic/google-code-prettify/lang-xq.js
  29. +2 −0 examples/basic/google-code-prettify/lang-yaml.js
  30. +1 −0 examples/basic/google-code-prettify/prettify.css
  31. +28 −0 examples/basic/google-code-prettify/prettify.js
  32. +13 −0 examples/basic/hashmap.pde
  33. +4 −0 examples/basic/helloworld.pde
  34. +117 −0 examples/basic/index.html
  35. BIN examples/basic/jelly.jpg
  36. +4 −0 examples/basic/jquery-1.6.4.js
  37. +31 −0 examples/basic/keyboard.pde
  38. +19 −0 examples/basic/loadimage.pde
  39. +27 −0 examples/basic/loop.pde
  40. +45 −0 examples/basic/mousesignals.pde
  41. +64 −0 examples/basic/objects.pde
  42. +23 −0 examples/basic/pgraphics.pde
  43. +14 −0 examples/basic/piechart.pde
  44. +28 −0 examples/basic/pointilism.pde
  45. +25 −0 examples/basic/pointsandlines.pde
  46. +24 −0 examples/basic/redraw.pde
  47. +26 −0 examples/basic/rotate.pde
  48. +28 −0 examples/basic/scale.pde
  49. +22 −0 examples/basic/setupanddraw.pde
  50. +10 −0 examples/basic/shapeprimitives.pde
  51. +18 −0 examples/basic/text.pde
  52. +33 −0 examples/basic/translate.pde
  53. +29 −0 examples/basic/variables.pde
  54. +23 −0 index.html
View
@@ -0,0 +1,30 @@
+float x = 50;
+float y = 100;
+float angle1 = 0.0;
+float angle2 = 0.0;
+float segLength = 50;
+
+void setup() {
+ size(200, 200);
+ smooth();
+ strokeWeight(20.0);
+ stroke(0, 100);
+}
+
+void draw() {
+ background(226);
+
+ angle1 = (mouseX/float(width) - 0.5) * -PI;
+ angle2 = (mouseY/float(height) - 0.5) * PI;
+
+ pushMatrix();
+ segment(x, y, angle1);
+ segment(segLength, 0, angle2);
+ popMatrix();
+}
+
+void segment(float x, float y, float a) {
+ translate(x, y);
+ rotate(a);
+ line(0, 0, segLength, 0);
+}
@@ -0,0 +1,95 @@
+ArrayList balls;
+int ballWidth = 48;
+
+void setup() {
+ size(200, 200);
+ smooth();
+ noStroke();
+
+ // Create an empty ArrayList
+ balls = new ArrayList();
+
+ // Start by adding one element
+ balls.add(new Ball(width/2, 0, ballWidth));
+}
+
+void draw() {
+ background(255);
+
+ // With an array, we say balls.length, with an ArrayList, we say balls.size()
+ // The length of an ArrayList is dynamic
+ // Notice how we are looping through the ArrayList backwards
+ // This is because we are deleting elements from the list
+ for (int i = balls.size()-1; i >= 0; i--) {
+ // An ArrayList doesn't know what it is storing so we have to cast the object coming out
+ Ball ball = (Ball) balls.get(i);
+ ball.move();
+ ball.display();
+ if (ball.finished()) {
+ // Items can be deleted with remove()
+ balls.remove(i);
+ }
+
+ }
+
+}
+
+void mousePressed() {
+ // A new ball object is added to the ArrayList (by default to the end)
+ balls.add(new Ball(mouseX, mouseY, ballWidth));
+}
+
+
+
+
+// Simple bouncing ball class
+
+class Ball {
+
+ float x;
+ float y;
+ float speed;
+ float gravity;
+ float w;
+ float life = 255;
+
+ Ball(float tempX, float tempY, float tempW) {
+ x = tempX;
+ y = tempY;
+ w = tempW;
+ speed = 0;
+ gravity = 0.1;
+ }
+
+ void move() {
+ // Add gravity to speed
+ speed = speed + gravity;
+ // Add speed to y location
+ y = y + speed;
+ // If square reaches the bottom
+ // Reverse speed
+ if (y > height) {
+ // Dampening
+ speed = speed * -0.8;
+ y = height;
+ }
+ }
+
+ boolean finished() {
+ // Balls fade out
+ life--;
+ if (life < 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ void display() {
+ // Display the circle
+ fill(0,life);
+ //stroke(0,life);
+ ellipse(x,y,w,w);
+ }
+}
+
View
@@ -0,0 +1,13 @@
+size(200, 200);
+noStroke();
+
+color inside = color(204, 102, 0);
+color middle = color(204, 153, 0);
+color outside = color(153, 51, 0);
+
+fill(outside);
+rect(0, 0, 200, 200);
+fill(middle);
+rect(40, 60, 120, 120);
+fill(inside);
+rect(60, 90, 80, 80);
@@ -0,0 +1,44 @@
+int segs = 12;
+int steps = 6;
+float rotAdjust = TWO_PI / segs / 2;
+float radius;
+float segWidth;
+float interval = TWO_PI / segs;
+
+void setup() {
+ size(200, 200);
+ background(127);
+ smooth();
+ ellipseMode(RADIUS);
+ noStroke();
+ // make the diameter 90% of the sketch area
+ radius = min(width, height) * 0.45;
+ segWidth = radius / steps;
+
+ drawShadeWheel();
+}
+
+void drawShadeWheel() {
+ for (int j = 0; j < steps; j++) {
+ color[] cols = {
+ color(255-(255/steps)*j, 255-(255/steps)*j, 0),
+ color(255-(255/steps)*j, (255/1.5)-((255/1.5)/steps)*j, 0),
+ color(255-(255/steps)*j, (255/2)-((255/2)/steps)*j, 0),
+ color(255-(255/steps)*j, (255/2.5)-((255/2.5)/steps)*j, 0),
+ color(255-(255/steps)*j, 0, 0),
+ color(255-(255/steps)*j, 0, (255/2)-((255/2)/steps)*j),
+ color(255-(255/steps)*j, 0, 255-(255/steps)*j),
+ color((255/2)-((255/2)/steps)*j, 0, 255-(255/steps)*j),
+ color(0, 0, 255-(255/steps)*j),
+ color(0, 255-(255/steps)*j, (255/2.5)-((255/2.5)/steps)*j),
+ color(0, 255-(255/steps)*j, 0),
+ color((255/2)-((255/2)/steps)*j, 255-(255/steps)*j, 0)
+ };
+ for (int i = 0; i < segs; i++) {
+ fill(cols[i]);
+ arc(width/2, height/2, radius, radius,
+ interval*i+rotAdjust, interval*(i+1)+rotAdjust);
+ }
+ radius -= segWidth;
+ }
+}
@@ -0,0 +1,33 @@
+int i = 0;
+void setup() { // this is run once.
+
+ // set the background color
+ background(255);
+
+ // canvas size (Integers only, please.)
+ size(300, 300);
+
+ // smooth edges
+ smooth();
+
+ // limit the number of frames per second
+ frameRate(30);
+
+ // set the width of the line.
+ strokeWeight(12);
+}
+
+void draw() { // this is run repeatedly.
+ // set the color
+ stroke(random(50), random(255), random(255), 100);
+
+ // draw the line
+ line(i, 0, random(0, width), height);
+
+ // move over a pixel
+ if (i < width) {
+ i++;
+ } else {
+ i = 0;
+ }
+}
@@ -0,0 +1,27 @@
+size(450, 450);
+
+background(255, 255, 255);
+
+fill(0);
+text("(0, 0)", 0, 25);
+text("X", width/2, 13);
+text("Y", 0, height/2);
+
+strokeWeight(2);
+stroke(255, 50, 50);
+line(30, 0, 30, height);
+line(0, 30, width, 30);
+
+strokeWeight(1);
+stroke(0);
+for (int i = 50; i < width; i = i + 20) {
+ line(i, 30, i, height);
+ line(30, i, width, i);
+}
+
+for (int i = 0; i <= 20; i++) {
+ textAlign(CENTER, BASELINE);
+ text(i, 40 + (i * 20), 25);
+ textAlign(RIGHT, BASELINE);
+ text(i, 25, 45 + (i * 20));
+}
@@ -0,0 +1,17 @@
+PImage img;
+
+void setup()
+{
+ size(200, 200);
+ img = createImage(120, 120, ARGB);
+ for(int i=0; i < img.pixels.length; i++) {
+ img.pixels[i] = color(0, 90, 102, i%img.width * 2);
+ }
+}
+
+void draw()
+{
+ background(204);
+ image(img, 33, 33);
+ image(img, mouseX-60, mouseY-60);
+}
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,30 @@
+float x;
+float y;
+float targetX, targetY;
+float easing = 0.05;
+
+void setup()
+{
+ size(200, 200);
+ smooth();
+ noStroke();
+}
+
+void draw()
+{
+ background( 51 );
+
+ targetX = mouseX;
+ float dx = targetX - x;
+ if(abs(dx) > 1) {
+ x += dx * easing;
+ }
+
+ targetY = mouseY;
+ float dy = targetY - y;
+ if(abs(dy) > 1) {
+ y += dy * easing;
+ }
+
+ ellipse(x, y, 33, 33);
+}
@@ -0,0 +1,13 @@
+size(200, 200);
+background(255);
+
+rect(5, 5, 90, 90);
+
+fill(50, 200, 50);
+rect(105, 5, 90, 90);
+
+strokeWeight(10);
+rect(10, 110, 80, 80);
+
+stroke(50, 50, 150);
+rect(110, 110, 80, 80);
@@ -0,0 +1,22 @@
+void setup() {
+ size(450, 450);
+ background(51);
+ noStroke();
+ smooth();
+ noLoop();
+}
+
+void draw() {
+ drawTarget(250, 250, 400, 10);
+ drawTarget(152, 16, 200, 3);
+ drawTarget(100, 144, 180, 5);
+}
+
+void drawTarget(int xloc, int yloc, int size, int num) {
+ float grayvalues = 255/num;
+ float steps = size/num;
+ for (int i = 0; i < num; i++) {
+ fill(i*grayvalues);
+ ellipse(xloc, yloc, size-i*steps, size-i*steps);
+ }
+}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,18 @@
+/*
+ Copyright (C) 2011 Google Inc.
+
+ 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.
+*/
+var a=null;
+PR.registerLangHandler(PR.createSimpleLexer([["opn",/^[([{]+/,a,"([{"],["clo",/^[)\]}]+/,a,")]}"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \xa0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn)\b/,a],
+["typ",/^:[\dA-Za-z-]+/]]),["clj"]);

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 81edf0e

Please sign in to comment.