@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Additive Wave
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Create a more complex wave by adding two waves together.
|
||||
*/
|
||||
|
||||
int xspacing = 8; // How far apart should each horizontal location be spaced
|
||||
int w; // Width of entire wave
|
||||
int maxwaves = 4; // total # of waves to add together
|
||||
|
||||
float theta = 0.0;
|
||||
float[] amplitude = new float[maxwaves]; // Height of wave
|
||||
float[] dx = new float[maxwaves]; // Value for incrementing X, to be calculated as a function of period and xspacing
|
||||
float[] yvalues; // Using an array to store height values for the wave (not entirely necessary)
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
frameRate(30);
|
||||
colorMode(RGB, 255, 255, 255, 100);
|
||||
smooth();
|
||||
w = width + 16;
|
||||
|
||||
for (int i = 0; i < maxwaves; i++) {
|
||||
amplitude[i] = random(10,30);
|
||||
float period = random(100,300); // How many pixels before the wave repeats
|
||||
dx[i] = (TWO_PI / period) * xspacing;
|
||||
}
|
||||
|
||||
yvalues = new float[w/xspacing];
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
calcWave();
|
||||
renderWave();
|
||||
}
|
||||
|
||||
void calcWave() {
|
||||
// Increment theta (try different values for 'angular velocity' here
|
||||
theta += 0.02;
|
||||
|
||||
// Set all height values to zero
|
||||
for (int i = 0; i < yvalues.length; i++) {
|
||||
yvalues[i] = 0;
|
||||
}
|
||||
|
||||
// Accumulate wave height values
|
||||
for (int j = 0; j < maxwaves; j++) {
|
||||
float x = theta;
|
||||
for (int i = 0; i < yvalues.length; i++) {
|
||||
// Every other wave is cosine instead of sine
|
||||
if (j % 2 == 0) yvalues[i] += sin(x)*amplitude[j];
|
||||
else yvalues[i] += cos(x)*amplitude[j];
|
||||
x+=dx[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void renderWave() {
|
||||
// A simple way to draw the wave with an ellipse at each location
|
||||
noStroke();
|
||||
fill(255,50);
|
||||
ellipseMode(CENTER);
|
||||
for (int x = 0; x < yvalues.length; x++) {
|
||||
ellipse(x*xspacing,width/2+yvalues[x],16,16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class AdditiveWave extends PApplet {
|
||||
|
||||
/**
|
||||
* Additive Wave
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Create a more complex wave by adding two waves together.
|
||||
*/
|
||||
|
||||
int xspacing = 8; // How far apart should each horizontal location be spaced
|
||||
int w; // Width of entire wave
|
||||
int maxwaves = 4; // total # of waves to add together
|
||||
|
||||
float theta = 0.0f;
|
||||
float[] amplitude = new float[maxwaves]; // Height of wave
|
||||
float[] dx = new float[maxwaves]; // Value for incrementing X, to be calculated as a function of period and xspacing
|
||||
float[] yvalues; // Using an array to store height values for the wave (not entirely necessary)
|
||||
|
||||
public void setup() {
|
||||
size(200, 200);
|
||||
frameRate(30);
|
||||
colorMode(RGB, 255, 255, 255, 100);
|
||||
smooth();
|
||||
w = width + 16;
|
||||
|
||||
for (int i = 0; i < maxwaves; i++) {
|
||||
amplitude[i] = random(10,30);
|
||||
float period = random(100,300); // How many pixels before the wave repeats
|
||||
dx[i] = (TWO_PI / period) * xspacing;
|
||||
}
|
||||
|
||||
yvalues = new float[w/xspacing];
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(0);
|
||||
calcWave();
|
||||
renderWave();
|
||||
}
|
||||
|
||||
public void calcWave() {
|
||||
// Increment theta (try different values for 'angular velocity' here
|
||||
theta += 0.02f;
|
||||
|
||||
// Set all height values to zero
|
||||
for (int i = 0; i < yvalues.length; i++) {
|
||||
yvalues[i] = 0;
|
||||
}
|
||||
|
||||
// Accumulate wave height values
|
||||
for (int j = 0; j < maxwaves; j++) {
|
||||
float x = theta;
|
||||
for (int i = 0; i < yvalues.length; i++) {
|
||||
// Every other wave is cosine instead of sine
|
||||
if (j % 2 == 0) yvalues[i] += sin(x)*amplitude[j];
|
||||
else yvalues[i] += cos(x)*amplitude[j];
|
||||
x+=dx[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void renderWave() {
|
||||
// A simple way to draw the wave with an ellipse at each location
|
||||
noStroke();
|
||||
fill(255,50);
|
||||
ellipseMode(CENTER);
|
||||
for (int x = 0; x < yvalues.length; x++) {
|
||||
ellipse(x*xspacing,width/2+yvalues[x],16,16);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "AdditiveWave" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Additive Wave
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Create a more complex wave by adding two waves together.
|
||||
*/
|
||||
|
||||
int xspacing = 8; // How far apart should each horizontal location be spaced
|
||||
int w; // Width of entire wave
|
||||
int maxwaves = 4; // total # of waves to add together
|
||||
|
||||
float theta = 0.0;
|
||||
float[] amplitude = new float[maxwaves]; // Height of wave
|
||||
float[] dx = new float[maxwaves]; // Value for incrementing X, to be calculated as a function of period and xspacing
|
||||
float[] yvalues; // Using an array to store height values for the wave (not entirely necessary)
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
frameRate(30);
|
||||
colorMode(RGB, 255, 255, 255, 100);
|
||||
smooth();
|
||||
w = width + 16;
|
||||
|
||||
for (int i = 0; i < maxwaves; i++) {
|
||||
amplitude[i] = random(10,30);
|
||||
float period = random(100,300); // How many pixels before the wave repeats
|
||||
dx[i] = (TWO_PI / period) * xspacing;
|
||||
}
|
||||
|
||||
yvalues = new float[w/xspacing];
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
calcWave();
|
||||
renderWave();
|
||||
}
|
||||
|
||||
void calcWave() {
|
||||
// Increment theta (try different values for 'angular velocity' here
|
||||
theta += 0.02;
|
||||
|
||||
// Set all height values to zero
|
||||
for (int i = 0; i < yvalues.length; i++) {
|
||||
yvalues[i] = 0;
|
||||
}
|
||||
|
||||
// Accumulate wave height values
|
||||
for (int j = 0; j < maxwaves; j++) {
|
||||
float x = theta;
|
||||
for (int i = 0; i < yvalues.length; i++) {
|
||||
// Every other wave is cosine instead of sine
|
||||
if (j % 2 == 0) yvalues[i] += sin(x)*amplitude[j];
|
||||
else yvalues[i] += cos(x)*amplitude[j];
|
||||
x+=dx[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void renderWave() {
|
||||
// A simple way to draw the wave with an ellipse at each location
|
||||
noStroke();
|
||||
fill(255,50);
|
||||
ellipseMode(CENTER);
|
||||
for (int x = 0; x < yvalues.length; x++) {
|
||||
ellipse(x*xspacing,width/2+yvalues[x],16,16);
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Arctangent.
|
||||
*
|
||||
* Move the mouse to change the direction of the eyes.
|
||||
* The atan2() function computes the angle from each eye
|
||||
* to the cursor.
|
||||
*/
|
||||
|
||||
Eye e1, e2, e3, e4, e5;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
smooth();
|
||||
noStroke();
|
||||
e1 = new Eye( 50, 16, 80);
|
||||
e2 = new Eye( 64, 85, 40);
|
||||
e3 = new Eye( 90, 200, 120);
|
||||
e4 = new Eye(150, 44, 40);
|
||||
e5 = new Eye(175, 120, 80);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(102);
|
||||
|
||||
e1.update(mouseX, mouseY);
|
||||
e2.update(mouseX, mouseY);
|
||||
e3.update(mouseX, mouseY);
|
||||
e4.update(mouseX, mouseY);
|
||||
e5.update(mouseX, mouseY);
|
||||
|
||||
e1.display();
|
||||
e2.display();
|
||||
e3.display();
|
||||
e4.display();
|
||||
e5.display();
|
||||
}
|
||||
|
||||
class Eye
|
||||
{
|
||||
int ex, ey;
|
||||
int size;
|
||||
float angle = 0.0;
|
||||
|
||||
Eye(int x, int y, int s) {
|
||||
ex = x;
|
||||
ey = y;
|
||||
size = s;
|
||||
}
|
||||
|
||||
void update(int mx, int my) {
|
||||
angle = atan2(my-ey, mx-ex);
|
||||
}
|
||||
|
||||
void display() {
|
||||
pushMatrix();
|
||||
translate(ex, ey);
|
||||
fill(255);
|
||||
ellipse(0, 0, size, size);
|
||||
rotate(angle);
|
||||
fill(153);
|
||||
ellipse(size/4, 0, size/2, size/2);
|
||||
popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Arctangent extends PApplet {
|
||||
|
||||
/**
|
||||
* Arctangent.
|
||||
*
|
||||
* Move the mouse to change the direction of the eyes.
|
||||
* The atan2() function computes the angle from each eye
|
||||
* to the cursor.
|
||||
*/
|
||||
|
||||
Eye e1, e2, e3, e4, e5;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
smooth();
|
||||
noStroke();
|
||||
e1 = new Eye( 50, 16, 80);
|
||||
e2 = new Eye( 64, 85, 40);
|
||||
e3 = new Eye( 90, 200, 120);
|
||||
e4 = new Eye(150, 44, 40);
|
||||
e5 = new Eye(175, 120, 80);
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
background(102);
|
||||
|
||||
e1.update(mouseX, mouseY);
|
||||
e2.update(mouseX, mouseY);
|
||||
e3.update(mouseX, mouseY);
|
||||
e4.update(mouseX, mouseY);
|
||||
e5.update(mouseX, mouseY);
|
||||
|
||||
e1.display();
|
||||
e2.display();
|
||||
e3.display();
|
||||
e4.display();
|
||||
e5.display();
|
||||
}
|
||||
|
||||
class Eye
|
||||
{
|
||||
int ex, ey;
|
||||
int size;
|
||||
float angle = 0.0f;
|
||||
|
||||
Eye(int x, int y, int s) {
|
||||
ex = x;
|
||||
ey = y;
|
||||
size = s;
|
||||
}
|
||||
|
||||
public void update(int mx, int my) {
|
||||
angle = atan2(my-ey, mx-ex);
|
||||
}
|
||||
|
||||
public void display() {
|
||||
pushMatrix();
|
||||
translate(ex, ey);
|
||||
fill(255);
|
||||
ellipse(0, 0, size, size);
|
||||
rotate(angle);
|
||||
fill(153);
|
||||
ellipse(size/4, 0, size/2, size/2);
|
||||
popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Arctangent" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Arctangent.
|
||||
*
|
||||
* Move the mouse to change the direction of the eyes.
|
||||
* The atan2() function computes the angle from each eye
|
||||
* to the cursor.
|
||||
*/
|
||||
|
||||
Eye e1, e2, e3, e4, e5;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
smooth();
|
||||
noStroke();
|
||||
e1 = new Eye( 50, 16, 80);
|
||||
e2 = new Eye( 64, 85, 40);
|
||||
e3 = new Eye( 90, 200, 120);
|
||||
e4 = new Eye(150, 44, 40);
|
||||
e5 = new Eye(175, 120, 80);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(102);
|
||||
|
||||
e1.update(mouseX, mouseY);
|
||||
e2.update(mouseX, mouseY);
|
||||
e3.update(mouseX, mouseY);
|
||||
e4.update(mouseX, mouseY);
|
||||
e5.update(mouseX, mouseY);
|
||||
|
||||
e1.display();
|
||||
e2.display();
|
||||
e3.display();
|
||||
e4.display();
|
||||
e5.display();
|
||||
}
|
||||
|
||||
class Eye
|
||||
{
|
||||
int ex, ey;
|
||||
int size;
|
||||
float angle = 0.0;
|
||||
|
||||
Eye(int x, int y, int s) {
|
||||
ex = x;
|
||||
ey = y;
|
||||
size = s;
|
||||
}
|
||||
|
||||
void update(int mx, int my) {
|
||||
angle = atan2(my-ey, mx-ex);
|
||||
}
|
||||
|
||||
void display() {
|
||||
pushMatrix();
|
||||
translate(ex, ey);
|
||||
fill(255);
|
||||
ellipse(0, 0, size, size);
|
||||
rotate(angle);
|
||||
fill(153);
|
||||
ellipse(size/4, 0, size/2, size/2);
|
||||
popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Distance 1D.
|
||||
*
|
||||
* Move the mouse left and right to control the
|
||||
* speed and direction of the moving shapes.
|
||||
*/
|
||||
|
||||
int thin = 8;
|
||||
int thick = 36;
|
||||
float xpos1 = 134.0;
|
||||
float xpos2 = 44.0;
|
||||
float xpos3 = 58.0;
|
||||
float xpos4 = 120.0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
frameRate(60);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(0);
|
||||
|
||||
float mx = mouseX * 0.4 - width/5.0;
|
||||
|
||||
fill(102);
|
||||
rect(xpos2, 0, thick, height/2);
|
||||
fill(204);
|
||||
rect(xpos1, 0, thin, height/2);
|
||||
fill(102);
|
||||
rect(xpos4, height/2, thick, height/2);
|
||||
fill(204);
|
||||
rect(xpos3, height/2, thin, height/2);
|
||||
|
||||
xpos1 += mx/16;
|
||||
xpos2 += mx/64;
|
||||
xpos3 -= mx/16;
|
||||
xpos4 -= mx/64;
|
||||
|
||||
if(xpos1 < -thin) { xpos1 = width; }
|
||||
if(xpos1 > width) { xpos1 = -thin; }
|
||||
if(xpos2 < -thick) { xpos2 = width; }
|
||||
if(xpos2 > width) { xpos2 = -thick; }
|
||||
if(xpos3 < -thin) { xpos3 = width; }
|
||||
if(xpos3 > width) { xpos3 = -thin; }
|
||||
if(xpos4 < -thick) { xpos4 = width; }
|
||||
if(xpos4 > width) { xpos4 = -thick; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Distance1D extends PApplet {
|
||||
|
||||
/**
|
||||
* Distance 1D.
|
||||
*
|
||||
* Move the mouse left and right to control the
|
||||
* speed and direction of the moving shapes.
|
||||
*/
|
||||
|
||||
int thin = 8;
|
||||
int thick = 36;
|
||||
float xpos1 = 134.0f;
|
||||
float xpos2 = 44.0f;
|
||||
float xpos3 = 58.0f;
|
||||
float xpos4 = 120.0f;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
frameRate(60);
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
background(0);
|
||||
|
||||
float mx = mouseX * 0.4f - width/5.0f;
|
||||
|
||||
fill(102);
|
||||
rect(xpos2, 0, thick, height/2);
|
||||
fill(204);
|
||||
rect(xpos1, 0, thin, height/2);
|
||||
fill(102);
|
||||
rect(xpos4, height/2, thick, height/2);
|
||||
fill(204);
|
||||
rect(xpos3, height/2, thin, height/2);
|
||||
|
||||
xpos1 += mx/16;
|
||||
xpos2 += mx/64;
|
||||
xpos3 -= mx/16;
|
||||
xpos4 -= mx/64;
|
||||
|
||||
if(xpos1 < -thin) { xpos1 = width; }
|
||||
if(xpos1 > width) { xpos1 = -thin; }
|
||||
if(xpos2 < -thick) { xpos2 = width; }
|
||||
if(xpos2 > width) { xpos2 = -thick; }
|
||||
if(xpos3 < -thin) { xpos3 = width; }
|
||||
if(xpos3 > width) { xpos3 = -thin; }
|
||||
if(xpos4 < -thick) { xpos4 = width; }
|
||||
if(xpos4 > width) { xpos4 = -thick; }
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Distance1D" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Distance 1D.
|
||||
*
|
||||
* Move the mouse left and right to control the
|
||||
* speed and direction of the moving shapes.
|
||||
*/
|
||||
|
||||
int thin = 8;
|
||||
int thick = 36;
|
||||
float xpos1 = 134.0;
|
||||
float xpos2 = 44.0;
|
||||
float xpos3 = 58.0;
|
||||
float xpos4 = 120.0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
frameRate(60);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(0);
|
||||
|
||||
float mx = mouseX * 0.4 - width/5.0;
|
||||
|
||||
fill(102);
|
||||
rect(xpos2, 0, thick, height/2);
|
||||
fill(204);
|
||||
rect(xpos1, 0, thin, height/2);
|
||||
fill(102);
|
||||
rect(xpos4, height/2, thick, height/2);
|
||||
fill(204);
|
||||
rect(xpos3, height/2, thin, height/2);
|
||||
|
||||
xpos1 += mx/16;
|
||||
xpos2 += mx/64;
|
||||
xpos3 -= mx/16;
|
||||
xpos4 -= mx/64;
|
||||
|
||||
if(xpos1 < -thin) { xpos1 = width; }
|
||||
if(xpos1 > width) { xpos1 = -thin; }
|
||||
if(xpos2 < -thick) { xpos2 = width; }
|
||||
if(xpos2 > width) { xpos2 = -thick; }
|
||||
if(xpos3 < -thin) { xpos3 = width; }
|
||||
if(xpos3 > width) { xpos3 = -thin; }
|
||||
if(xpos4 < -thick) { xpos4 = width; }
|
||||
if(xpos4 > width) { xpos4 = -thick; }
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Distance 2D.
|
||||
*
|
||||
* Move the mouse across the image to obscure and reveal the matrix.
|
||||
* Measures the distance from the mouse to each square and sets the
|
||||
* size proportionally.
|
||||
*/
|
||||
|
||||
float max_distance;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
noStroke();
|
||||
max_distance = dist(0, 0, width, height);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(51);
|
||||
|
||||
for(int i = 0; i <= width; i += 20) {
|
||||
for(int j = 0; j <= height; j += 20) {
|
||||
float size = dist(mouseX, mouseY, i, j);
|
||||
size = size/max_distance * 66;
|
||||
ellipse(i, j, size, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Distance2D extends PApplet {
|
||||
|
||||
/**
|
||||
* Distance 2D.
|
||||
*
|
||||
* Move the mouse across the image to obscure and reveal the matrix.
|
||||
* Measures the distance from the mouse to each square and sets the
|
||||
* size proportionally.
|
||||
*/
|
||||
|
||||
float max_distance;
|
||||
|
||||
public void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
noStroke();
|
||||
max_distance = dist(0, 0, width, height);
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
background(51);
|
||||
|
||||
for(int i = 0; i <= width; i += 20) {
|
||||
for(int j = 0; j <= height; j += 20) {
|
||||
float size = dist(mouseX, mouseY, i, j);
|
||||
size = size/max_distance * 66;
|
||||
ellipse(i, j, size, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Distance2D" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Distance 2D.
|
||||
*
|
||||
* Move the mouse across the image to obscure and reveal the matrix.
|
||||
* Measures the distance from the mouse to each square and sets the
|
||||
* size proportionally.
|
||||
*/
|
||||
|
||||
float max_distance;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
noStroke();
|
||||
max_distance = dist(0, 0, width, height);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(51);
|
||||
|
||||
for(int i = 0; i <= width; i += 20) {
|
||||
for(int j = 0; j <= height; j += 20) {
|
||||
float size = dist(mouseX, mouseY, i, j);
|
||||
size = size/max_distance * 66;
|
||||
ellipse(i, j, size, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Double Random
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* Using two random() calls and the point() function
|
||||
* to create an irregular sawtooth line.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
background(0);
|
||||
int totalPts = 300;
|
||||
float steps = totalPts + 1;
|
||||
stroke(255);
|
||||
float rand = 0;
|
||||
|
||||
for (int i = 1; i < steps; i++){
|
||||
point( (width/steps) * i, (height/2) + random(-rand, rand) );
|
||||
rand += random(-5, 5);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class DoubleRandom extends PApplet {
|
||||
public void setup() {/**
|
||||
* Double Random
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* Using 2 random() calls the and point() function
|
||||
* to create an irregular sawtooth line.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
background(0);
|
||||
int totalPts = 300;
|
||||
float steps = totalPts+1;
|
||||
stroke(255);
|
||||
float rand = 0;
|
||||
|
||||
for (int i=1; i< steps; i++){
|
||||
point( (width/steps) * i, (height/2) + random(-rand, rand) );
|
||||
rand += random(-5, 5);
|
||||
}
|
||||
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "DoubleRandom" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Double Random
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* Using 2 random() calls the and point() function
|
||||
* to create an irregular sawtooth line.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
background(0);
|
||||
int totalPts = 300;
|
||||
float steps = totalPts+1;
|
||||
stroke(255);
|
||||
float rand = 0;
|
||||
|
||||
for (int i=1; i< steps; i++){
|
||||
point( (width/steps) * i, (height/2) + random(-rand, rand) );
|
||||
rand += random(-5, 5);
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Graphing 2D Equations
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Graphics the following equation:
|
||||
* sin(n*cos(r) + 5*theta)
|
||||
* where n is a function of horizontal mouse location.
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
loadPixels();
|
||||
float n = (mouseX * 10.0) / width;
|
||||
float w = 16.0; // 2D space width
|
||||
float h = 16.0; // 2D space height
|
||||
float dx = w / width; // Increment x this amount per pixel
|
||||
float dy = h / height; // Increment y this amount per pixel
|
||||
float x = -w/2; // Start x at -1 * width / 2
|
||||
for (int i = 0; i < width; i++) {
|
||||
float y = -h/2; // Start y at -1 * height / 2
|
||||
for (int j = 0; j < height; j++) {
|
||||
float r = sqrt((x*x) + (y*y)); // Convert cartesian to polar
|
||||
float theta = atan2(y,x); // Convert cartesian to polar
|
||||
// Compute 2D polar coordinate function
|
||||
float val = sin(n*cos(r) + 5 * theta); // Results in a value between -1 and 1
|
||||
//float val = cos(r); // Another simple function
|
||||
//float val = sin(theta); // Another simple function
|
||||
// Map resulting vale to grayscale value
|
||||
pixels[i+j*width] = color((val + 1.0) * 255.0/2.0); // Scale to between 0 and 255
|
||||
y += dy; // Increment y
|
||||
}
|
||||
x += dx; // Increment x
|
||||
}
|
||||
updatePixels();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Graphing2DEquation extends PApplet {
|
||||
|
||||
/**
|
||||
* Graphing 2D Equations
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Graphics the following equation:
|
||||
* sin(n*cos(r) + 5*theta)
|
||||
* where n is a function of horizontal mouse location.
|
||||
*/
|
||||
|
||||
public void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
loadPixels();
|
||||
float n = (mouseX * 10.0f) / width;
|
||||
float w = 16.0f; // 2D space width
|
||||
float h = 16.0f; // 2D space height
|
||||
float dx = w / width; // Increment x this amount per pixel
|
||||
float dy = h / height; // Increment y this amount per pixel
|
||||
float x = -w/2; // Start x at -1 * width / 2
|
||||
for (int i = 0; i < width; i++) {
|
||||
float y = -h/2; // Start y at -1 * height / 2
|
||||
for (int j = 0; j < height; j++) {
|
||||
float r = sqrt((x*x) + (y*y)); // Convert cartesian to polar
|
||||
float theta = atan2(y,x); // Convert cartesian to polar
|
||||
// Compute 2D polar coordinate function
|
||||
float val = sin(n*cos(r) + 5 * theta); // Results in a value between -1 and 1
|
||||
//float val = cos(r); // Another simple function
|
||||
//float val = sin(theta); // Another simple function
|
||||
// Map resulting vale to grayscale value
|
||||
pixels[i+j*width] = color((val + 1.0f) * 255.0f/2.0f); // Scale to between 0 and 255
|
||||
y += dy; // Increment y
|
||||
}
|
||||
x += dx; // Increment x
|
||||
}
|
||||
updatePixels();
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Graphing2DEquation" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Graphing 2D Equations
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Graphics the following equation:
|
||||
* sin(n*cos(r) + 5*theta)
|
||||
* where n is a function of horizontal mouse location.
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
loadPixels();
|
||||
float n = (mouseX * 10.0) / width;
|
||||
float w = 16.0; // 2D space width
|
||||
float h = 16.0; // 2D space height
|
||||
float dx = w / width; // Increment x this amount per pixel
|
||||
float dy = h / height; // Increment y this amount per pixel
|
||||
float x = -w/2; // Start x at -1 * width / 2
|
||||
for (int i = 0; i < width; i++) {
|
||||
float y = -h/2; // Start y at -1 * height / 2
|
||||
for (int j = 0; j < height; j++) {
|
||||
float r = sqrt((x*x) + (y*y)); // Convert cartesian to polar
|
||||
float theta = atan2(y,x); // Convert cartesian to polar
|
||||
// Compute 2D polar coordinate function
|
||||
float val = sin(n*cos(r) + 5 * theta); // Results in a value between -1 and 1
|
||||
//float val = cos(r); // Another simple function
|
||||
//float val = sin(theta); // Another simple function
|
||||
// Map resulting vale to grayscale value
|
||||
pixels[i+j*width] = color((val + 1.0) * 255.0/2.0); // Scale to between 0 and 255
|
||||
y += dy; // Increment y
|
||||
}
|
||||
x += dx; // Increment x
|
||||
}
|
||||
updatePixels();
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Increment Decrement.
|
||||
*
|
||||
* Writing "a++" is equivalent to "a = a + 1".
|
||||
* Writing "a--" is equivalent to "a = a - 1".
|
||||
*/
|
||||
|
||||
int a;
|
||||
int b;
|
||||
boolean direction;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
colorMode(RGB, width);
|
||||
a = 0;
|
||||
b = width;
|
||||
direction = true;
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
a++;
|
||||
if(a > width) {
|
||||
a = 0;
|
||||
direction = !direction;
|
||||
}
|
||||
if(direction == true){
|
||||
stroke(a);
|
||||
} else {
|
||||
stroke(width-a);
|
||||
}
|
||||
line(a, 0, a, height/2);
|
||||
|
||||
b--;
|
||||
if(b < 0) {
|
||||
b = width;
|
||||
}
|
||||
if(direction == true) {
|
||||
stroke(width-b);
|
||||
} else {
|
||||
stroke(b);
|
||||
}
|
||||
line(b, height/2+1, b, height);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class IncrementDecrement extends PApplet {
|
||||
|
||||
/**
|
||||
* Increment Decrement.
|
||||
*
|
||||
* Writing "a++" is equivalent to "a = a + 1".
|
||||
* Writing "a--" is equivalent to "a = a - 1".
|
||||
*/
|
||||
|
||||
int a;
|
||||
int b;
|
||||
boolean direction;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
colorMode(RGB, width);
|
||||
a = 0;
|
||||
b = width;
|
||||
direction = true;
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
a++;
|
||||
if(a > width) {
|
||||
a = 0;
|
||||
direction = !direction;
|
||||
}
|
||||
if(direction == true){
|
||||
stroke(a);
|
||||
} else {
|
||||
stroke(width-a);
|
||||
}
|
||||
line(a, 0, a, height/2);
|
||||
|
||||
b--;
|
||||
if(b < 0) {
|
||||
b = width;
|
||||
}
|
||||
if(direction == true) {
|
||||
stroke(width-b);
|
||||
} else {
|
||||
stroke(b);
|
||||
}
|
||||
line(b, height/2+1, b, height);
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "IncrementDecrement" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Increment Decrement.
|
||||
*
|
||||
* Writing "a++" is equivalent to "a = a + 1".
|
||||
* Writing "a--" is equivalent to "a = a - 1".
|
||||
*/
|
||||
|
||||
int a;
|
||||
int b;
|
||||
boolean direction;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
colorMode(RGB, width);
|
||||
a = 0;
|
||||
b = width;
|
||||
direction = true;
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
a++;
|
||||
if(a > width) {
|
||||
a = 0;
|
||||
direction = !direction;
|
||||
}
|
||||
if(direction == true){
|
||||
stroke(a);
|
||||
} else {
|
||||
stroke(width-a);
|
||||
}
|
||||
line(a, 0, a, height/2);
|
||||
|
||||
b--;
|
||||
if(b < 0) {
|
||||
b = width;
|
||||
}
|
||||
if(direction == true) {
|
||||
stroke(width-b);
|
||||
} else {
|
||||
stroke(b);
|
||||
}
|
||||
line(b, height/2+1, b, height);
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Modulo.
|
||||
*
|
||||
* The modulo operator (%) returns the remainder of a number
|
||||
* divided by another. As in this example, it is often used
|
||||
* to keep numerical values within a set range.
|
||||
*/
|
||||
|
||||
int num = 20;
|
||||
float c;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200,200);
|
||||
fill(255);
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(0);
|
||||
c+=0.1;
|
||||
for(int i=1; i<height/num; i++) {
|
||||
float x = (c%i)*i*i;
|
||||
stroke(102);
|
||||
line(0, i*num, x, i*num);
|
||||
noStroke();
|
||||
rect(x, i*num-num/2, 8, num);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Modulo extends PApplet {
|
||||
|
||||
/**
|
||||
* Modulo.
|
||||
*
|
||||
* The modulo operator (%) returns the remainder of a number
|
||||
* divided by another. As in this example, it is often used
|
||||
* to keep numerical values within a set range.
|
||||
*/
|
||||
|
||||
int num = 20;
|
||||
float c;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200,200);
|
||||
fill(255);
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
background(0);
|
||||
c+=0.1f;
|
||||
for(int i=1; i<height/num; i++) {
|
||||
float x = (c%i)*i*i;
|
||||
stroke(102);
|
||||
line(0, i*num, x, i*num);
|
||||
noStroke();
|
||||
rect(x, i*num-num/2, 8, num);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Modulo" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Modulo.
|
||||
*
|
||||
* The modulo operator (%) returns the remainder of a number
|
||||
* divided by another. As in this example, it is often used
|
||||
* to keep numerical values within a set range.
|
||||
*/
|
||||
|
||||
int num = 20;
|
||||
float c;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200,200);
|
||||
fill(255);
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(0);
|
||||
c+=0.1;
|
||||
for(int i=1; i<height/num; i++) {
|
||||
float x = (c%i)*i*i;
|
||||
stroke(102);
|
||||
line(0, i*num, x, i*num);
|
||||
noStroke();
|
||||
rect(x, i*num-num/2, 8, num);
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Noise1D.
|
||||
*
|
||||
* Using 1D Perlin Noise to assign location.
|
||||
*/
|
||||
|
||||
float xoff = 0.0;
|
||||
float xincrement = 0.01;
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
background(0);
|
||||
frameRate(30);
|
||||
smooth();
|
||||
noStroke();
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
// Create an alpha blended background
|
||||
fill(0, 10);
|
||||
rect(0,0,width,height);
|
||||
|
||||
//float n = random(0,width); // Try this line instead of noise
|
||||
|
||||
// Get a noise value based on xoff and scale it according to the window's width
|
||||
float n = noise(xoff)*width;
|
||||
|
||||
// With each cycle, increment xoff
|
||||
xoff += xincrement;
|
||||
|
||||
// Draw the ellipse at the value produced by perlin noise
|
||||
fill(200);
|
||||
ellipse(n,height/2,16,16);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Noise1D extends PApplet {
|
||||
|
||||
/**
|
||||
* Noise1D.
|
||||
*
|
||||
* Using 1D Perlin Noise to assign location.
|
||||
*/
|
||||
|
||||
float xoff = 0.0f;
|
||||
float xincrement = 0.01f;
|
||||
|
||||
public void setup() {
|
||||
size(200,200);
|
||||
background(0);
|
||||
frameRate(30);
|
||||
smooth();
|
||||
noStroke();
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
// Create an alpha blended background
|
||||
fill(0, 10);
|
||||
rect(0,0,width,height);
|
||||
|
||||
//float n = random(0,width); // Try this line instead of noise
|
||||
|
||||
// Get a noise value based on xoff and scale it according to the window's width
|
||||
float n = noise(xoff)*width;
|
||||
|
||||
// With each cycle, increment xoff
|
||||
xoff += xincrement;
|
||||
|
||||
// Draw the ellipse at the value produced by perlin noise
|
||||
fill(200);
|
||||
ellipse(n,height/2,16,16);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Noise1D" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Noise1D.
|
||||
*
|
||||
* Using 1D Perlin Noise to assign location.
|
||||
*/
|
||||
|
||||
float xoff = 0.0;
|
||||
float xincrement = 0.01;
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
background(0);
|
||||
frameRate(30);
|
||||
smooth();
|
||||
noStroke();
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
// Create an alpha blended background
|
||||
fill(0, 10);
|
||||
rect(0,0,width,height);
|
||||
|
||||
//float n = random(0,width); // Try this line instead of noise
|
||||
|
||||
// Get a noise value based on xoff and scale it according to the window's width
|
||||
float n = noise(xoff)*width;
|
||||
|
||||
// With each cycle, increment xoff
|
||||
xoff += xincrement;
|
||||
|
||||
// Draw the ellipse at the value produced by perlin noise
|
||||
fill(200);
|
||||
ellipse(n,height/2,16,16);
|
||||
}
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Noise2D
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Using 2D noise to create simple texture.
|
||||
*/
|
||||
|
||||
float increment = 0.02;
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
|
||||
// Optional: adjust noise detail here
|
||||
// noiseDetail(8,0.65f);
|
||||
|
||||
loadPixels();
|
||||
|
||||
float xoff = 0.0; // Start xoff at 0
|
||||
|
||||
// For every x,y coordinate in a 2D space, calculate a noise value and produce a brightness value
|
||||
for (int x = 0; x < width; x++) {
|
||||
xoff += increment; // Increment xoff
|
||||
float yoff = 0.0; // For every xoff, start yoff at 0
|
||||
for (int y = 0; y < height; y++) {
|
||||
yoff += increment; // Increment yoff
|
||||
|
||||
// Calculate noise and scale by 255
|
||||
float bright = noise(xoff,yoff)*255;
|
||||
|
||||
// Try using this line instead
|
||||
//float bright = random(0,255);
|
||||
|
||||
// Set each pixel onscreen to a grayscale value
|
||||
pixels[x+y*width] = color(bright);
|
||||
}
|
||||
}
|
||||
|
||||
updatePixels();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Noise2D extends PApplet {
|
||||
|
||||
/**
|
||||
* Noise2D
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Using 2D noise to create simple texture.
|
||||
*/
|
||||
|
||||
float increment = 0.02f;
|
||||
|
||||
public void setup() {
|
||||
size(200,200);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(0);
|
||||
|
||||
// Optional: adjust noise detail here
|
||||
// noiseDetail(8,0.65f);
|
||||
|
||||
loadPixels();
|
||||
|
||||
float xoff = 0.0f; // Start xoff at 0
|
||||
|
||||
// For every x,y coordinate in a 2D space, calculate a noise value and produce a brightness value
|
||||
for (int x = 0; x < width; x++) {
|
||||
xoff += increment; // Increment xoff
|
||||
float yoff = 0.0f; // For every xoff, start yoff at 0
|
||||
for (int y = 0; y < height; y++) {
|
||||
yoff += increment; // Increment yoff
|
||||
|
||||
// Calculate noise and scale by 255
|
||||
float bright = noise(xoff,yoff)*255;
|
||||
|
||||
// Try using this line instead
|
||||
//float bright = random(0,255);
|
||||
|
||||
// Set each pixel onscreen to a grayscale value
|
||||
pixels[x+y*width] = color(bright);
|
||||
}
|
||||
}
|
||||
|
||||
updatePixels();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Noise2D" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Noise2D
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Using 2D noise to create simple texture.
|
||||
*/
|
||||
|
||||
float increment = 0.02;
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
|
||||
// Optional: adjust noise detail here
|
||||
// noiseDetail(8,0.65f);
|
||||
|
||||
loadPixels();
|
||||
|
||||
float xoff = 0.0; // Start xoff at 0
|
||||
|
||||
// For every x,y coordinate in a 2D space, calculate a noise value and produce a brightness value
|
||||
for (int x = 0; x < width; x++) {
|
||||
xoff += increment; // Increment xoff
|
||||
float yoff = 0.0; // For every xoff, start yoff at 0
|
||||
for (int y = 0; y < height; y++) {
|
||||
yoff += increment; // Increment yoff
|
||||
|
||||
// Calculate noise and scale by 255
|
||||
float bright = noise(xoff,yoff)*255;
|
||||
|
||||
// Try using this line instead
|
||||
//float bright = random(0,255);
|
||||
|
||||
// Set each pixel onscreen to a grayscale value
|
||||
pixels[x+y*width] = color(bright);
|
||||
}
|
||||
}
|
||||
|
||||
updatePixels();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Noise3D.
|
||||
*
|
||||
* Using 3D noise to create simple animated texture.
|
||||
* Here, the third dimension ('z') is treated as time.
|
||||
*/
|
||||
|
||||
float increment = 0.01;
|
||||
// The noise function's 3rd argument, a global variable that increments once per cycle
|
||||
float zoff = 0.0;
|
||||
// We will increment zoff differently than xoff and yoff
|
||||
float zincrement = 0.02;
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
|
||||
// Optional: adjust noise detail here
|
||||
// noiseDetail(8,0.65f);
|
||||
|
||||
loadPixels();
|
||||
|
||||
float xoff = 0.0; // Start xoff at 0
|
||||
|
||||
// For every x,y coordinate in a 2D space, calculate a noise value and produce a brightness value
|
||||
for (int x = 0; x < width; x++) {
|
||||
xoff += increment; // Increment xoff
|
||||
float yoff = 0.0; // For every xoff, start yoff at 0
|
||||
for (int y = 0; y < height; y++) {
|
||||
yoff += increment; // Increment yoff
|
||||
|
||||
// Calculate noise and scale by 255
|
||||
float bright = noise(xoff,yoff,zoff)*255;
|
||||
|
||||
// Try using this line instead
|
||||
//float bright = random(0,255);
|
||||
|
||||
// Set each pixel onscreen to a grayscale value
|
||||
pixels[x+y*width] = color(bright,bright,bright);
|
||||
}
|
||||
}
|
||||
updatePixels();
|
||||
|
||||
zoff += zincrement; // Increment zoff
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Noise3D extends PApplet {
|
||||
|
||||
/**
|
||||
* Noise3D.
|
||||
*
|
||||
* Using 3D noise to create simple animated texture.
|
||||
* Here, the third dimension ('z') is treated as time.
|
||||
*/
|
||||
|
||||
float increment = 0.01f;
|
||||
// The noise function's 3rd argument, a global variable that increments once per cycle
|
||||
float zoff = 0.0f;
|
||||
// We will increment zoff differently than xoff and yoff
|
||||
float zincrement = 0.02f;
|
||||
|
||||
public void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(0);
|
||||
|
||||
// Optional: adjust noise detail here
|
||||
// noiseDetail(8,0.65f);
|
||||
|
||||
loadPixels();
|
||||
|
||||
float xoff = 0.0f; // Start xoff at 0
|
||||
|
||||
// For every x,y coordinate in a 2D space, calculate a noise value and produce a brightness value
|
||||
for (int x = 0; x < width; x++) {
|
||||
xoff += increment; // Increment xoff
|
||||
float yoff = 0.0f; // For every xoff, start yoff at 0
|
||||
for (int y = 0; y < height; y++) {
|
||||
yoff += increment; // Increment yoff
|
||||
|
||||
// Calculate noise and scale by 255
|
||||
float bright = noise(xoff,yoff,zoff)*255;
|
||||
|
||||
// Try using this line instead
|
||||
//float bright = random(0,255);
|
||||
|
||||
// Set each pixel onscreen to a grayscale value
|
||||
pixels[x+y*width] = color(bright,bright,bright);
|
||||
}
|
||||
}
|
||||
updatePixels();
|
||||
|
||||
zoff += zincrement; // Increment zoff
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Noise3D" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Noise3D.
|
||||
*
|
||||
* Using 3D noise to create simple animated texture.
|
||||
* Here, the third dimension ('z') is treated as time.
|
||||
*/
|
||||
|
||||
float increment = 0.01;
|
||||
// The noise function's 3rd argument, a global variable that increments once per cycle
|
||||
float zoff = 0.0;
|
||||
// We will increment zoff differently than xoff and yoff
|
||||
float zincrement = 0.02;
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
|
||||
// Optional: adjust noise detail here
|
||||
// noiseDetail(8,0.65f);
|
||||
|
||||
loadPixels();
|
||||
|
||||
float xoff = 0.0; // Start xoff at 0
|
||||
|
||||
// For every x,y coordinate in a 2D space, calculate a noise value and produce a brightness value
|
||||
for (int x = 0; x < width; x++) {
|
||||
xoff += increment; // Increment xoff
|
||||
float yoff = 0.0; // For every xoff, start yoff at 0
|
||||
for (int y = 0; y < height; y++) {
|
||||
yoff += increment; // Increment yoff
|
||||
|
||||
// Calculate noise and scale by 255
|
||||
float bright = noise(xoff,yoff,zoff)*255;
|
||||
|
||||
// Try using this line instead
|
||||
//float bright = random(0,255);
|
||||
|
||||
// Set each pixel onscreen to a grayscale value
|
||||
pixels[x+y*width] = color(bright,bright,bright);
|
||||
}
|
||||
}
|
||||
updatePixels();
|
||||
|
||||
zoff += zincrement; // Increment zoff
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Noise Wave
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Using Perlin Noise to generate a wave-like pattern.
|
||||
*/
|
||||
|
||||
int xspacing = 8; // How far apart should each horizontal location be spaced
|
||||
int w; // Width of entire wave
|
||||
|
||||
float yoff = 0.0f; // 2nd dimension of perlin noise
|
||||
float[] yvalues; // Using an array to store height values for the wave (not entirely necessary)
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
colorMode(RGB,255,255,255,100);
|
||||
smooth();
|
||||
w = width+16;
|
||||
yvalues = new float[w/xspacing];
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
calcWave();
|
||||
renderWave();
|
||||
|
||||
}
|
||||
|
||||
void calcWave() {
|
||||
float dx = 0.05f;
|
||||
float dy = 0.01f;
|
||||
float amplitude = 100.0f;
|
||||
|
||||
// Increment y ('time')
|
||||
yoff += dy;
|
||||
|
||||
//float xoff = 0.0; // Option #1
|
||||
float xoff = yoff; // Option #2
|
||||
|
||||
for (int i = 0; i < yvalues.length; i++) {
|
||||
// Using 2D noise function
|
||||
//yvalues[i] = (2*noise(xoff,yoff)-1)*amplitude; // Option #1
|
||||
// Using 1D noise function
|
||||
yvalues[i] = (2*noise(xoff)-1)*amplitude; // Option #2
|
||||
xoff+=dx;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void renderWave() {
|
||||
// A simple way to draw the wave with an ellipse at each location
|
||||
for (int x = 0; x < yvalues.length; x++) {
|
||||
noStroke();
|
||||
fill(255,50);
|
||||
ellipseMode(CENTER);
|
||||
ellipse(x*xspacing,width/2+yvalues[x],16,16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class NoiseWave extends PApplet {
|
||||
|
||||
/**
|
||||
* Noise Wave
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Using Perlin Noise to generate a wave-like pattern.
|
||||
*/
|
||||
|
||||
int xspacing = 8; // How far apart should each horizontal location be spaced
|
||||
int w; // Width of entire wave
|
||||
|
||||
float yoff = 0.0f; // 2nd dimension of perlin noise
|
||||
float[] yvalues; // Using an array to store height values for the wave (not entirely necessary)
|
||||
|
||||
public void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
colorMode(RGB,255,255,255,100);
|
||||
smooth();
|
||||
w = width+16;
|
||||
yvalues = new float[w/xspacing];
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(0);
|
||||
calcWave();
|
||||
renderWave();
|
||||
|
||||
}
|
||||
|
||||
public void calcWave() {
|
||||
float dx = 0.05f;
|
||||
float dy = 0.01f;
|
||||
float amplitude = 100.0f;
|
||||
|
||||
// Increment y ('time')
|
||||
yoff += dy;
|
||||
|
||||
//float xoff = 0.0; // Option #1
|
||||
float xoff = yoff; // Option #2
|
||||
|
||||
for (int i = 0; i < yvalues.length; i++) {
|
||||
// Using 2D noise function
|
||||
//yvalues[i] = (2*noise(xoff,yoff)-1)*amplitude; // Option #1
|
||||
// Using 1D noise function
|
||||
yvalues[i] = (2*noise(xoff)-1)*amplitude; // Option #2
|
||||
xoff+=dx;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void renderWave() {
|
||||
// A simple way to draw the wave with an ellipse at each location
|
||||
for (int x = 0; x < yvalues.length; x++) {
|
||||
noStroke();
|
||||
fill(255,50);
|
||||
ellipseMode(CENTER);
|
||||
ellipse(x*xspacing,width/2+yvalues[x],16,16);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "NoiseWave" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Noise Wave
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Using Perlin Noise to generate a wave-like pattern.
|
||||
*/
|
||||
|
||||
int xspacing = 8; // How far apart should each horizontal location be spaced
|
||||
int w; // Width of entire wave
|
||||
|
||||
float yoff = 0.0f; // 2nd dimension of perlin noise
|
||||
float[] yvalues; // Using an array to store height values for the wave (not entirely necessary)
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
colorMode(RGB,255,255,255,100);
|
||||
smooth();
|
||||
w = width+16;
|
||||
yvalues = new float[w/xspacing];
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
calcWave();
|
||||
renderWave();
|
||||
|
||||
}
|
||||
|
||||
void calcWave() {
|
||||
float dx = 0.05f;
|
||||
float dy = 0.01f;
|
||||
float amplitude = 100.0f;
|
||||
|
||||
// Increment y ('time')
|
||||
yoff += dy;
|
||||
|
||||
//float xoff = 0.0; // Option #1
|
||||
float xoff = yoff; // Option #2
|
||||
|
||||
for (int i = 0; i < yvalues.length; i++) {
|
||||
// Using 2D noise function
|
||||
//yvalues[i] = (2*noise(xoff,yoff)-1)*amplitude; // Option #1
|
||||
// Using 1D noise function
|
||||
yvalues[i] = (2*noise(xoff)-1)*amplitude; // Option #2
|
||||
xoff+=dx;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void renderWave() {
|
||||
// A simple way to draw the wave with an ellipse at each location
|
||||
for (int x = 0; x < yvalues.length; x++) {
|
||||
noStroke();
|
||||
fill(255,50);
|
||||
ellipseMode(CENTER);
|
||||
ellipse(x*xspacing,width/2+yvalues[x],16,16);
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Operator Precedence
|
||||
*
|
||||
* If you don't explicitly state the order in which
|
||||
* an expression is evaluated, they are evaluated based
|
||||
* on the operator precedence. For example, in the statement
|
||||
* "4+2*8", the 2 will first be multiplied by 8 and then the result will
|
||||
* be added to 4. This is because the "*" has a higher precedence
|
||||
* than the "+". To avoid ambiguity in reading the program,
|
||||
* it is recommended that is statement is written as "4+(2*8)".
|
||||
* The order of evaluation can be controlled through placement of
|
||||
* parenthesis in the code. A table of operator precedence follows below.
|
||||
*
|
||||
*/
|
||||
|
||||
// The highest precedence is at the top of the list and
|
||||
// the lowest is at the bottom.
|
||||
// Multiplicative: * / %
|
||||
// Additive: + -
|
||||
// Relational: < > <= >=
|
||||
// Equality: == !=
|
||||
// Logical AND: &&
|
||||
// Logical OR: ||
|
||||
// Assignment: = += -= *= /= %=
|
||||
|
||||
size(200, 200);
|
||||
background(51);
|
||||
noFill();
|
||||
stroke(51);
|
||||
|
||||
stroke(204);
|
||||
for(int i=0; i< width-20; i+= 4) {
|
||||
// The 30 is added to 70 and then evaluated
|
||||
// if it is greater than the current value of "i"
|
||||
// For clarity, write as "if(i > (30 + 70)) {"
|
||||
if(i > 30 + 70) {
|
||||
line(i, 0, i, 50);
|
||||
}
|
||||
}
|
||||
|
||||
stroke(255);
|
||||
// The 2 is multiplied by the 8 and the result is added to the 5
|
||||
// For clarity, write as "rect(5 + (2 * 8), 0, 90, 20);"
|
||||
rect(4 + 2 * 8, 52, 90, 48);
|
||||
rect((4 + 2) * 8, 100, 90, 49);
|
||||
|
||||
stroke(153);
|
||||
for(int i=0; i< width; i+= 2) {
|
||||
// The relational statements are evaluated
|
||||
// first, and then the logical AND statements and
|
||||
// finally the logical OR. For clarity, write as:
|
||||
// "if(((i > 10) && (i < 50)) || ((i > 80) && (i < 160))) {"
|
||||
if(i > 20 && i < 50 || i > 100 && i < width-20) {
|
||||
line(i, 151, i, height-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class OperatorPrecedence extends PApplet {
|
||||
public void setup() {/**
|
||||
* Operator_Precedence
|
||||
*
|
||||
* If you don't explicitly state the order in which
|
||||
* an expression is evaluated, they are evaluated based
|
||||
* on the operator precedence. For example, in the statement
|
||||
* "4+2*8", the 2 will first be multiplied by 8 and then the result will
|
||||
* be added to 4. This is because the "*" has a higher precedence
|
||||
* than the "+". To avoid ambiguity in reading the program,
|
||||
* it is recommended that is statement is written as "4+(2*8)".
|
||||
* The order of evaluation can be controlled through placement of
|
||||
* parenthesis in the code. A table of operator precedence follows below.
|
||||
*
|
||||
*/
|
||||
|
||||
// The highest precedence is at the top of the list and
|
||||
// the lowest is at the bottom.
|
||||
// Multiplicative: * / %
|
||||
// Additive: + -
|
||||
// Relational: < > <= >=
|
||||
// Equality: == !=
|
||||
// Logical AND: &&
|
||||
// Logical OR: ||
|
||||
// Assignment: = += -= *= /= %=
|
||||
|
||||
size(200, 200);
|
||||
background(51);
|
||||
noFill();
|
||||
stroke(51);
|
||||
|
||||
stroke(204);
|
||||
for(int i=0; i< width-20; i+= 4) {
|
||||
// The 30 is added to 70 and then evaluated
|
||||
// if it is greater than the current value of "i"
|
||||
// For clarity, write as "if(i > (30 + 70)) {"
|
||||
if(i > 30 + 70) {
|
||||
line(i, 0, i, 50);
|
||||
}
|
||||
}
|
||||
|
||||
stroke(255);
|
||||
// The 2 is multiplied by the 8 and the result is added to the 5
|
||||
// For clarity, write as "rect(5 + (2 * 8), 0, 90, 20);"
|
||||
rect(4 + 2 * 8, 52, 90, 48);
|
||||
rect((4 + 2) * 8, 100, 90, 49);
|
||||
|
||||
stroke(153);
|
||||
for(int i=0; i< width; i+= 2) {
|
||||
// The relational statements are evaluated
|
||||
// first, and then the logical AND statements and
|
||||
// finally the logical OR. For clarity, write as:
|
||||
// "if(((i > 10) && (i < 50)) || ((i > 80) && (i < 160))) {"
|
||||
if(i > 20 && i < 50 || i > 100 && i < width-20) {
|
||||
line(i, 151, i, height-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "OperatorPrecedence" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Operator_Precedence
|
||||
*
|
||||
* If you don't explicitly state the order in which
|
||||
* an expression is evaluated, they are evaluated based
|
||||
* on the operator precedence. For example, in the statement
|
||||
* "4+2*8", the 2 will first be multiplied by 8 and then the result will
|
||||
* be added to 4. This is because the "*" has a higher precedence
|
||||
* than the "+". To avoid ambiguity in reading the program,
|
||||
* it is recommended that is statement is written as "4+(2*8)".
|
||||
* The order of evaluation can be controlled through placement of
|
||||
* parenthesis in the code. A table of operator precedence follows below.
|
||||
*
|
||||
*/
|
||||
|
||||
// The highest precedence is at the top of the list and
|
||||
// the lowest is at the bottom.
|
||||
// Multiplicative: * / %
|
||||
// Additive: + -
|
||||
// Relational: < > <= >=
|
||||
// Equality: == !=
|
||||
// Logical AND: &&
|
||||
// Logical OR: ||
|
||||
// Assignment: = += -= *= /= %=
|
||||
|
||||
size(200, 200);
|
||||
background(51);
|
||||
noFill();
|
||||
stroke(51);
|
||||
|
||||
stroke(204);
|
||||
for(int i=0; i< width-20; i+= 4) {
|
||||
// The 30 is added to 70 and then evaluated
|
||||
// if it is greater than the current value of "i"
|
||||
// For clarity, write as "if(i > (30 + 70)) {"
|
||||
if(i > 30 + 70) {
|
||||
line(i, 0, i, 50);
|
||||
}
|
||||
}
|
||||
|
||||
stroke(255);
|
||||
// The 2 is multiplied by the 8 and the result is added to the 5
|
||||
// For clarity, write as "rect(5 + (2 * 8), 0, 90, 20);"
|
||||
rect(4 + 2 * 8, 52, 90, 48);
|
||||
rect((4 + 2) * 8, 100, 90, 49);
|
||||
|
||||
stroke(153);
|
||||
for(int i=0; i< width; i+= 2) {
|
||||
// The relational statements are evaluated
|
||||
// first, and then the logical AND statements and
|
||||
// finally the logical OR. For clarity, write as:
|
||||
// "if(((i > 10) && (i < 50)) || ((i > 80) && (i < 160))) {"
|
||||
if(i > 20 && i < 50 || i > 100 && i < width-20) {
|
||||
line(i, 151, i, height-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* PolarToCartesian
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Convert a polar coordinate (r,theta) to cartesian (x,y):
|
||||
* x = r * cos(theta)
|
||||
* y = r * sin(theta)
|
||||
*/
|
||||
|
||||
float r;
|
||||
|
||||
// Angle and angular velocity, accleration
|
||||
float theta;
|
||||
float theta_vel;
|
||||
float theta_acc;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
frameRate(30);
|
||||
smooth();
|
||||
|
||||
// Initialize all values
|
||||
r = 50;
|
||||
theta = 0;
|
||||
theta_vel = 0;
|
||||
theta_acc = 0.0001;
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
// Translate the origin point to the center of the screen
|
||||
translate(width/2, height/2);
|
||||
|
||||
// Convert polar to cartesian
|
||||
float x = r * cos(theta);
|
||||
float y = r * sin(theta);
|
||||
|
||||
// Draw the ellipse at the cartesian coordinate
|
||||
ellipseMode(CENTER);
|
||||
noStroke();
|
||||
fill(200);
|
||||
ellipse(x, y, 16, 16);
|
||||
|
||||
// Apply acceleration and velocity to angle (r remains static in this example)
|
||||
theta_vel += theta_acc;
|
||||
theta += theta_vel;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class PolarToCartesian extends PApplet {
|
||||
|
||||
/**
|
||||
* PolarToCartesian
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Convert a polar coordinate (r,theta) to cartesian (x,y):
|
||||
* x = r * cos(theta)
|
||||
* y = r * sin(theta)
|
||||
*/
|
||||
|
||||
float r;
|
||||
|
||||
// Angle and angular velocity, accleration
|
||||
float theta;
|
||||
float theta_vel;
|
||||
float theta_acc;
|
||||
|
||||
public void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
smooth();
|
||||
|
||||
// Initialize all values
|
||||
r = 50.0f;
|
||||
theta = 0.0f;
|
||||
theta_vel = 0.0f;
|
||||
theta_acc = 0.0001f;
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(0);
|
||||
// Translate the origin point to the center of the screen
|
||||
translate(width/2,height/2);
|
||||
|
||||
// Convert polar to cartesian
|
||||
float x = r * cos(theta);
|
||||
float y = r * sin(theta);
|
||||
|
||||
// Draw the ellipse at the cartesian coordinate
|
||||
ellipseMode(CENTER);
|
||||
noStroke();
|
||||
fill(200);
|
||||
ellipse(x,y,16,16);
|
||||
|
||||
// Apply acceleration and velocity to angle (r remains static in this example)
|
||||
theta_vel += theta_acc;
|
||||
theta += theta_vel;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "PolarToCartesian" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* PolarToCartesian
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Convert a polar coordinate (r,theta) to cartesian (x,y):
|
||||
* x = r * cos(theta)
|
||||
* y = r * sin(theta)
|
||||
*/
|
||||
|
||||
float r;
|
||||
|
||||
// Angle and angular velocity, accleration
|
||||
float theta;
|
||||
float theta_vel;
|
||||
float theta_acc;
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
smooth();
|
||||
|
||||
// Initialize all values
|
||||
r = 50.0f;
|
||||
theta = 0.0f;
|
||||
theta_vel = 0.0f;
|
||||
theta_acc = 0.0001f;
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
// Translate the origin point to the center of the screen
|
||||
translate(width/2,height/2);
|
||||
|
||||
// Convert polar to cartesian
|
||||
float x = r * cos(theta);
|
||||
float y = r * sin(theta);
|
||||
|
||||
// Draw the ellipse at the cartesian coordinate
|
||||
ellipseMode(CENTER);
|
||||
noStroke();
|
||||
fill(200);
|
||||
ellipse(x,y,16,16);
|
||||
|
||||
// Apply acceleration and velocity to angle (r remains static in this example)
|
||||
theta_vel += theta_acc;
|
||||
theta += theta_vel;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Random.
|
||||
*
|
||||
* Random numbers create the basis of this image.
|
||||
* Each time the program is loaded the result is different.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
smooth();
|
||||
background(0);
|
||||
strokeWeight(10);
|
||||
|
||||
for(int i = 0; i < width; i++) {
|
||||
float r = random(255);
|
||||
float x = random(0, width);
|
||||
stroke(r, 100);
|
||||
line(i, 0, x, height);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Random extends PApplet {
|
||||
public void setup() {/**
|
||||
* Random.
|
||||
*
|
||||
* Random numbers create the basis of this image.
|
||||
* Each time the program is loaded the result is different.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
smooth();
|
||||
background(0);
|
||||
strokeWeight(10);
|
||||
|
||||
for(int i = 0; i < width; i++) {
|
||||
float r = random(255);
|
||||
float x = random(0, width);
|
||||
stroke(r, 100);
|
||||
line(i, 0, x, height);
|
||||
}
|
||||
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Random" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Random.
|
||||
*
|
||||
* Random numbers create the basis of this image.
|
||||
* Each time the program is loaded the result is different.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
smooth();
|
||||
background(0);
|
||||
strokeWeight(10);
|
||||
|
||||
for(int i = 0; i < width; i++) {
|
||||
float r = random(255);
|
||||
float x = random(0, width);
|
||||
stroke(r, 100);
|
||||
line(i, 0, x, height);
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Sine.
|
||||
*
|
||||
* Smoothly scaling size with the sin() function.
|
||||
*/
|
||||
|
||||
float spin = 0.0;
|
||||
float diameter = 84.0;
|
||||
float angle;
|
||||
|
||||
float angle_rot;
|
||||
int rad_points = 90;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
smooth();
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(153);
|
||||
|
||||
translate(130, 65);
|
||||
|
||||
fill(255);
|
||||
ellipse(0, 0, 16, 16);
|
||||
|
||||
angle_rot = 0;
|
||||
fill(51);
|
||||
|
||||
for(int i=0; i<5; i++) {
|
||||
pushMatrix();
|
||||
rotate(angle_rot + -45);
|
||||
ellipse(-116, 0, diameter, diameter);
|
||||
popMatrix();
|
||||
angle_rot += PI*2/5;
|
||||
}
|
||||
|
||||
diameter = 34 * sin(angle) + 168;
|
||||
|
||||
angle += 0.02;
|
||||
if (angle > TWO_PI) { angle = 0; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Sine extends PApplet {
|
||||
|
||||
/**
|
||||
* Sine.
|
||||
*
|
||||
* Smoothly scaling size with the sin() function.
|
||||
*/
|
||||
|
||||
float spin = 0.0f;
|
||||
float diameter = 84.0f;
|
||||
float angle;
|
||||
|
||||
float angle_rot;
|
||||
int rad_points = 90;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
smooth();
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
background(153);
|
||||
|
||||
translate(130, 65);
|
||||
|
||||
fill(255);
|
||||
ellipse(0, 0, 16, 16);
|
||||
|
||||
angle_rot = 0;
|
||||
fill(51);
|
||||
|
||||
for(int i=0; i<5; i++) {
|
||||
pushMatrix();
|
||||
rotate(angle_rot + -45);
|
||||
ellipse(-116, 0, diameter, diameter);
|
||||
popMatrix();
|
||||
angle_rot += PI*2/5;
|
||||
}
|
||||
|
||||
diameter = 34 * sin(angle) + 168;
|
||||
|
||||
angle += 0.02f;
|
||||
if (angle > TWO_PI) { angle = 0; }
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Sine" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Sine.
|
||||
*
|
||||
* Smoothly scaling size with the sin() function.
|
||||
*/
|
||||
|
||||
float spin = 0.0;
|
||||
float diameter = 84.0;
|
||||
float angle;
|
||||
|
||||
float angle_rot;
|
||||
int rad_points = 90;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
smooth();
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(153);
|
||||
|
||||
translate(130, 65);
|
||||
|
||||
fill(255);
|
||||
ellipse(0, 0, 16, 16);
|
||||
|
||||
angle_rot = 0;
|
||||
fill(51);
|
||||
|
||||
for(int i=0; i<5; i++) {
|
||||
pushMatrix();
|
||||
rotate(angle_rot + -45);
|
||||
ellipse(-116, 0, diameter, diameter);
|
||||
popMatrix();
|
||||
angle_rot += PI*2/5;
|
||||
}
|
||||
|
||||
diameter = 34 * sin(angle) + 168;
|
||||
|
||||
angle += 0.02;
|
||||
if (angle > TWO_PI) { angle = 0; }
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Sine Cosine.
|
||||
*
|
||||
* Linear movement with sin() and cos().
|
||||
* Numbers between 0 and PI*2 (TWO_PI which is roughly 6.28)
|
||||
* are put into these functions and numbers between -1 and 1 are
|
||||
* returned. These values are then scaled to produce larger movements.
|
||||
*/
|
||||
|
||||
int i = 45;
|
||||
int j = 225;
|
||||
float pos1 = 0;
|
||||
float pos2 = 0;
|
||||
float pos3 = 0;
|
||||
float pos4 = 0;
|
||||
int sc = 40;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
smooth();
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(0);
|
||||
|
||||
fill(51);
|
||||
rect(60, 60, 80, 80);
|
||||
|
||||
fill(255);
|
||||
ellipse(pos1, 36, 32, 32);
|
||||
|
||||
fill(153);
|
||||
ellipse(36, pos2, 32, 32);
|
||||
|
||||
fill(255);
|
||||
ellipse(pos3, 164, 32, 32);
|
||||
|
||||
fill(153);
|
||||
ellipse(164, pos4, 32, 32);
|
||||
|
||||
i += 3;
|
||||
j -= 3;
|
||||
|
||||
if(i > 405) {
|
||||
i = 45;
|
||||
j = 225;
|
||||
}
|
||||
|
||||
float ang1 = radians(i); // convert degrees to radians
|
||||
float ang2 = radians(j); // convert degrees to radians
|
||||
pos1 = width/2 + (sc * cos(ang1));
|
||||
pos2 = width/2 + (sc * sin(ang1));
|
||||
pos3 = width/2 + (sc * cos(ang2));
|
||||
pos4 = width/2 + (sc * sin(ang2));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class SineCosine extends PApplet {
|
||||
|
||||
/**
|
||||
* Sine Cosine.
|
||||
*
|
||||
* Linear movement with sin() and cos().
|
||||
* Numbers between 0 and PI*2 (TWO_PI which is roughly 6.28)
|
||||
* are put into these functions and numbers between -1 and 1 are
|
||||
* returned. These values are then scaled to produce larger movements.
|
||||
*/
|
||||
|
||||
int i = 45;
|
||||
int j = 225;
|
||||
float pos1 = 0;
|
||||
float pos2 = 0;
|
||||
float pos3 = 0;
|
||||
float pos4 = 0;
|
||||
int sc = 40;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
smooth();
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
background(0);
|
||||
|
||||
fill(51);
|
||||
rect(60, 60, 80, 80);
|
||||
|
||||
fill(255);
|
||||
ellipse(pos1, 36, 32, 32);
|
||||
|
||||
fill(153);
|
||||
ellipse(36, pos2, 32, 32);
|
||||
|
||||
fill(255);
|
||||
ellipse(pos3, 164, 32, 32);
|
||||
|
||||
fill(153);
|
||||
ellipse(164, pos4, 32, 32);
|
||||
|
||||
i += 3;
|
||||
j -= 3;
|
||||
|
||||
if(i > 405) {
|
||||
i = 45;
|
||||
j = 225;
|
||||
}
|
||||
|
||||
float ang1 = radians(i); // convert degrees to radians
|
||||
float ang2 = radians(j); // convert degrees to radians
|
||||
pos1 = width/2 + (sc * cos(ang1));
|
||||
pos2 = width/2 + (sc * sin(ang1));
|
||||
pos3 = width/2 + (sc * cos(ang2));
|
||||
pos4 = width/2 + (sc * sin(ang2));
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "SineCosine" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Sine Cosine.
|
||||
*
|
||||
* Linear movement with sin() and cos().
|
||||
* Numbers between 0 and PI*2 (TWO_PI which is roughly 6.28)
|
||||
* are put into these functions and numbers between -1 and 1 are
|
||||
* returned. These values are then scaled to produce larger movements.
|
||||
*/
|
||||
|
||||
int i = 45;
|
||||
int j = 225;
|
||||
float pos1 = 0;
|
||||
float pos2 = 0;
|
||||
float pos3 = 0;
|
||||
float pos4 = 0;
|
||||
int sc = 40;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
smooth();
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(0);
|
||||
|
||||
fill(51);
|
||||
rect(60, 60, 80, 80);
|
||||
|
||||
fill(255);
|
||||
ellipse(pos1, 36, 32, 32);
|
||||
|
||||
fill(153);
|
||||
ellipse(36, pos2, 32, 32);
|
||||
|
||||
fill(255);
|
||||
ellipse(pos3, 164, 32, 32);
|
||||
|
||||
fill(153);
|
||||
ellipse(164, pos4, 32, 32);
|
||||
|
||||
i += 3;
|
||||
j -= 3;
|
||||
|
||||
if(i > 405) {
|
||||
i = 45;
|
||||
j = 225;
|
||||
}
|
||||
|
||||
float ang1 = radians(i); // convert degrees to radians
|
||||
float ang2 = radians(j); // convert degrees to radians
|
||||
pos1 = width/2 + (sc * cos(ang1));
|
||||
pos2 = width/2 + (sc * sin(ang1));
|
||||
pos3 = width/2 + (sc * cos(ang2));
|
||||
pos4 = width/2 + (sc * sin(ang2));
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Sine Wave
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Render a simple sine wave.
|
||||
*/
|
||||
|
||||
int xspacing = 8; // How far apart should each horizontal location be spaced
|
||||
int w; // Width of entire wave
|
||||
|
||||
float theta = 0.0; // Start angle at 0
|
||||
float amplitude = 75.0; // Height of wave
|
||||
float period = 500.0; // How many pixels before the wave repeats
|
||||
float dx; // Value for incrementing X, a function of period and xspacing
|
||||
float[] yvalues; // Using an array to store height values for the wave
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
colorMode(RGB,255,255,255,100);
|
||||
smooth();
|
||||
w = width+16;
|
||||
dx = (TWO_PI / period) * xspacing;
|
||||
yvalues = new float[w/xspacing];
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
calcWave();
|
||||
renderWave();
|
||||
|
||||
}
|
||||
|
||||
void calcWave() {
|
||||
// Increment theta (try different values for 'angular velocity' here
|
||||
theta += 0.02;
|
||||
|
||||
// For every x value, calculate a y value with sine function
|
||||
float x = theta;
|
||||
for (int i = 0; i < yvalues.length; i++) {
|
||||
yvalues[i] = sin(x)*amplitude;
|
||||
x+=dx;
|
||||
}
|
||||
}
|
||||
|
||||
void renderWave() {
|
||||
// A simple way to draw the wave with an ellipse at each location
|
||||
for (int x = 0; x < yvalues.length; x++) {
|
||||
noStroke();
|
||||
fill(255,50);
|
||||
ellipseMode(CENTER);
|
||||
ellipse(x*xspacing,width/2+yvalues[x],16,16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class SineWave extends PApplet {
|
||||
|
||||
/**
|
||||
* Sine Wave
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Render a simple sine wave.
|
||||
*/
|
||||
|
||||
int xspacing = 8; // How far apart should each horizontal location be spaced
|
||||
int w; // Width of entire wave
|
||||
|
||||
float theta = 0.0f; // Start angle at 0
|
||||
float amplitude = 75.0f; // Height of wave
|
||||
float period = 500.0f; // How many pixels before the wave repeats
|
||||
float dx; // Value for incrementing X, a function of period and xspacing
|
||||
float[] yvalues; // Using an array to store height values for the wave
|
||||
|
||||
public void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
colorMode(RGB,255,255,255,100);
|
||||
smooth();
|
||||
w = width+16;
|
||||
dx = (TWO_PI / period) * xspacing;
|
||||
yvalues = new float[w/xspacing];
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(0);
|
||||
calcWave();
|
||||
renderWave();
|
||||
|
||||
}
|
||||
|
||||
public void calcWave() {
|
||||
// Increment theta (try different values for 'angular velocity' here
|
||||
theta += 0.02f;
|
||||
|
||||
// For every x value, calculate a y value with sine function
|
||||
float x = theta;
|
||||
for (int i = 0; i < yvalues.length; i++) {
|
||||
yvalues[i] = sin(x)*amplitude;
|
||||
x+=dx;
|
||||
}
|
||||
}
|
||||
|
||||
public void renderWave() {
|
||||
// A simple way to draw the wave with an ellipse at each location
|
||||
for (int x = 0; x < yvalues.length; x++) {
|
||||
noStroke();
|
||||
fill(255,50);
|
||||
ellipseMode(CENTER);
|
||||
ellipse(x*xspacing,width/2+yvalues[x],16,16);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "SineWave" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Sine Wave
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Render a simple sine wave.
|
||||
*/
|
||||
|
||||
int xspacing = 8; // How far apart should each horizontal location be spaced
|
||||
int w; // Width of entire wave
|
||||
|
||||
float theta = 0.0; // Start angle at 0
|
||||
float amplitude = 75.0; // Height of wave
|
||||
float period = 500.0; // How many pixels before the wave repeats
|
||||
float dx; // Value for incrementing X, a function of period and xspacing
|
||||
float[] yvalues; // Using an array to store height values for the wave
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
colorMode(RGB,255,255,255,100);
|
||||
smooth();
|
||||
w = width+16;
|
||||
dx = (TWO_PI / period) * xspacing;
|
||||
yvalues = new float[w/xspacing];
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
calcWave();
|
||||
renderWave();
|
||||
|
||||
}
|
||||
|
||||
void calcWave() {
|
||||
// Increment theta (try different values for 'angular velocity' here
|
||||
theta += 0.02;
|
||||
|
||||
// For every x value, calculate a y value with sine function
|
||||
float x = theta;
|
||||
for (int i = 0; i < yvalues.length; i++) {
|
||||
yvalues[i] = sin(x)*amplitude;
|
||||
x+=dx;
|
||||
}
|
||||
}
|
||||
|
||||
void renderWave() {
|
||||
// A simple way to draw the wave with an ellipse at each location
|
||||
for (int x = 0; x < yvalues.length; x++) {
|
||||
noStroke();
|
||||
fill(255,50);
|
||||
ellipseMode(CENTER);
|
||||
ellipse(x*xspacing,width/2+yvalues[x],16,16);
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |