Changing line colors randomly.
Hello all, I wrote a code that draws a line for every nth degree. I need to know how to create another loop that will change the color of every line. I have researched RNG and things of that nature, but nothing is working for me. Please help or give me tips if you can; below is my code.
int x = shape->width;
int y = shape->height;
int m = 0;
int l = 2;
int q = 200;
int z = shape->width / l;
int a = shape->height / l;
int b = 10;
int f = -255;
int g = 255;
int w = 450;
int v = 36;
int h = 100;
int p = l++;
int r = 10;
int s = r++;
int t = 30;
int u = t++;
int c = 150;
cvRectangle(shape,cvPoint(x,m),cvPoint(m,y),CV_RGB(m,g,m),f,g);
//Drawing a Circle
cvCircle(shape,cvPoint(z,a),q, CV_RGB(m,m,g),f);
// for loop execution
for(int o = c; o < 511; o+=v){
for(int n = c; n < 467; n+=v){
cvLine(shape, cvPoint(z,a), cvPoint(o,n), CV_RGB(p,r,u),1,1);
}
}
cvCircle(shape,cvPoint(z,a),b,CV_RGB(m,g,m),f);
cvCircle(shape,cvPoint(z,a),q, CV_RGB(g,m,m),h,g);
//Showing the image
cvShowImage("Shapes",shape);
//Escape Sequence
cvWaitKey(0);
//CleanUp
cvReleaseImage(&shape);
cvDestroyAllWindows();
}
just please stop using the arcane c-api. that's not allowed for noobs !
also: RNG r(getTickCount()); int randomNumber=r.uniform(0,256);
I do not see the random number generation in code. Also, it may be a good idea to move to the C++ interface.