Hey people,

I have managed to combine two sources to make a colourful ripple effect with a continuous flow but I am now stuck as to how I make the background transparent.

This is to be projected on to a wall, hence the desire for it to be see through. Here is the source code for what I already have....

//ring.pde

ArrayList ripples;

color bg = 0;

int c1 = 255; // Color array

int c2 = 127;

color[] c = {

color(c1, c2, 0), color(c1, 0, c2), color(c2, c1, 0), color(c2, 0, c1), color(0, c2, c1), };

void setup() {

size(500, 500);

ripples = new ArrayList();

smooth();

stroke(255);

strokeWeight(3);

noFill();

}

void draw() {

background(bg);

for( int i = ripples.size()-1; i >= 0;i--){

Ripple ripple = (Ripple) ripples.get(i);

ripple.resize();

ripple.display();

if(!ripple.on)ripples.remove(i);

}

}

void mouseDragged() {

int which = round(random(4)); // pick a color, any color (or the number associateing to that color in the array)

ripples.add(new Ripple(mouseX, mouseY, which));

}

void keyPressed() {

if (keyCode == ' ') {

if (bg == 0) {

bg = 255;

} else {

bg = 0;

}

}

}

//ripple class

class Ripple { // The ripple class

float x, y; //

float diameter, alph;

boolean on;

boolean finished = false;

color colors;

public Ripple(float xpos, float ypos, color shade) {

x = xpos;

y = ypos;

on = true;

diameter = 1;

colors = shade;

}

void resize() {

if (on) {

if (diameter < 200) {

diameter++;

alph = abs((diameter*1.275)-255);

} else {

on = false;

}

}

}

void display() {

noFill();

stroke(c[colors], alph);

strokeWeight(3);

ellipse(x, y, diameter, diameter);

}

}

Thanks in advance for any help.

I have managed to combine two sources to make a colourful ripple effect with a continuous flow but I am now stuck as to how I make the background transparent.

This is to be projected on to a wall, hence the desire for it to be see through. Here is the source code for what I already have....

//ring.pde

ArrayList ripples;

color bg = 0;

int c1 = 255; // Color array

int c2 = 127;

color[] c = {

color(c1, c2, 0), color(c1, 0, c2), color(c2, c1, 0), color(c2, 0, c1), color(0, c2, c1), };

void setup() {

size(500, 500);

ripples = new ArrayList();

smooth();

stroke(255);

strokeWeight(3);

noFill();

}

void draw() {

background(bg);

for( int i = ripples.size()-1; i >= 0;i--){

Ripple ripple = (Ripple) ripples.get(i);

ripple.resize();

ripple.display();

if(!ripple.on)ripples.remove(i);

}

}

void mouseDragged() {

int which = round(random(4)); // pick a color, any color (or the number associateing to that color in the array)

ripples.add(new Ripple(mouseX, mouseY, which));

}

void keyPressed() {

if (keyCode == ' ') {

if (bg == 0) {

bg = 255;

} else {

bg = 0;

}

}

}

//ripple class

class Ripple { // The ripple class

float x, y; //

float diameter, alph;

boolean on;

boolean finished = false;

color colors;

public Ripple(float xpos, float ypos, color shade) {

x = xpos;

y = ypos;

on = true;

diameter = 1;

colors = shade;

}

void resize() {

if (on) {

if (diameter < 200) {

diameter++;

alph = abs((diameter*1.275)-255);

} else {

on = false;

}

}

}

void display() {

noFill();

stroke(c[colors], alph);

strokeWeight(3);

ellipse(x, y, diameter, diameter);

}

}

Thanks in advance for any help.

1