Example #1
0
Maze::Maze(string filename, GWindow & gw) {
   gp = &gw;
   readMazeFile(filename);
   x0 = (gw.getWidth() - cols * SQUARE_SIZE) / 2;
   y0 = (gw.getHeight() - rows * SQUARE_SIZE) / 2;
   drawMaze();
}
Example #2
0
int main() {
    GWindow gw (1400, 900);

    //the x and y coordinate of the bottom center of the canvas
    double px = gw.getWidth() / 2;
    double py = gw.getHeight();

    //create the point with coordinates in the bottom center of the canvas
    GPoint pt(px,py);
    pt = drawFractalTree (gw, pt, SIZE, +90, ORDER);
    return 0;
}
Example #3
0
//GWindow elements
void update(Grid<int> & board, GWindow & gw, bool loading, double & loadX) {
    //printBoard(board);                                    //NOTE: *****UNCHECK THIS TO SEE THE TEXT BASED VERSION *******
    gw.clear();
    GRect *background = new GRect(gw.getWidth(), gw.getHeight());
    background -> setFillColor("#0000CC");
    background -> setFilled(true);
    gw.add(background, 0, 0);
     
    if(loading) {
        GRect *loading = new GRect(LOAD_WIDTH, LOAD_HEIGHT);
        loading -> setFillColor("#FFCC66");
        loading -> setFilled(true);
        loading -> setColor("#FFCC66");
        gw.add(loading, loadX, 0);
        loadX += 20;
        if(loadX > gw.getWidth()) {
            loadX = -LOAD_WIDTH;
        }
    }
    double spacer = gw.getWidth()/29;
    double x = 0;
    for(int i = 0; i < 7; i++) {
        double y = 0;
        x += spacer;
        for(int j = 0; j < 6; j++) {
            y += spacer;
            string c = "lightGray";
            if(board[j][i] == 1) {
                if(loading) {
                    c = "#990000";
                } else {
                    c = "#C80000";
                }
            } else if (board[j][i] == 2) {
                if(loading) {
                    c = "#000033";
                } else {
                    c = "#660066";
                }
            } else if (board[j][i] == 3) {
                if(loading) {
                    c = "#996633";
                /*} else {
                    c = "#660066";*/
                }
            }
            gw.add(circle(c, spacer), x + i*spacer*3, y + j*spacer*3);
        }
    }
}
Example #4
0
/*
 * Display ChessBoard in graphics window
 */
void draw_ChessBoard(Grid<bool> &ChessBoard, GWindow &gw)
{
    int row = ChessBoard.numRows();
    int col = ChessBoard.numCols();
    double width = gw.getWidth();
    double height = gw.getHeight();
    double cell_width = width/col;
    double cell_height = height/row;

    for(int i = 0; i < row; i++)
    {
        gw.drawLine(0, i*cell_height, width, i*cell_height);
        gw.drawLine(i*cell_width, 0, i*cell_width, height);
    }

}
pair<double, double> drawCoordinateSystem(GWindow &graphicsWindow, int scale) {
    pair<double, double> result;
    result.first = graphicsWindow.getWidth() / 2;
    result.second = graphicsWindow.getHeight() / 2;
    graphicsWindow.drawLine(result.first, 0, result.first, result.second * 2);
    graphicsWindow.drawLine(0, result.second, result.first * 2, result.second);
    for (int x = -result.first / scale + 1; x <= result.first / scale - 1; x++)
        graphicsWindow.drawLine(result.first + x * scale, result.second - 5,
                                result.first + x * scale, result.second + 5);
    for (int y = -result.second / scale + 1; y <= result.second / scale - 1; y++)
        graphicsWindow.drawLine(result.first - 5, result.second + y * scale,
                                result.first + 5, result.second + y * scale);
    GLabel* xMark = new GLabel("x", result.first * 2 - 20, result.second + 15);
    graphicsWindow.add(xMark);
    GLabel* yMark = new GLabel("y", result.first + 10, 20);
    graphicsWindow.add(yMark);
    return result;
}
Example #6
0
bool isPointInWindow(GWindow & gw, double coordX, double coordY){
    if((coordX >= gw.getWidth()) || (coordX <= 0) || (coordY >= gw.getHeight()) || (coordY <= 0)){
        return false;
    }
    return true;
}
Example #7
0
static void drawTree(GWindow& window, int order) {
    GPoint trunkBase(window.getWidth()/2, window.getHeight());
    // GPoint trunkEnd(window.getWidth()/2, window.getHeight() - kTrunkLength);
    drawTree(window, order, trunkBase, kTrunkStartAngle, kTrunkLength);
}