예제 #1
0
/*
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();
}
예제 #2
0
static void FillRoundedRect (double x, double y, double width, double height,
                             double radius, double fill, string color)
{
    SetPenColor(color);
    StartFilledRegion(fill);
    DrawRoundedRect(x,y,width, height, radius);
    EndFilledRegion();
}
예제 #3
0
static void FillBox(double x, double y, double width, double height,
                    double fill, string color)
{
    SetPenColor(color);
    StartFilledRegion(fill);
    DrawBox(x, y, width, height);
    EndFilledRegion();
}
예제 #4
0
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);
}
예제 #5
0
파일: graphics.cpp 프로젝트: ej2xu/cs106b
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);
}
예제 #6
0
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");
}
예제 #7
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);
}
예제 #8
0
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);
	}
}
예제 #9
0
/* 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);
	}
}
예제 #10
0
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);
}
예제 #11
0
void DrawCell(cell c, string color)
{
	double inset = gWallLength / 5;
	double startx = GetMazeLowerLeftX() + c.col * gWallLength + inset;
	double starty = GetMazeLowerLeftY() + c.row * gWallLength + inset;
	SetPenColor(color);
	MovePen(startx, starty);
	StartFilledRegion(0.9);
	double insetWallLength = gWallLength - 2 * inset;
	DrawLine(insetWallLength, 0);
	DrawLine(0, insetWallLength);
	DrawLine(-insetWallLength, 0);
	DrawLine(0, -insetWallLength);
	EndFilledRegion();
}
예제 #12
0
void DrawScore(int MissilesLeft,int ShipsLeft,int hit,int total)
{
	MovePen(16.5*LG,GetWindowHeight());
	StartFilledRegion(1);
	SetPenColor("White");
	DrawLine(0,-10*LG);
	DrawLine(7*LG,0);
	DrawLine(0,10*LG);
	DrawLine(-7*LG,0);
	EndFilledRegion();
	SetPenColor("Black");
	MovePen(17*LG,GetWindowHeight()-4*LG);
	DrawTextString("Missiles left: ");
	DrawTextString(IntegerToString(MissilesLeft));
	MovePen(17*LG,GetWindowHeight()-5.5*LG);
	DrawTextString("Ships to sink: ");
	DrawTextString(IntegerToString(ShipsLeft));
	MovePen(17*LG,GetWindowHeight()-7*LG);
	DrawTextString("Hit rate: ");
	DrawTextString(IntegerToString(percent(hit,total)));
	DrawTextString("%");
}
예제 #13
0
void FillBox(double x, double y, double width, double height) {
	StartFilledRegion(1.0);
	DrawBox(x, y, width, height);
	EndFilledRegion();
}