Statements and Comments
Coordinates
Width and Height
Setup and Draw
No Loop
Loop
Redraw
Functions
Recursion
Recursion 2
Objects
Points and Lines
Shape Primitives
Vertices
Simple Curves
Bezier
Variables
Integers and Floats
True/False
Array
Array 2D
Array Objects
Characters and Strings
Datatype Conversion
Variable Scope
Iteration
Embedded Iteration
Conditionals 1
Conditionals 2
Logical Operators
Increment/Decrement
Modulo
Operator Precedence
Distance 1D
Distance 2D
Sine
Sine and Cosine
Additive Wave
Arctangent
Graphing 2D Equation
Koch
Madelbrot
Random
Noise 1D
Noise 2D
Noise 3D
NoiseWave
Polar to Cartesian
Continuous Lines
Pattern
Custom Tool
Letters
Words
Displaying
Background Image
Brightness
Pointillism
Histogram
Pixel Array
Linear Image
Transparency
Convolution
Edge Detection
Blur
Sequential
Sprite
Animated Sprite
Alphamask
Hue
Saturation
Brightness
Reading
Creating
Relativity
Translate
Scale
Rotate
Limb
Linear
Bounce
Nonlinear
Moving On Curves
Brownian Motion
Collision
Mouse 1D
Mouse 2D
Click
Mouse Signals
Interpolate
Constrain
Storing Input
Mouse Functions
Keyboard
Keyboard Functions
Follow 1
Follow 2
Follow 3
Reach 1
Reach 2
Reach 3
Rollover
Button
Buttons
Image Button
Handles
Scrollbar
Spring
Springs
Cellular Automata 1 (Life)
Cellular Automata 2
Cellular Automata 3
Wolfram CA
Tree
Fluid
Smoke
Simple Particle System
Multiple Particle Systems
Smoke Particle System
Primitives 3D
Vertices 3D
RGB Cube
Translate 3D
Rotate 3D
Push and Pop
Embedding Push and Pop
Extrusion
Zoom
Explode
Letter K
Kinetic Type
Typing
Lights
Directional
Spot
Ortho
Perspective
Ortho vs. Perpective
Movie
Pixelate
Using Capture
Mirror
Mirror2
Brightness Tracking
ASCII Video
Disgrand
Framingham
HSV Space
Live Pocky
Radial Pocky
One Frame
Multiple Frames
Mouse Press
Large Page
Many Pages
Complex 3D
ValueClient
ValueServer
HTTP Client
Chat Server
Binary input
Analog input
Call / Response
Duplex
Matrix
Examples for Processing (BETA) version 116+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know .
Mouse Functions.
Click on the box and drag it across the screen.
Updated 19 January 2003
float bx;
float by;
int bs = 20;
boolean bover = false;
boolean locked = false;
float bdifx = 0.0;
float bdify = 0.0;
void setup()
{
size(200, 200);
bx = width/2.0;
by = height/2.0;
rectMode(CENTER_RADIUS);
}
void draw()
{
background(0);
// Test if the cursor is over the box
if (mouseX > bx-bs && mouseX < bx+bs &&
mouseY > by-bs && mouseY < by+bs) {
bover = true;
if(!locked) {
stroke(255);
fill(153);
}
} else {
stroke(153);
fill(153);
bover = false;
}
// Draw the box
rect(bx, by, bs, bs);
}
void mousePressed() {
if(bover) {
locked = true;
fill(255, 255, 255);
} else {
locked = false;
}
bdifx = mouseX-bx;
bdify = mouseY-by;
}
void mouseDragged() {
if(locked) {
bx = mouseX-bdifx;
by = mouseY-bdify;
}
}
void mouseReleased() {
locked = false;
}