Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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();

}

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();

}

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();

}

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();

}