Array of colours

Hey all,

I need to set up an array of specific colours which I can cycle through depending on another value. I have tried:

ofColor colors[3];

colors[0] = ofColor(65,255,245);
colors[1] = ofColor(62,192,197);
colors[2] = ofColor(59,129,150);

as suggested here:

but I get a no matching function error

Please could someone suggest the best way to achieve this?

Many thanks! :slight_smile:


I will need to see the code you are using to change the colours that throw the “no matching function error”

Check out this link were I discuss a similar problem

Hope it helps!

  • rS


Thanks for the speedy reply but this *is* the code that throws the error, I haven’t even got as far as trying to change it :confused:

This is the error: error: no matching function for call to `ofColor::ofColor(int, int, int)’

I see, sorry I misunderstood, I did came a cross the same problem, but I dont have that project with me, as soon as I get home I will get back to you, hopefully some one else my reply by then.

Which version of OF are you using?


  • rS

Cool, thank you :slight_smile: I am using v6.1, if you could look at your code that would be awesome. In the mean time I’ll try to get around it another way. Once I have sorted this bit out your interpolation post will be very handy :wink:

For of_v0062

ofColor *colors;  
void testApp::setup(){  
	colors = new ofColor[3];  
	colors[0].r = 65;  
	colors[0].g = 255;  
	colors[0].b = 245;  
	colors[1].r = 62;  
	colors[1].g = 192;  
	colors[1].b = 197;  
	colors[2].r = 59;  
	colors[2].g = 129;  
	colors[2].b = 150;  
void testApp::draw()  
	for(int i = 0; i < 3; i++)  
		ofSetColor(colors[i].r, colors[i].g, colors[i].b);  
		ofRect(100 * i, 100, 100, 100);  

Perfect, thanks :slight_smile: