/**
 * Initializes window with a grid of bricks.
 */
void initBricks(GWindow window)
{
    // somewhere else ask user for number of blocks per row with slider perhaps? then calcualte even spaces
    for (int row = 0; row < ROWS; row++)
    {
        for(int column = 0; column < COLS; column++)
        {
            // location of individual bricks
            GRect(brick)= newGRect(SPACE / 2 + column * WIDTH / COLS, 
            (row + 2) * (HEIGHT / (ROWS + SPACE)) / ROWS,
            
            // size of bricks 
            WIDTH / COLS - SPACE, (HEIGHT / (ROWS + SPACE)) / ROWS - SPACE);
            
            // color bricks by row 
            switch (row % 3)
            {
                case 0:
                    setColor(brick, "GREEN");
                    setFilled(brick, true);
                    break;
                case 1:
                    setColor(brick, "GRAY");
                    setFilled(brick, true);
                    break;
                case 2:
                    setColor(brick, "YELLOW");
                    setFilled(brick, true);
                    break;
            }
            add(window, brick);
        }
    }
}
Exemple #2
0
/**
 * Initializes window with a grid of bricks.
 */
void initBricks(GWindow window)
{
int x=0;
int y=40;

    for(int e = 0; e<ROWS; e++) {
    x=2;
        for(int i = 0; i<COLS;i++) {
         GRect bricks = newGRect(x,y,35,10);
        
            if(e==0) {
                setColor(bricks,"RED");
                setFilled(bricks,true);
            } if (e==1) {
                setColor(bricks,"FACC2E");
               setFilled(bricks,true);
            }  if (e==2) {
                setColor(bricks,"CE00F7");
              setFilled(bricks,true);
            }  if (e==3) {
                setColor(bricks,"BLUE");
                setFilled(bricks,true);
            } if (e==4) {
                setColor(bricks,"00DBF7");
                setFilled(bricks,true);
            }
          
              add(window,bricks);
              x = x+40;
   
        }
            y=y+13;
    }
}
void GArc::setFillColor(const std::string& color) {
    fillColor = color;
    if (fillColor == "") {
        if (isFilled()) {
            setFilled(false);
        }
    } else {
        fillColor = convertRGBToColor(convertColorToRGB(color));
        if (!isFilled()) {
            setFilled(true);
        }
    }
    stanfordcpplib::getPlatform()->gobject_setFillColor(this, fillColor);
}
Exemple #4
0
/**
 * Initializes window with a grid of bricks.
 */
void initBricks(GWindow window)
{
    // create bricks
    
    //intialize column spacing
    double y = 10;
    
    //set colors
    string color[] = {"RED", "ORANGE", "YELLOW", "GREEN", "BLUE"};
    
    //create brick table
    for(int n = 0; n < ROWS; n ++)
      {
      double x = 2;
      for(int i = 0; i < COLS; i++)
        {
        GRect brick = newGRect(x, y, 35, 10);
        setFilled(brick, true);
        setColor(brick, color[n]);
        add(window, brick);
        x = x + 40;
        }
        y = y + 20;
      
      }
}
/**
 * Initializes window with a grid of bricks.
 */
void initBricks(GWindow window)
{
    char *color[5] =   { "RED", "ORANGE", "YELLOW",  "GREEN", "CYAN"}; 
    
    double space = 4; // space in between bricks
    double x ; // vertical space before first brick
    double y = 50; //horizontal space before brick
    
    double brickWidth = 35;
    double brickHeight = 10;
    double w = getWidth(window);
    
    for (int r = 0 ; r < ROWS ; r++)
    {
        x = 2;
        for (int c = 0 ; c < COLS ; c++)
        {
            GRect brick = newGRect(x, y,brickWidth,brickHeight);
            setFilled(brick, true);
            setColor(brick,color[r]);
            add(window,brick);
            
            x = x + brickWidth + space;
        }
        
        y = y + brickHeight + space;
    }  
}
Exemple #6
0
/**
 * Instantiates paddle in bottom-middle of window.
 */
GRect initPaddle(GWindow window)
{
    GRect rectangle = newGRect(WIDTH / 2 - PADDLEWIDTH / 2, HEIGHT - 30, PADDLEWIDTH, PADDLEHEIGHT);
    setColor(rectangle, "BLACK");
    setFilled(rectangle, true);
    return rectangle;
}
Exemple #7
0
/**
 * Instantiates ball in center of window.  Returns ball.
 */
GOval initBall(GWindow window)
{
    GOval ball = newGOval(0 + WIDTH / 2, 0 + HEIGHT / 2, RADIUS, RADIUS);
    setColor(ball, "BLACK");
    setFilled(ball, true);
    return ball;
}
Exemple #8
0
int main() {
   GWindow gw;
   GArc pacman;
   int angle, sign;
   double limit;

   gw = newGWindow(600, 400);
   pacman = newGArc(0, (getHeight(gw) - PACMAN_SIZE) / 2,
                    PACMAN_SIZE, PACMAN_SIZE, 45, 270);
   setFilled(pacman, true);
   setFillColor(pacman, "YELLOW");
   add(gw, pacman);
   waitForClick();
   angle = 45;
   sign = -1;
   limit = getWidth(gw) - PACMAN_SIZE;
   while (getX(pacman) < limit) {
      move(pacman, DELTA_X, 0);
      angle += sign * DELTA_THETA;
      if (angle == 0 || angle == 45) sign = -sign;
      setStartAngle(pacman, angle);
      setSweepAngle(pacman, 360 - 2 * angle);
      pause(PAUSE_TIME);
   }

   return 0;
}
Exemple #9
0
/**
 * Initializes window with a grid of bricks.
 */
void initBricks(GWindow window)
{
    int BricksWidth = (WIDTH / COLS) - 6;
    int BricksHeight = 10;
    for(int i = 0; i <= COLS - 1; i++)
    {
        for(int j = 0; j <= ROWS - 1 ; j++)
        {
            GRect bricks = newGRect(i * (WIDTH / COLS) + 2, j * (BricksHeight + 6) + 50 , BricksWidth, BricksHeight);
            if (j == 0)
            {
                setColor(bricks, "GREEN");
            }
            if (j == 1)
            {
                setColor(bricks, "BLUE");
            }
            if (j == 2)
            {
                setColor(bricks, "RED");
            }
            if (j == 3)
            {
                setColor(bricks, "YELLOW");
            }
            if (j == 4)
            {
                setColor(bricks, "CYAN");
            }
            setFilled(bricks, true);
            add(window, bricks);
        }
    }
}
Exemple #10
0
/**
 * Initializes window with a grid of bricks.
 */
void initBricks(GWindow window)
{
    string color[5] = {"BLACK", "RED", "ORANGE", "GREEN", "CYAN"};
    // stay consistant with paddle bottom offset, paddle and bricks offsets are symmetrical
    int brick_top_offset = HEIGHT * 1/10 - BRICK_HEIGHT;
    // set brick width to scale with window width
    int brick_width = WIDTH * 1/11;
    
    for (int i = 0; i < 5; i++)
    {
        // update brick column offset on outer loop
        int y = brick_top_offset + (BRICK_SPACING * i) + (BRICK_HEIGHT * i);
        for (int j = 0; j < 10; j++)
        {
            // update brick row
            int x = (BRICK_SPACING * j + 1) + (j * brick_width);
            // instantiate a new brick
            GRect brick = newGRect(x, y, brick_width, BRICK_HEIGHT);
            // set different brick colors for each row and add brick to canvas
            setFilled(brick, true);
            setColor(brick, color[i]);
            add(window, brick);
        }
    }
}
Exemple #11
0
/**
 * Initializes window with a grid of bricks.
 */
void initBricks(GWindow window)
{
  int xStart = 0;       // x coord  of brick
  int yStart = 0;       // y coord of brick
  int xSpacing = 2;     // spacing between bricks on horizontal
  int ySpacing = 2;     // spacing between bricks on vertical
  
  // Define dimensions of brick
  int brickWidth = WIDTH / (COLS) - xSpacing; 
  int brickHeight = 10;
  
  // Define different color for each row #rrggbb
  string color = "#" + itoa(rand()%1000000);
  
  // Build the matrix of bricks 
  for(int r = 0; r < ROWS; r++) {
    for(int c = 0; c < COLS; c++) {
      GRect brick = newGRect(xStart, yStart, brickWidth, brickHeight);
      setFilled(brick, true);
      setColor(brick, color);
      add(window, brick);
      xStart += (brickWidth + xSpacing);
    }
    yStart += (brickHeight + ySpacing);
    xStart = 0;
    color = "#" + itoa(rand()%1000000);
  }
}
Exemple #12
0
//------------------------------------------------------------------------------
// setSlotFilled() - is our segment filled or not?
//------------------------------------------------------------------------------
bool DialArcSegment::setSlotFilled(const base::Number* const x)
{
    if (x != nullptr) {
        return setFilled(x->getBoolean());
    }
    return false;
}
Exemple #13
0
//Initializes window with a grid of bricks.
void initBricks(GWindow window)
{
    int xDistance = 2;
    int yDistance = 30;
    string rowColors[5];
    rowColors[0] = "RED";
    rowColors[1] = "MAGENTA";
    rowColors[2] = "ORANGE";
    rowColors[3] = "YELLOW";
    rowColors[4] = "GREEN";

    for(int row = 0; row < ROWS; row++)
    {
        for(int col = 0; col < COLS; col++, xDistance += 40)
        {
            GRect brick = newGRect(xDistance, yDistance, WIDTH/11, 10);
            setFilled(brick, true);
            setColor(brick, rowColors[row]);
            add(window, brick);
        }

        xDistance = 2;
        yDistance += 20;
    }
}
Exemple #14
0
/**
 * Initializes window with a grid of bricks.
 */
void initBricks(GWindow window)
{
    
    double brickL =35 , brickH =10, space =4;
    double x = 2; // initial cordinate
    double y = SPACE; // final cordinate
    
    //char *color[5] ={"BLUE", "RED", "GREEN", "ORANGE", "YELLOW"};
    char *color[5] =   { "RED", "ORANGE", "YELLOW",  "GREEN", "CYAN"}; 
        
    for(int row = 0; row < ROWS; row++)
    {
        x = 2;      
        for(int col = 0 ; col < COLS; col++)
        {
            // start (x,y) end(x,y)
            GRect brick = newGRect( x , y, brickL, brickH);
            setFilled(brick, true);
            setColor(brick,color[row]);
            add(window,brick);
            x = x + brickL +space;
        }
        
        y = y + brickH + space;
    }
}
Exemple #15
0
/**
 * Initializes window with a grid of bricks.
 */
void initBricks(GWindow window)
{
    for(int i = 0; i < ROWS; i++)
    {
        for(int x = 0; x < COLS; x++)
        {
            GRect brick = newGRect(2 + (BL+6) * x, 50 + (BH+2) * i, BL, BH);
            if (i == 0)
            {
            setColor(brick, "RED");
            }
            else if (i == 1)
            {
            setColor(brick, "YELLOW");
            }
            else if (i == 2)
            {
            setColor(brick, "ORANGE");
            }
            else if (i == 3)
            {
            setColor(brick, "GREEN");
            }
            else if (i == 4)
            {
            setColor(brick, "BLUE");
            }
            setFilled(brick, true);
            add(window, brick);
        }
    }
}
/**
 * Initializes window with a grid of bricks.
 */
void initBricks(GWindow window)
{
    // TODO
	string color;
    for (int c = 0; c < COLS; c++) 
    {
        for (int r = 0; r < ROWS; r++)
        {
            GRect rect = newGRect( 40 * c + 3, 15 * r + 50, 34, 9);
            setFilled(rect, true);
			switch (r) {
            case 0:
                color = "RED";
                break;
            case 1:
                color = "ORANGE";
                break;
			case 2:
                color = "YELLOW";
                break;
			case 3:
                color = "CYAN";
                break;
            default:
                color = "GREEN";
            }
            setColor(rect, color);
            add(window, rect);
        }    
    }
    
}
Exemple #17
0
/**
 * Instantiate bricks and also return an array with Y coordinates for bricks.
 * This is probably not an elegant way to do it, but I wanted to avoid duplicate
 * code, running the same loop in a different function etc..
 */
int *initBricks(GWindow window)
{
    // array to store brick Y offsets
    int *bricks_offset = malloc(5 * sizeof(int));
    // drawing purpose array
    string color[5] = {"BLACK", "RED", "ORANGE", "GREEN", "CYAN"};
    // stay consistant with paddle bottom offset, paddle and bricks offsets are symmetrical
    int brick_top_offset = HEIGHT * 1/10. - BRICK_HEIGHT;
    
    for (int i = 0; i < 5; i++)
    {
        // update brick column offset on outer loop
        int y = brick_top_offset + (BRICK_SPACING * i) + (BRICK_HEIGHT * i);
        // store the offset
        bricks_offset[i] = y;
        for (int j = 0; j < 10; j++)
        {
            // update brick row
            int x = (BRICK_SPACING * j + 1) + (j * BRICK_WIDTH);
            // instantiate a new brick
            GRect brick = newGRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
            // set different brick colors for each row and add brick to canvas
            setFilled(brick, true);
            setColor(brick, color[i]);
            add(window, brick);
        }
    }
    
    return bricks_offset;
}
/**
 * Initializes window with a grid of bricks.
 */
void initBricks(GWindow window)
{
    // initiate bricks using five loops for each line of different colour.
    int i,j,posX=1,posY=50;
    for(i=0;i<ROWS;i++)    {
        for(j=0;j<COLS;j++)   {
        GRect brick = newGRect(posX+(j*40) ,posY+(i*15), BWIDTH, BHEIGHT);
       setFilled(brick, true);
        if(i==0){   //these if conditions choose colour for each line of bricks.
            setColor(brick, "RED");
        }
        if(i==1){
            setColor(brick, "BLUE");
        }
        if(i==2){
            setColor(brick, "CYAN");
        }
        if(i==3){
            setColor(brick, "YELLOW");
        }
        if(i==4){
            setColor(brick, "MAGENTA");
        }
        add(window, brick);
        }
    }
}
Exemple #19
0
/**
 * Instantiates paddle in bottom-middle of window.
 */
GRect initPaddle(GWindow window)
{
    GRect paddle = newGRect(175, 500, 50, 10);
    setColor (paddle, "MAGENTA");
    setFilled (paddle, true);
    add (window, paddle);
    return paddle;
}
Exemple #20
0
/**
 * Instantiates paddle in bottom-middle of window.
 */
GRect initPaddle(GWindow window)
{
    GRect paddle = newGRect(185, 500, 50, 10);
    setFilled(paddle, true);
    setFillColor(paddle, "BLACK");
    add(window, paddle);
    return paddle;
}
Exemple #21
0
/**
 * Instantiates ball in center of window.  Returns ball.
 */
GOval initBall(GWindow window)
{
    GOval ball = newGOval(200 - RADIUS, 300 - RADIUS, 2*RADIUS, 2*RADIUS);
    setFilled(ball, true);
    setFillColor(ball, "RED");
    add(window, ball);
    return ball;
}
Exemple #22
0
Rectangle::Rectangle(float x, float y, 
					 float w, float h, bool fill):
					 width(w), height(h)
{
	setX(x);
	setY(y);
	setFilled(fill);
}
Exemple #23
0
/**
 * Instantiates paddle in bottom-middle of window.
 */
GRect initPaddle(GWindow window)
{
    GRect paddle = newGRect(160, 550, P_WIDTH, P_HEIGHT);
    setColor(paddle, "BLACK");
    setFilled(paddle, true);
    add(window, paddle);
    return paddle;
}
Exemple #24
0
/**
 * Instantiates paddle in bottom-middle of window.
 */
GRect initPaddle(GWindow window)
{
    GRect paddle = newGRect((WIDTH / 2) - (PADDLE_WIDTH / 2), HEIGHT - (HEIGHT / 7), PADDLE_WIDTH, PADDLE_HEIGHT);
    setColor(paddle, "BLACK");
    setFilled(paddle, true);
    add(window, paddle);
    return paddle;
}
/**
 * Instantiates ball in center of window.  Returns ball.
 */
GOval initBall(GWindow window)
{
    GOval ball = newGOval(200 - 10, 200, 20, 20); 
    setColor(ball, "BLACK");
    setFilled(ball, true);
    add(window, ball);
    return ball;
}
Exemple #26
0
/**
 * Instantiates paddle in bottom-middle of window.
 */
GRect initPaddle(GWindow window)
{
    GRect paddle = newGRect(190, 400, 50, 10);
    setFilled(paddle, true);
    setColor(paddle, "7FFFD4"); //Aquamarine
    add(window, paddle);
    return paddle;
}
Exemple #27
0
Triangle::Triangle(float x, float y, float z, float size, int farbindex):size(size)
{
	setX(x);
	setY(y);
	setZ(z);
	setFilled(true);
	setActiveColorByIndex(farbindex);
}
Exemple #28
0
/**
 * Instantiates ball in center of window.  Returns ball.
 */
GOval initBall(GWindow window)
{
    GOval ball = newGOval((WIDTH - RADIUS)/2, (HEIGHT - RADIUS)/2, RADIUS, RADIUS);
    setColor(ball, "BLUE");
    setFilled(ball, true);
    add(window, ball);
    return ball;
}
Exemple #29
0
/**
 * Instantiates ball in center of window.  Returns ball.
 */
GOval initBall(GWindow window)
{
    GOval ball = newGOval(190, 250, RADIUS, RADIUS);
    setFilled(ball, true);
    setColor(ball, "FF00FF"); // Magenta color
    add(window, ball);
    return ball;
}
Exemple #30
0
/**
 * Instantiates ball in center of window.  Returns ball.
 */
GOval initBall(GWindow window)
{
    GOval ball = newGOval((WIDTH / 2) - RADIUS, (HEIGHT / 2) + RADIUS, RADIUS * 2, RADIUS * 2);
    setColor(ball, "BLACK");
    setFilled(ball, true);
    add(window, ball);
    return ball;
}