void DrawStartingBoard(string choice) { int i; string letter[10]={"A","B","C","D","E","F","G","H","I","J"}; if( StringEqual(choice,"y") ) { PlayNamedSound("Fanfare"); } for (i=0;i<=NUM_COLS;i++) { if (i!=NUM_COLS) { MovePen((i+1.3)*LG,GetWindowHeight()-LG); DrawTextString(IntegerToString(i)); } MovePen((i+1)*LG,GetWindowHeight()-1.3*LG); DrawLine(0,(-NUM_ROWS)*LG); } for (i=0;i<=NUM_ROWS;i++) { if (i!=NUM_ROWS) { MovePen(LG/4,GetWindowHeight()-(11.1-i)*LG); DrawTextString(letter[9-i]); } MovePen(LG,GetWindowHeight()-(11.3-i)*LG); DrawLine((NUM_COLS)*LG,0); } }
void MarkMiss(coord location) { MovePen( (location.col+1)*LG,GetWindowHeight()-(location.row+1.3)*LG ); DrawLine(LG,-LG); MovePen( (location.col+2)*LG,GetWindowHeight()-(location.row+1.3)*LG ); DrawLine(-LG,-LG); }
static void DrawWallUsingColor(wall w, string color) { double startx = GetMazeLowerLeftX() + w.one.col * gWallLength; double starty = GetMazeLowerLeftY() + w.one.row * gWallLength; double wallLength = gWallLength; if (color == kMazeInvisibleColor) { wallLength *= 0.6; } SetPenColor(color); if (w.one.row == w.two.row) { startx += gWallLength; if (color == kMazeInvisibleColor) starty += gWallLength / 5; MovePen(startx, starty); DrawLine(0, wallLength); } else { starty += gWallLength; if (color == kMazeInvisibleColor) startx += gWallLength / 5; MovePen(startx, starty); DrawLine(wallLength, 0); } }
void confirmComplete(double x1, double y1, double x2, double y2)//确认完成按钮函数 { MovePen(x1,y1); DrawLine(x2-x1,0); DrawLine(0,y2-y1); DrawLine(x1-x2,0); DrawLine(0,y1-y2); double distance1; double distance2; double X,Y; SetPenColor(RED); distance1=(x2-x1-GetStringWidth("输入完成"))/2; distance2=(y1-y2-GetStringWidth("输"))/2; MovePen(x1+distance1,y1-distance2); DrawString("输入完成"); SetPenColor(BLACK); while(1) { while(!(WaitForEvent()==KEYDOWN)){} if(GetStruckKey() == VK_LBUTTON) { X = GetMouseX(); Y = GetMouseY(); if((X >= x1 && X <= x2) && (Y >= y2 && Y <= y1))//鼠标点击在所规定的范围内 { EatEgg();//吃掉完成键和信息输入框的蛋 break; } } } }
void DrawHighlight(buttonT & button) { MovePen(button.x + 2, button.y + button.height - 2); DrawLine(0, 4 - button.height); MovePen(button.x + 2, button.y + button.height - 2); DrawLine(button.width - 4, 0); MovePen(button.x + 3, button.y + button.height - 3); DrawLine(0, 0); }
/* * Function: DrawPlayerLabel * ------------------------- * Labels player word list with specified name and draws a line underneath the label. * It also resets the player's score and word list count back to zero. */ static void DrawPlayerLabel(playerT player, string name) { SetPenColor("Label Color"); MovePen(gState.scoreBox[player].x, gState.scoreBox[player].y); DrawLine(gState.scoreBox[player].w , 0); SetFont(SCORE_FONT); SetPointSize(SCORE_FONT_SIZE); MovePen(gState.scoreBox[player].x, gState.scoreBox[player].y + GetFontDescent()); DrawTextString(name); gState.scores[player] = gState.numWords[player] = 0; }
/* Function: DrawFilledCircleWithLabel * Usage: DrawFilledCircleWithLabel(center, .25, "Green", "You are here"); * ----------------------------------------------------------------------- * Uses facilities from extgraph to draw a circle filled with * color specified. The circle is centered at the given coord has the * specified radius. A label is drawn to the right of the circle. * If you don't want a label, pass the empty string. */ void DrawFilledCircleWithLabel(coordT center, double radius, string color, string label) { MovePen(center.x + radius, center.y); SetPenColor(color); StartFilledRegion(1.0); DrawArc(radius, 0, 360); EndFilledRegion(); MovePen(center.x + radius, center.y); SetFont("Helvetica"); SetPointSize(FONT_SIZE); DrawTextString(label); }
void DrawPathfinderNode(pointT center, string color, string label) { MovePen(center.x + NODE_RADIUS, center.y); SetPenColor(color); StartFilledRegion(1.0); DrawArc(NODE_RADIUS, 0, 360); EndFilledRegion(); if (!label.empty()) { MovePen(center.x + NODE_RADIUS + 2, center.y + 0.4 * GetFontAscent()); SetFont("Helvetica"); SetPointSize(FONT_SIZE); DrawTextString(label); } }
void Maze::drawMark(pointT p, string color) { if (!pointInBounds(p)) Error("Point is not in bounds for maze"); if (!configured) configureGraphics(); double margin = cellSize*.3; double length = cellSize - 2*margin; SetPenColor(color); MovePen(originX + p.col*cellSize + margin, originY + p.row*cellSize + margin); DrawLine(length, length); MovePen(originX + p.col*cellSize + margin, originY + p.row*cellSize + cellSize - margin); DrawLine(length, -length); UpdateDisplay(); }
void DrawPrintfMessage(string message) { MovePen( LG , GetWindowHeight()-11.5*LG ); SetPenColor("White"); StartFilledRegion(1); DrawLine(0,-2*LG); DrawLine(23*LG,0); DrawLine(0,2*LG); DrawLine(-23*LG,0); EndFilledRegion(); SetPenColor("Black"); MovePen( 2*LG , GetWindowHeight()-12.3*LG ); DrawTextString(message); }
/* Function: DrawFilledCircleWithLabel * Usage: DrawFilledCircleWithLabel(center, "Green", "You are here"); * ------------------------------------------------------------------- * Uses facilities from extgraph to draw a circle filled with * color specified. The circle is centered at the given coord has the * specified radius. A label is drawn to the right of the circle. * You can leave off the last argument if no label is desired. */ void DrawFilledCircleWithLabel(coordT center, string color, string label) { MovePen(center.x + CircleRadius, center.y); SetPenColor(color); StartFilledRegion(1.0); DrawArc(CircleRadius, 0, 360); EndFilledRegion(); if (!label.empty()) { MovePen(center.x + CircleRadius, center.y); SetFont("Helvetica"); SetPointSize(LabelFontSize); DrawTextString(label); } }
/* * Function: GetTrianglePoints * Usage: GetTrianglePoints(tri) * ----------------------------------- * This function watches the user click three points on the Graphics Console. * The function notes the location of those points by loading the 'tri' array * with three pointT structs. * The function connects the dots to create a triangle on the screen. * Graphics should already be initialized. We assume working with triangles, * but the constant nPOINTS will let us see if this works for four points. */ void GetTrianglePoints(pointT tri[]) { int pt_ct = 0; while ( pt_ct < nPOINTS ) { //cout << "got to this point" << endl; WaitForMouseDown(); WaitForMouseUp(); tri[pt_ct].xp = GetMouseX(); tri[pt_ct].yp = GetMouseY(); if ( pt_ct == 0 ) { MovePen(tri[0].xp, tri[0].yp); } else { DrawLine( (tri[pt_ct].xp - tri[pt_ct - 1].xp ), (tri[pt_ct].yp - tri[pt_ct - 1].yp ) ); } UpdateDisplay(); pt_ct ++; } // Connect the third and first points of the triangle with lines DrawLine( (tri[0].xp - tri[nPOINTS - 1].xp ), (tri[0].yp - tri[nPOINTS - 1].yp ) ); UpdateDisplay(); }
void DrawInnerShade(buttonT & button) { MovePen(button.x + 2, button.y + 3); DrawLine(button.width - 6, 0); DrawLine(0, 1); DrawLine(1, 0); DrawLine(0, button.height - 6); }
void DrawOuterShade(buttonT & button) { MovePen(button.x + 2, button.y + 2); DrawLine(button.width - 5, 0); DrawLine(0, 1); DrawLine(1, 0); DrawLine(0, button.height - 5); }
void DrawBox(double x, double y, double width, double height) { MovePen(x, y); DrawLine(width, 0); DrawLine(0, height); DrawLine(-width, 0); DrawLine(0, -height); }
/* Function: DrawCircle Usage: DrawCircle(pt) ----------------------------------- Given a pointT point (pt), this function draws a circle of radius FILL_RADIUS and color FILL_COLOR around that point. */ void DrawCircle(pointT pt) { SetPenColor(FILL_COLOR); StartFilledRegion(PT_DENSITY); MovePen(pt.xp + FILL_RADIUS, pt.yp); DrawArc(FILL_RADIUS, 0, 360); EndFilledRegion(); }
void createTriangle(Point &v1, Point &v2, Point &v3) { int count = 0; while(count < 3) { WaitForMouseDown(); WaitForMouseUp(); double X = GetMouseX(); double Y = GetMouseY(); /* log points */ if (count == 0) { MovePen(X, Y); v1.X = X; v1.Y = Y; } else if (count == 1) { v2.X = X; v2.Y = Y; DrawLine(v2.X - v1.X, v2.Y - v1.Y); } else { v3.X = X; v3.Y = Y; DrawLine(v3.X - v2.X, v3.Y - v2.Y); // close triangle DrawLine(v1.X - v3.X, v1.Y - v3.Y); } count++; } }
void clean(int order) { const int sort[3]={2,7,12}; int i;/*counter*/ if(order==2) for(i=1;i<=4;i++) { MovePen(click[sort[2]+i].leftup_x,click[sort[2]+i].leftup_y); DrawBitmap(click[sort[2]+i].bitmap_B); } else for(i=1;i<=5;i++) { MovePen(click[sort[order]+i].leftup_x,click[sort[order]+i].leftup_y); DrawBitmap(click[sort[order]+i].bitmap_B); } }
/* * Function: DrawCenteredChar * -------------------------- * Used to draw the letters in the center of the cube. * Note that this function centers the char * both vertically and horizontally around the point specified. */ static void DrawCenteredChar(double centerX, double centerY, char ch) { string s(1, ch); SetFont(CUBE_FONT); SetPointSize(gState.cubeFontSize); MovePen(centerX - TextStringWidth(s)/2, centerY - GetFontAscent()/2); DrawTextString(s); }
void DrawButtonText(buttonT & button) { SetFont(BUTTON_FONT); SetStyle(BUTTON_STYLE); SetPointSize(BUTTON_POINT_SIZE); MovePen(button.x + (button.width - TextStringWidth(button.name)) / 2, button.y + (button.height + GetFontAscent()) / 2); DrawTextString(button.name); }
static void DrawCenteredCircle(double radius, double cx, double cy, string color = "Black", bool isSolid = true) { string oldColor = GetPenColor(); SetPenColor(color); MovePen(cx + radius, cy); if (isSolid) StartFilledRegion(1.0); DrawArc(radius, 0, 360); if (isSolid) EndFilledRegion(); SetPenColor(oldColor); }
static void DrawCenteredText(string text, double cx, double cy, string color) { double x = cx - TextStringWidth(text)/2; double y = cy - GetFontAscent()/2; MovePen(x, y); string oldColor = GetPenColor(); SetPenColor(color); DrawTextString(text); SetPenColor(oldColor); }
void DrawPathfinderMap(string mapFile) { SetPenColor("White"); FillBox(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); SetPenColor("Black"); if (mapFile != "") { MovePen(0, 0); DrawNamedPicture(mapFile); } }
/* * Function: DrawOneScore * ---------------------- * Draws the specified score for the player according to player enum. */ static void DrawOneScore(playerT playerNum, int value) { SetFont(SCORE_FONT); SetPointSize(SCORE_FONT_SIZE); SetPenColor("Label Color"); string str = IntegerToString(value); MovePen(gState.scoreBox[playerNum].x + gState.scoreBox[playerNum].w - TextStringWidth(str), gState.scoreBox[playerNum].y + GetFontDescent() + 0.03); // the 0.03 hack added Sept-2011 // Using SetEraseMode() to delete old score interfered with the line underneath DrawTextString(str); }
void DrawOutline(buttonT & button) { MovePen(button.x, button.y + button.height - 2); DrawLine(0, 5 - button.height); DrawLine(2, -2); DrawLine(button.width - 5, 0); DrawLine(2, 2); DrawLine(0, button.height - 5); DrawLine(-2, 2); DrawLine(5 - button.width, 0); DrawLine(-2, -2); }
static void DrawRoundedRect (double x, double y, double width, double height, double radius) { MovePen(x + radius, y); DrawLine(width -2*radius,0); // line across bottom DrawArc(radius,270,90); // arc on lower right corner DrawLine(0,height -2*radius); // line up right side DrawArc(radius,0,90); // arc on upper right corner DrawLine(-(width -2*radius), 0); // line across top DrawArc(radius,90,90); // arc on upper left corner DrawLine(0,-(height-2*radius)); // line down left side DrawArc(radius,180,90); // arc on lower left corner }
void iterate(Point v1, Point v2, Point v3, Point currentPoint) { if (MouseButtonIsDown()) ExitGraphics(); MovePen(currentPoint.X, currentPoint.Y); StartFilledRegion(1); DrawArc(CIRCLE_SIZE, 0, 360); EndFilledRegion(); Point nextRand = randPoint(v1, v2, v3); currentPoint.X = 0.5 * (currentPoint.X + nextRand.X); currentPoint.Y = 0.5 * (currentPoint.Y + nextRand.Y); UpdateDisplay(); iterate(v1, v2, v3, currentPoint); }
void MarkHit(coord location,string color,double density) { SetPenColor(color); MovePen( (location.col+1.5)*LG,GetWindowHeight()-(location.row+1.3)*LG ); StartFilledRegion(density); DrawLine(-LG/2,-LG/2); DrawLine(LG/2,-LG/2); DrawLine(LG/2,LG/2); DrawLine(-LG/2,LG/2); EndFilledRegion(); SetPenColor("Black"); }
void Maze::drawWallsForCell(pointT p) { MovePen(originX + p.col*cellSize, originY + p.row*cellSize); SetPenColor(cells(p.row, p.col).walls[South] ? "Black" : "White"); DrawLine(cellSize, 0); SetPenColor(cells(p.row, p.col).walls[East] ? "Black" : "White"); DrawLine(0, cellSize); SetPenColor(cells(p.row, p.col).walls[North] ? "Black" : "White"); DrawLine(-cellSize, 0); SetPenColor(cells(p.row, p.col).walls[West] ? "Black" : "White"); DrawLine(0, -cellSize); }
void DrawMazeBorder() { double llx = GetMazeLowerLeftX(); double lly = GetMazeLowerLeftY(); MovePen(llx, lly); DrawLine(0, kMazeDimension, kMazeVisibleColor); DrawLine(gWallLength, 0, kMazeInvisibleColor); DrawLine(kMazeDimension - gWallLength, 0, kMazeVisibleColor); DrawLine(0, -kMazeDimension, kMazeVisibleColor); DrawLine(- gWallLength, 0, kMazeInvisibleColor); DrawLine(- kMazeDimension + gWallLength, 0, kMazeVisibleColor); }