How can I draw a line with a variable of width?

Posted by user1729944 on Stack Overflow See other posts from Stack Overflow or by user1729944
Published on 2012-10-08T20:49:52Z Indexed on 2012/10/08 21:37 UTC
Read the original article Hit count: 164

Filed under:
|
|
#include <iostream>
#include <cmath>
#include "graph1.h"

using namespace std;

int main()
{
    int diameter = 0;
    int height = 0;
    double rate = 0;
    char repeat = 'y';
    int obj_num = 0;

    displayGraphics();

    obj_num = drawRect(0,0,50,400);
    setColor(obj_num,200,200,200);

    obj_num = drawRect(0,400,640,79);
    setColor(obj_num,71,35,35);

    obj_num = drawLine(50,50,150,50,5);
    setColor(obj_num,80,80,80);

    displayBMP("faucet.bmp",150,12);

    do
    {
        do
        {
            cout << "Enter the diamater of the cylinder <in inches > 0 but <= 300: ";
            cin >> diameter;
        if((diameter<0) || (diameter>300))
        { 
            cout << "Incorrect diamater entered; value must be between 1 and 300" << endl;

        }
        }while((diameter<0) || (diameter>300));

        do
        {
            cout << "Enter the height of the cylinder <in inches > 0 but <= 325: ";
            cin >> height;
        if((height<0) || (height>325))
        {
            cout << "Incorrect height entered; value must be between 1 and 325" << endl;
        }

        }while((height<0) || (height>325));

        do
        {
            cout << "Enter the facet water's rate: <gallons/minute> ";
            cin >> rate;
        if((rate<0) || (rate>100))
        { 
            cout << "Incorrect rate entered; value must be between 1 and 100" << endl;

        }
        }while((rate<0) || (rate>100));


//I need to draw the lines here. The graphics window has a faucet that is supposed to fill 
//up a cylinder made out of 3 lines. I don't know how to make the lines vary from the users 
//input since lines are hard coded with points and all i am receiving is the width for the 
//bottom line and the height for the left and right lines. 

      cout << "Repeat program? (y/n): ";
      cin >> repeat;

      clearGraphics();

    }while ( (repeat == 'y') || (repeat == 'Y') );
    return 0;
}

Here is a screenshot for reference: screenshot

© Stack Overflow or respective owner

Related posts about c++

Related posts about variables