如何从控制台传递变量

时间:2017-04-25 03:40:53

标签: c++ graphics 2d transformation bgi

我正在编写C ++图形程序。我需要翻译,缩放和旋转这个菱形形状(以及其他形状)。我想编写一个函数来做到这一点,但我还没弄明白如何将x1,y1,x2,y2从鼠标输入(或键盘输入)传递给我想写的新转换函数。
我想在BGI屏幕上绘制一个形状,然后点击“翻译”。按钮,然后输入一些变量和形状变换 仅供参考,我使用BGI来制作图形。我用鼠标输入绘制了一些形状,有些带有键盘输入 这是我的代码:

void drawRhombus (int x1, int y1, int x2, int y2)
{
    int x3 = x2 + (x2 - x1);
    int y3 = y1;
    int x4 = x2;
    int y4 = y1 + (y1 - y2);

    lineBresenham(x1, y1, x2, y2);
    lineBresenham(x2, y2, x3, y3);
    lineBresenham(x3, y3, x4, y4);
    lineBresenham(x4, y4, x1, y1);
}

if (LOWORD(wParam) == 9) {  
                cout<<"Draw Rhombus"<<endl; 
                int x1, y1, x2, y2 = 0;             
                int count = 0;
                coordinateLines();
                while(1) 
                {
                    delay (0.0001);
                    if (ismouseclick(WM_LBUTTONDOWN))
                    {
                        getmouseclick(WM_LBUTTONDOWN, x1, y1);
                        cout<<"A("<<setXMachine2User(x1)<<","<<setYMachine2User(y1)<<")\n";
                        putpixel(x1,y1,color);
                        count++;
                    }
                    if (count == 1)
                    {
                        if (ismouseclick(WM_LBUTTONUP))
                        {
                            getmouseclick(WM_LBUTTONUP, x2, y2);                        
                            cout<<"B("<<setXMachine2User(x2)<<","<<setYMachine2User(y2)<<")\n";
                            drawRhombus(x1, y1, x2, y2);
                            cout<<"-------------------------------"<<endl;
                            count++;                    
                        }

                    }
                    if (count == 2)
                    {
                        count = 0;              
                    }   
                }           

            }

0 个答案:

没有答案