本文整理汇总了C++中setFilled函数的典型用法代码示例。如果您正苦于以下问题:C++ setFilled函数的具体用法?C++ setFilled怎么用?C++ setFilled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setFilled函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initBricks
/**
* 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);
}
}
}
示例2: initBricks
/**
* 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;
}
}
示例3: setFilled
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);
}
示例4: initBricks
/**
* 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;
}
}
示例5: initBricks
/**
* 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;
}
}
开发者ID:FarahAgha,项目名称:CS50,代码行数:31,代码来源:breakout+(Rahul’s+MacBook+Pro's+conflicted+copy+2014-07-25).c
示例6: initPaddle
/**
* 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;
}
示例7: initBall
/**
* 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;
}
示例8: main
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;
}
示例9: initBricks
/**
* 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);
}
}
}
示例10: initBricks
/**
* 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);
}
}
}
示例11: initBricks
/**
* 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);
}
}
示例12: initBricks
//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;
}
}
示例13: initBricks
/**
* 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;
}
}
示例14: initBricks
/**
* 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);
}
}
}
示例15: initBricks
/**
* 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);
}
}
}