removing applet folders from svn
@@ -1,51 +0,0 @@
|
||||
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 Brightness extends PApplet {
|
||||
|
||||
/**
|
||||
* Brightness
|
||||
* by Rusty Robison.
|
||||
*
|
||||
* Brightness is the relative lightness or darkness of a color.
|
||||
* Move the cursor vertically over each bar to alter its brightness.
|
||||
*/
|
||||
|
||||
int barWidth = 5;
|
||||
int[] brightness;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
colorMode(HSB, 360, height, height);
|
||||
brightness = new int[width/barWidth];
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
int j = 0;
|
||||
for (int i = 0; i <= (width-barWidth); i += barWidth) {
|
||||
noStroke();
|
||||
if ((mouseX > i) && (mouseX < i+barWidth)) {
|
||||
brightness[j] = mouseY;
|
||||
}
|
||||
fill(i, height, brightness[j]);
|
||||
rect(i, 0, barWidth, height);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Brightness" });
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* Brightness
|
||||
* by Rusty Robison.
|
||||
*
|
||||
* Brightness is the relative lightness or darkness of a color.
|
||||
* Move the cursor vertically over each bar to alter its brightness.
|
||||
*/
|
||||
|
||||
int barWidth = 5;
|
||||
int[] brightness;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
colorMode(HSB, 360, height, height);
|
||||
brightness = new int[width/barWidth];
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
int j = 0;
|
||||
for (int i = 0; i <= (width-barWidth); i += barWidth) {
|
||||
noStroke();
|
||||
if ((mouseX > i) && (mouseX < i+barWidth)) {
|
||||
brightness[j] = mouseY;
|
||||
}
|
||||
fill(i, height, brightness[j]);
|
||||
rect(i, 0, barWidth, height);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,99 +0,0 @@
|
||||
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 ColorWheel extends PApplet {
|
||||
|
||||
/**
|
||||
* Subtractive Color Wheel
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* The primaries are red, yellow, and blue. The
|
||||
* secondaries are green, purple, and orange. The
|
||||
* tertiaries are yellow-orange, red-orange, red-purple,
|
||||
* blue-purple, blue-green, and yellow-green.
|
||||
*
|
||||
* Create a shade or tint of the
|
||||
* subtractive color wheel using
|
||||
* SHADE or TINT parameters.
|
||||
*/
|
||||
|
||||
int segs = 12;
|
||||
int steps = 6;
|
||||
float rotAdjust = radians(360.0f/segs/2.0f);
|
||||
float radius = 95.0f;
|
||||
float segWidth = radius/steps;
|
||||
float interval = TWO_PI/segs;
|
||||
int SHADE = 0;
|
||||
int TINT = 1;
|
||||
|
||||
public void setup(){
|
||||
size(200, 200);
|
||||
background(127);
|
||||
smooth();
|
||||
ellipseMode(CENTER_RADIUS);
|
||||
noStroke();
|
||||
// you can substitue TINT for SHADE argument
|
||||
createWheel(width/2, height/2, SHADE);
|
||||
}
|
||||
|
||||
public void createWheel(int x, int y, int valueShift){
|
||||
if (valueShift == SHADE){
|
||||
for (int j=0; j<steps; j++){
|
||||
int[]cols = {
|
||||
color(255-(255/steps)*j, 255-(255/steps)*j, 0),
|
||||
color(255-(255/steps)*j, (255/1.5f)-((255/1.5f)/steps)*j, 0),
|
||||
color(255-(255/steps)*j, (255/2)-((255/2)/steps)*j, 0),
|
||||
color(255-(255/steps)*j, (255/2.5f)-((255/2.5f)/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.5f)-((255/2.5f)/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(x, y, radius, radius, interval*i+rotAdjust, interval*(i+1)+rotAdjust);
|
||||
}
|
||||
radius -= segWidth;
|
||||
}
|
||||
} else if (valueShift == TINT){
|
||||
for (int j=0; j<steps; j++){
|
||||
int[]cols = {
|
||||
color((255/steps)*j, (255/steps)*j, 0),
|
||||
color((255/steps)*j, ((255/1.5f)/steps)*j, 0),
|
||||
color((255/steps)*j, ((255/2)/steps)*j, 0),
|
||||
color((255/steps)*j, ((255/2.5f)/steps)*j, 0),
|
||||
color((255/steps)*j, 0, 0),
|
||||
color((255/steps)*j, 0, ((255/2)/steps)*j),
|
||||
color((255/steps)*j, 0, (255/steps)*j),
|
||||
color(((255/2)/steps)*j, 0, (255/steps)*j),
|
||||
color(0, 0, (255/steps)*j),
|
||||
color(0, (255/steps)*j, ((255/2.5f)/steps)*j),
|
||||
color(0, (255/steps)*j, 0),
|
||||
color(((255/2)/steps)*j, (255/steps)*j, 0) };
|
||||
for (int i=0; i< segs; i++){
|
||||
fill(cols[i]);
|
||||
arc(x, y, radius, radius, interval*i+rotAdjust, interval*(i+1)+rotAdjust);
|
||||
}
|
||||
radius -= segWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "ColorWheel" });
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* Subtractive Color Wheel
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* The primaries are red, yellow, and blue. The
|
||||
* secondaries are green, purple, and orange. The
|
||||
* tertiaries are yellow-orange, red-orange, red-purple,
|
||||
* blue-purple, blue-green, and yellow-green.
|
||||
*
|
||||
* Create a shade or tint of the
|
||||
* subtractive color wheel using
|
||||
* SHADE or TINT parameters.
|
||||
*/
|
||||
|
||||
int segs = 12;
|
||||
int steps = 6;
|
||||
float rotAdjust = radians(360.0/segs/2.0);
|
||||
float radius = 95.0;
|
||||
float segWidth = radius/steps;
|
||||
float interval = TWO_PI/segs;
|
||||
int SHADE = 0;
|
||||
int TINT = 1;
|
||||
|
||||
void setup(){
|
||||
size(200, 200);
|
||||
background(127);
|
||||
smooth();
|
||||
ellipseMode(CENTER_RADIUS);
|
||||
noStroke();
|
||||
// you can substitue TINT for SHADE argument
|
||||
createWheel(width/2, height/2, SHADE);
|
||||
}
|
||||
|
||||
void createWheel(int x, int y, int valueShift){
|
||||
if (valueShift == SHADE){
|
||||
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(x, y, radius, radius, interval*i+rotAdjust, interval*(i+1)+rotAdjust);
|
||||
}
|
||||
radius -= segWidth;
|
||||
}
|
||||
} else if (valueShift == TINT){
|
||||
for (int j=0; j<steps; j++){
|
||||
color[]cols = {
|
||||
color((255/steps)*j, (255/steps)*j, 0),
|
||||
color((255/steps)*j, ((255/1.5)/steps)*j, 0),
|
||||
color((255/steps)*j, ((255/2)/steps)*j, 0),
|
||||
color((255/steps)*j, ((255/2.5)/steps)*j, 0),
|
||||
color((255/steps)*j, 0, 0),
|
||||
color((255/steps)*j, 0, ((255/2)/steps)*j),
|
||||
color((255/steps)*j, 0, (255/steps)*j),
|
||||
color(((255/2)/steps)*j, 0, (255/steps)*j),
|
||||
color(0, 0, (255/steps)*j),
|
||||
color(0, (255/steps)*j, ((255/2.5)/steps)*j),
|
||||
color(0, (255/steps)*j, 0),
|
||||
color(((255/2)/steps)*j, (255/steps)*j, 0) };
|
||||
for (int i=0; i< segs; i++){
|
||||
fill(cols[i]);
|
||||
arc(x, y, radius, radius, interval*i+rotAdjust, interval*(i+1)+rotAdjust);
|
||||
}
|
||||
radius -= segWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,47 +0,0 @@
|
||||
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 Creating extends PApplet {
|
||||
public void setup() {/**
|
||||
* Creating Colors (Homage to Albers).
|
||||
*
|
||||
* Creating variables for colors that may be referred to
|
||||
* in the program by their name, rather than a number.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
|
||||
int inside = color(204, 102, 0);
|
||||
int middle = color(204, 153, 0);
|
||||
int outside = color(153, 51, 0);
|
||||
|
||||
// These statements are equivalent to the statements above.
|
||||
// Programmers may use the format they prefer.
|
||||
//color inside = #CC6600;
|
||||
//color middle = #CC9900;
|
||||
//color outside = #993300;
|
||||
|
||||
fill(outside);
|
||||
rect(0, 0, 200, 200);
|
||||
fill(middle);
|
||||
rect(40, 60, 120, 120);
|
||||
fill(inside);
|
||||
rect(60, 90, 80, 80);
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Creating" });
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Creating Colors (Homage to Albers).
|
||||
*
|
||||
* Creating variables for colors that may be referred to
|
||||
* in the program by their name, rather than a number.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
|
||||
color inside = color(204, 102, 0);
|
||||
color middle = color(204, 153, 0);
|
||||
color outside = color(153, 51, 0);
|
||||
|
||||
// These statements are equivalent to the statements above.
|
||||
// Programmers may use the format they prefer.
|
||||
//color inside = #CC6600;
|
||||
//color middle = #CC9900;
|
||||
//color outside = #993300;
|
||||
|
||||
fill(outside);
|
||||
rect(0, 0, 200, 200);
|
||||
fill(middle);
|
||||
rect(40, 60, 120, 120);
|
||||
fill(inside);
|
||||
rect(60, 90, 80, 80);
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,51 +0,0 @@
|
||||
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 Hue extends PApplet {
|
||||
|
||||
/**
|
||||
* Hue.
|
||||
*
|
||||
* Hue is the color reflected from or transmitted through an object
|
||||
* and is typically referred to as the name of the color (red, blue, yellow, etc.)
|
||||
* Move the cursor vertically over each bar to alter its hue.
|
||||
*/
|
||||
|
||||
int barWidth = 5;
|
||||
int[] hue;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
colorMode(HSB, 360, height, height);
|
||||
hue = new int[width/barWidth];
|
||||
noStroke();
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
int j = 0;
|
||||
for (int i=0; i<=(width-barWidth); i+=barWidth) {
|
||||
if ((mouseX > i) && (mouseX < i+barWidth)) {
|
||||
hue[j] = mouseY;
|
||||
}
|
||||
fill(hue[j], height/1.2f, height/1.2f);
|
||||
rect(i, 0, barWidth, height);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Hue" });
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* Hue.
|
||||
*
|
||||
* Hue is the color reflected from or transmitted through an object
|
||||
* and is typically referred to as the name of the color (red, blue, yellow, etc.)
|
||||
* Move the cursor vertically over each bar to alter its hue.
|
||||
*/
|
||||
|
||||
int barWidth = 5;
|
||||
int[] hue;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
colorMode(HSB, 360, height, height);
|
||||
hue = new int[width/barWidth];
|
||||
noStroke();
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
int j = 0;
|
||||
for (int i=0; i<=(width-barWidth); i+=barWidth) {
|
||||
if ((mouseX > i) && (mouseX < i+barWidth)) {
|
||||
hue[j] = mouseY;
|
||||
}
|
||||
fill(hue[j], height/1.2, height/1.2);
|
||||
rect(i, 0, barWidth, height);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,93 +0,0 @@
|
||||
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 LinearGradient extends PApplet {
|
||||
|
||||
/**
|
||||
* Simple Linear Gradient
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* Using the convenient red(), green()
|
||||
* and blue() component functions,
|
||||
* generate some linear gradients.
|
||||
*/
|
||||
|
||||
// constants
|
||||
int Y_AXIS = 1;
|
||||
int X_AXIS = 2;
|
||||
|
||||
public void setup(){
|
||||
size(200, 200);
|
||||
|
||||
// create some gradients
|
||||
// background
|
||||
int b1 = color(190, 190, 190);
|
||||
int b2 = color(20, 20, 20);
|
||||
setGradient(0, 0, width, height, b1, b2, Y_AXIS);
|
||||
//center squares
|
||||
int c1 = color(255, 120, 0);
|
||||
int c2 = color(10, 45, 255);
|
||||
int c3 = color(10, 255, 15);
|
||||
int c4 = color(125, 2, 140);
|
||||
int c5 = color(255, 255, 0);
|
||||
int c6 = color(25, 255, 200);
|
||||
setGradient(25, 25, 75, 75, c1, c2, Y_AXIS);
|
||||
setGradient(100, 25, 75, 75, c3, c4, X_AXIS);
|
||||
setGradient(25, 100, 75, 75, c2, c5, X_AXIS);
|
||||
setGradient(100, 100, 75, 75, c4, c6, Y_AXIS);
|
||||
}
|
||||
|
||||
public void setGradient(int x, int y, float w, float h, int c1, int c2, int axis ){
|
||||
// calculate differences between color components
|
||||
float deltaR = red(c2)-red(c1);
|
||||
float deltaG = green(c2)-green(c1);
|
||||
float deltaB = blue(c2)-blue(c1);
|
||||
|
||||
// choose axis
|
||||
if(axis == Y_AXIS){
|
||||
/*nested for loops set pixels
|
||||
in a basic table structure */
|
||||
// column
|
||||
for (int i=x; i<=(x+w); i++){
|
||||
// row
|
||||
for (int j = y; j<=(y+h); j++){
|
||||
int c = color(
|
||||
(red(c1)+(j-y)*(deltaR/h)),
|
||||
(green(c1)+(j-y)*(deltaG/h)),
|
||||
(blue(c1)+(j-y)*(deltaB/h))
|
||||
);
|
||||
set(i, j, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(axis == X_AXIS){
|
||||
// column
|
||||
for (int i=y; i<=(y+h); i++){
|
||||
// row
|
||||
for (int j = x; j<=(x+w); j++){
|
||||
int c = color(
|
||||
(red(c1)+(j-x)*(deltaR/h)),
|
||||
(green(c1)+(j-x)*(deltaG/h)),
|
||||
(blue(c1)+(j-x)*(deltaB/h))
|
||||
);
|
||||
set(j, i, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "LinearGradient" });
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/**
|
||||
* Simple Linear Gradient
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* Using the convenient red(), green()
|
||||
* and blue() component functions,
|
||||
* generate some linear gradients.
|
||||
*/
|
||||
|
||||
// constants
|
||||
int Y_AXIS = 1;
|
||||
int X_AXIS = 2;
|
||||
|
||||
void setup(){
|
||||
size(200, 200);
|
||||
|
||||
// create some gradients
|
||||
// background
|
||||
color b1 = color(190, 190, 190);
|
||||
color b2 = color(20, 20, 20);
|
||||
setGradient(0, 0, width, height, b1, b2, Y_AXIS);
|
||||
//center squares
|
||||
color c1 = color(255, 120, 0);
|
||||
color c2 = color(10, 45, 255);
|
||||
color c3 = color(10, 255, 15);
|
||||
color c4 = color(125, 2, 140);
|
||||
color c5 = color(255, 255, 0);
|
||||
color c6 = color(25, 255, 200);
|
||||
setGradient(25, 25, 75, 75, c1, c2, Y_AXIS);
|
||||
setGradient(100, 25, 75, 75, c3, c4, X_AXIS);
|
||||
setGradient(25, 100, 75, 75, c2, c5, X_AXIS);
|
||||
setGradient(100, 100, 75, 75, c4, c6, Y_AXIS);
|
||||
}
|
||||
|
||||
void setGradient(int x, int y, float w, float h, color c1, color c2, int axis ){
|
||||
// calculate differences between color components
|
||||
float deltaR = red(c2)-red(c1);
|
||||
float deltaG = green(c2)-green(c1);
|
||||
float deltaB = blue(c2)-blue(c1);
|
||||
|
||||
// choose axis
|
||||
if(axis == Y_AXIS){
|
||||
/*nested for loops set pixels
|
||||
in a basic table structure */
|
||||
// column
|
||||
for (int i=x; i<=(x+w); i++){
|
||||
// row
|
||||
for (int j = y; j<=(y+h); j++){
|
||||
color c = color(
|
||||
(red(c1)+(j-y)*(deltaR/h)),
|
||||
(green(c1)+(j-y)*(deltaG/h)),
|
||||
(blue(c1)+(j-y)*(deltaB/h))
|
||||
);
|
||||
set(i, j, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(axis == X_AXIS){
|
||||
// column
|
||||
for (int i=y; i<=(y+h); i++){
|
||||
// row
|
||||
for (int j = x; j<=(x+w); j++){
|
||||
color c = color(
|
||||
(red(c1)+(j-x)*(deltaR/h)),
|
||||
(green(c1)+(j-x)*(deltaG/h)),
|
||||
(blue(c1)+(j-x)*(deltaB/h))
|
||||
);
|
||||
set(j, i, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,78 +0,0 @@
|
||||
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 RadialGradient extends PApplet {
|
||||
|
||||
/**
|
||||
* Simple Radial Gradient
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* Using the convenient red(), green()
|
||||
* and blue() component functions,
|
||||
* generate an array of radial gradients.
|
||||
*/
|
||||
|
||||
public void setup(){
|
||||
size(200, 200);
|
||||
background(0);
|
||||
smooth();
|
||||
|
||||
// create a simple table of gradients
|
||||
int columns = 4;
|
||||
int radius = (width/columns)/2;
|
||||
// create some gradients
|
||||
for (int i=radius; i< width; i+=radius*2){
|
||||
for (int j =radius; j< height; j+=radius*2){
|
||||
createGradient(i, j, radius,
|
||||
color(PApplet.parseInt(random(255)), PApplet.parseInt(random(255)), PApplet.parseInt(random(255))),
|
||||
color(PApplet.parseInt(random(255)), PApplet.parseInt(random(255)), PApplet.parseInt(random(255))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void createGradient (float x, float y, float radius, int c1, int c2){
|
||||
float px = 0, py = 0, angle = 0;
|
||||
|
||||
// calculate differences between color components
|
||||
float deltaR = red(c2)-red(c1);
|
||||
float deltaG = green(c2)-green(c1);
|
||||
float deltaB = blue(c2)-blue(c1);
|
||||
// hack to ensure there are no holes in gradient
|
||||
// needs to be increased, as radius increases
|
||||
float gapFiller = 8.0f;
|
||||
|
||||
for (int i=0; i< radius; i++){
|
||||
for (float j=0; j<360; j+=1.0f/gapFiller){
|
||||
px = x+cos(radians(angle))*i;
|
||||
py = y+sin(radians(angle))*i;
|
||||
angle+=1.0f/gapFiller;
|
||||
int c = color(
|
||||
(red(c1)+(i)*(deltaR/radius)),
|
||||
(green(c1)+(i)*(deltaG/radius)),
|
||||
(blue(c1)+(i)*(deltaB/radius))
|
||||
);
|
||||
set(PApplet.parseInt(px), PApplet.parseInt(py), c);
|
||||
}
|
||||
}
|
||||
// adds smooth edge
|
||||
// hack anti-aliasing
|
||||
noFill();
|
||||
strokeWeight(3);
|
||||
ellipse(x, y, radius*2, radius*2);
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "RadialGradient" });
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/**
|
||||
* Simple Radial Gradient
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* Using the convenient red(), green()
|
||||
* and blue() component functions,
|
||||
* generate an array of radial gradients.
|
||||
*/
|
||||
|
||||
void setup(){
|
||||
size(200, 200);
|
||||
background(0);
|
||||
smooth();
|
||||
|
||||
// create a simple table of gradients
|
||||
int columns = 4;
|
||||
int radius = (width/columns)/2;
|
||||
// create some gradients
|
||||
for (int i=radius; i< width; i+=radius*2){
|
||||
for (int j =radius; j< height; j+=radius*2){
|
||||
createGradient(i, j, radius,
|
||||
color(int(random(255)), int(random(255)), int(random(255))),
|
||||
color(int(random(255)), int(random(255)), int(random(255))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void createGradient (float x, float y, float radius, color c1, color c2){
|
||||
float px = 0, py = 0, angle = 0;
|
||||
|
||||
// calculate differences between color components
|
||||
float deltaR = red(c2)-red(c1);
|
||||
float deltaG = green(c2)-green(c1);
|
||||
float deltaB = blue(c2)-blue(c1);
|
||||
// hack to ensure there are no holes in gradient
|
||||
// needs to be increased, as radius increases
|
||||
float gapFiller = 8.0;
|
||||
|
||||
for (int i=0; i< radius; i++){
|
||||
for (float j=0; j<360; j+=1.0/gapFiller){
|
||||
px = x+cos(radians(angle))*i;
|
||||
py = y+sin(radians(angle))*i;
|
||||
angle+=1.0/gapFiller;
|
||||
color c = color(
|
||||
(red(c1)+(i)*(deltaR/radius)),
|
||||
(green(c1)+(i)*(deltaG/radius)),
|
||||
(blue(c1)+(i)*(deltaB/radius))
|
||||
);
|
||||
set(int(px), int(py), c);
|
||||
}
|
||||
}
|
||||
// adds smooth edge
|
||||
// hack anti-aliasing
|
||||
noFill();
|
||||
strokeWeight(3);
|
||||
ellipse(x, y, radius*2, radius*2);
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,63 +0,0 @@
|
||||
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 Reading extends PApplet {
|
||||
public void setup() {/**
|
||||
* Reading.
|
||||
*
|
||||
* An image is recreated from its individual component colors.
|
||||
* The many colors of the image are created through modulating the
|
||||
* red, green, and blue values. This is an exageration of an LCD display.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
background(0);
|
||||
|
||||
// Load an image from the data directory
|
||||
PImage c;
|
||||
c = loadImage("cait.jpg");
|
||||
|
||||
int xoff = 0;
|
||||
int yoff = 0;
|
||||
int p = 2;
|
||||
int pix = p*3;
|
||||
|
||||
|
||||
for(int i = 0; i < c.width*c.height; i += 1)
|
||||
{
|
||||
int here = c.pixels[i];
|
||||
|
||||
fill(red(here), 0, 0);
|
||||
rect(xoff, yoff, p, pix);
|
||||
|
||||
fill(0, green(here), 0);
|
||||
rect(xoff+p, yoff, p, pix);
|
||||
|
||||
fill(0, 0, blue(here));
|
||||
rect(xoff+p*2, yoff, p, pix);
|
||||
|
||||
xoff+=pix;
|
||||
if(xoff >= width-pix) {
|
||||
xoff = 0;
|
||||
yoff += pix;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Reading" });
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* Reading.
|
||||
*
|
||||
* An image is recreated from its individual component colors.
|
||||
* The many colors of the image are created through modulating the
|
||||
* red, green, and blue values. This is an exageration of an LCD display.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
background(0);
|
||||
|
||||
// Load an image from the data directory
|
||||
PImage c;
|
||||
c = loadImage("cait.jpg");
|
||||
|
||||
int xoff = 0;
|
||||
int yoff = 0;
|
||||
int p = 2;
|
||||
int pix = p*3;
|
||||
|
||||
|
||||
for(int i = 0; i < c.width*c.height; i += 1)
|
||||
{
|
||||
int here = c.pixels[i];
|
||||
|
||||
fill(red(here), 0, 0);
|
||||
rect(xoff, yoff, p, pix);
|
||||
|
||||
fill(0, green(here), 0);
|
||||
rect(xoff+p, yoff, p, pix);
|
||||
|
||||
fill(0, 0, blue(here));
|
||||
rect(xoff+p*2, yoff, p, pix);
|
||||
|
||||
xoff+=pix;
|
||||
if(xoff >= width-pix) {
|
||||
xoff = 0;
|
||||
yoff += pix;
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,62 +0,0 @@
|
||||
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 Relativity extends PApplet {
|
||||
|
||||
/**
|
||||
* Relativity.
|
||||
*
|
||||
* Each color is perceived in relation to other colors.
|
||||
* The top and bottom bars each contain the same component colors,
|
||||
* but a different display order causes individual colors to appear differently.
|
||||
*/
|
||||
|
||||
int a, b, c, d, e;
|
||||
|
||||
public void setup() {
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
a = color(165, 167, 20);
|
||||
b = color(77, 86, 59);
|
||||
c = color(42, 106, 105);
|
||||
d = color(165, 89, 20);
|
||||
e = color(146, 150, 127);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
drawBand(a, b, c, d, e, 0, 4);
|
||||
drawBand(c, a, d, b, e, height/2, 4);
|
||||
}
|
||||
|
||||
public void drawBand(int v, int w, int x, int y, int z, int ypos, int barWidth) {
|
||||
int num = 5;
|
||||
int[] colorOrder = { v, w, x, y, z };
|
||||
for(int i = 0; i < width; i += barWidth*num) {
|
||||
for(int j = 0; j < num; j++) {
|
||||
fill(colorOrder[j]);
|
||||
rect(i+j*barWidth, ypos, barWidth, height/2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Relativity" });
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* Relativity.
|
||||
*
|
||||
* Each color is perceived in relation to other colors.
|
||||
* The top and bottom bars each contain the same component colors,
|
||||
* but a different display order causes individual colors to appear differently.
|
||||
*/
|
||||
|
||||
color a, b, c, d, e;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
a = color(165, 167, 20);
|
||||
b = color(77, 86, 59);
|
||||
c = color(42, 106, 105);
|
||||
d = color(165, 89, 20);
|
||||
e = color(146, 150, 127);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
drawBand(a, b, c, d, e, 0, 4);
|
||||
drawBand(c, a, d, b, e, height/2, 4);
|
||||
}
|
||||
|
||||
void drawBand(color v, color w, color x, color y, color z, int ypos, int barWidth) {
|
||||
int num = 5;
|
||||
color[] colorOrder = { v, w, x, y, z };
|
||||
for(int i = 0; i < width; i += barWidth*num) {
|
||||
for(int j = 0; j < num; j++) {
|
||||
fill(colorOrder[j]);
|
||||
rect(i+j*barWidth, ypos, barWidth, height/2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,52 +0,0 @@
|
||||
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 Saturation extends PApplet {
|
||||
|
||||
/**
|
||||
* Saturation.
|
||||
*
|
||||
* Saturation is the strength or purity of the color and represents the
|
||||
* amount of gray in proportion to the hue. A "saturated" color is pure
|
||||
* and an "unsaturated" color has a large percentage of gray.
|
||||
* Move the cursor vertically over each bar to alter its saturation.
|
||||
*/
|
||||
|
||||
int barWidth = 5;
|
||||
int[] saturation;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
colorMode(HSB, 360, height, height);
|
||||
saturation = new int[width/barWidth];
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
int j = 0;
|
||||
for (int i=0; i<=(width-barWidth); i+=barWidth) {
|
||||
noStroke();
|
||||
if ((mouseX > i) && (mouseX < i+barWidth)) {
|
||||
saturation[j] = mouseY;
|
||||
}
|
||||
fill(i, saturation[j], height/1.5f);
|
||||
rect(i, 0, barWidth, height);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Saturation" });
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* Saturation.
|
||||
*
|
||||
* Saturation is the strength or purity of the color and represents the
|
||||
* amount of gray in proportion to the hue. A "saturated" color is pure
|
||||
* and an "unsaturated" color has a large percentage of gray.
|
||||
* Move the cursor vertically over each bar to alter its saturation.
|
||||
*/
|
||||
|
||||
int barWidth = 5;
|
||||
int[] saturation;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
colorMode(HSB, 360, height, height);
|
||||
saturation = new int[width/barWidth];
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
int j = 0;
|
||||
for (int i=0; i<=(width-barWidth); i+=barWidth) {
|
||||
noStroke();
|
||||
if ((mouseX > i) && (mouseX < i+barWidth)) {
|
||||
saturation[j] = mouseY;
|
||||
}
|
||||
fill(i, saturation[j], height/1.5);
|
||||
rect(i, 0, barWidth, height);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,59 +0,0 @@
|
||||
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 WaveGradient extends PApplet {
|
||||
|
||||
/**
|
||||
* Wave Gradient
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* Generate a gradient along a sin() wave.
|
||||
*/
|
||||
|
||||
float angle = 0;
|
||||
float px = 0, py = 0;
|
||||
float amplitude = 30;
|
||||
float frequency = 0;
|
||||
float fillGap = 2.5f;
|
||||
int c;
|
||||
|
||||
public void setup() {
|
||||
size(200, 200);
|
||||
background(200,200,200);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
for (int i =- 75; i < height+75; i++){
|
||||
// Reset angle to 0, so waves stack properly
|
||||
angle = 0;
|
||||
// Increasing frequency causes more gaps
|
||||
frequency+=.006f;
|
||||
for (float j=0; j<width+75; j++){
|
||||
py = i+sin(radians(angle))*amplitude;
|
||||
angle+=frequency;
|
||||
c = color(abs(py-i)*255/amplitude, 255-abs(py-i)*255/amplitude, j*(255.0f/(width+50)));
|
||||
// Hack to fill gaps. Raise value of fillGap if you increase frequency
|
||||
for (int filler = 0; filler<fillGap; filler++){
|
||||
set(PApplet.parseInt(j-filler), PApplet.parseInt(py)-filler, c);
|
||||
set(PApplet.parseInt(j), PApplet.parseInt(py), c);
|
||||
set(PApplet.parseInt(j+filler), PApplet.parseInt(py)+filler, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "WaveGradient" });
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/**
|
||||
* Wave Gradient
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* Generate a gradient along a sin() wave.
|
||||
*/
|
||||
|
||||
float angle = 0;
|
||||
float px = 0, py = 0;
|
||||
float amplitude = 30;
|
||||
float frequency = 0;
|
||||
float fillGap = 2.5;
|
||||
color c;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
background(200,200,200);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
for (int i =- 75; i < height+75; i++){
|
||||
// Reset angle to 0, so waves stack properly
|
||||
angle = 0;
|
||||
// Increasing frequency causes more gaps
|
||||
frequency+=.006;
|
||||
for (float j=0; j<width+75; j++){
|
||||
py = i+sin(radians(angle))*amplitude;
|
||||
angle+=frequency;
|
||||
c = color(abs(py-i)*255/amplitude, 255-abs(py-i)*255/amplitude, j*(255.0/(width+50)));
|
||||
// Hack to fill gaps. Raise value of fillGap if you increase frequency
|
||||
for (int filler = 0; filler<fillGap; filler++){
|
||||
set(int(j-filler), int(py)-filler, c);
|
||||
set(int(j), int(py), c);
|
||||
set(int(j+filler), int(py)+filler, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |