We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › programming a color mixer diagram
Page Index Toggle Pages: 1
programming a color mixer diagram (Read 1389 times)
programming a color mixer diagram
Jul 6th, 2009, 10:13pm
 
Out of curiosity, is there an easy way to program an image like this in processing:
http://www.processing.org/learning/tutorials/color/imgs/rgb.png

The trick is to show transparency only where overlapping (and between the images) and not to the background color.

Any clues?

Re: programming a color mixer diagram
Reply #1 - Jul 6th, 2009, 11:22pm
 
Unless somebody smarter has a better idea, I would say if you need different transparency on a shape, you need to make compound shapes, ie. different shapes. Or make a shape behind to make a neutral background on the overall shape.
Re: programming a color mixer diagram
Reply #2 - Jul 7th, 2009, 1:46am
 
search for "additive blending"

basically you have three circles ff0000, 00ff00 and 0000ff. when they overlap you just add them together (or let the software do it)

maybe use blend() (which only works with images - just use a white circle).
Re: programming a color mixer diagram
Reply #3 - Jul 8th, 2009, 9:26am
 
i had a bash at this last night using blend().

i had thought i could use 1 white circle image and tint() but tint() and blend() don't like working together so i ended up with a red, green and blue circle. took a background(), 3 loadImage()s and 3 blend()s

(but i'm worried that using 3 circles is cheating)
Re: programming a color mixer diagram
Reply #4 - Jul 8th, 2009, 9:43am
 
Why loadImage? You can draw the circles on a PGraphics, no?
Re: programming a color mixer diagram
Reply #5 - Jul 8th, 2009, 11:26am
 
have never used them. but, looking at the reference, yes, i guess so.

(and that might help with my video feedback idea that i haven't ever had any luck with. will try that tonight in front of tv)
Re: programming a color mixer diagram
Reply #6 - Jul 8th, 2009, 12:25pm
 
I would do it like that...

http://dec32.de/public/p5/rgb

ok the bouncing balls are not necessary but i had to...

Re: programming a color mixer diagram
Reply #7 - Jul 8th, 2009, 1:23pm
 
nice.

maybe i should mention this:

http://www.koogy.clara.co.uk/overlap/index.html

from 2003... (and even that was based on an amiga program from a few years earlier)

(and based originally on an animation (1935) by Len Lye, which is actually an advert for the post office and has been mangled by youtube here: http://www.youtube.com/watch?v=T3y1offmJ4Y )

(and also the wallpaper here: http://www.youtube.com/watch?v=fK3tJgYGI0s about 1m40s in)

8)
Re: programming a color mixer diagram
Reply #8 - Jul 8th, 2009, 3:27pm
 
off topic somewhat - the aforementioned attempt at a feedback effect:

Code:

static final int SIZE = 200;
static final int HSIZE = 100;

// double buffers
PGraphics front;

void setup() {
 size(SIZE, SIZE, P2D);
 front = createGraphics(SIZE, SIZE, P2D);
 frameRate(20);
}

void draw() {
 
 int x = (int)random(-5, 5);
 int y = (int)random(-5, 5);
 int r = (int)random(128, 255);
 int g = (int)random(128, 255);
 int b = (int)random(128, 255);
 
 front.beginDraw();
 front.translate(HSIZE, HSIZE);  // move origin to centre
 // copy saved image to foreground, twisted and a bit larger
 front.rotate(.02);
 front.scale(1.06);
 // copy from current image
 front.image(this.g, -HSIZE, -HSIZE, SIZE + 1, SIZE + 1);
 // draw something new on screen
 front.fill(r, g, b);
 front.noStroke();
 front.rectMode(CENTER);
 front.ellipse(x, y, 5, 5);
 front.endDraw();
 
 // copy image to screen
 image(front, 0, 0);
}


the colours fade too quickly. i am not sure why.
Re: programming a color mixer diagram
Reply #9 - Jul 8th, 2009, 3:33pm
 
the effects mentioned in the URL are easily done with parts of my programm code...
Re: programming a color mixer diagram
Reply #10 - Jul 9th, 2009, 3:30pm
 
Cedric wrote on Jul 8th, 2009, 3:33pm:
the effects mentioned in the URL are easily done with parts of my programm code...

thanks for that code! works like a charm Smiley
Page Index Toggle Pages: 1