Graphics
Borland Turbo C++ was used.
![]()
Graph01 - Simple Screen Manipulation, Modes, and Colors
Graph02 - The Spaceship moves across space...
Graph03 - Timing Line Segment
Drawing
(Includes the first and last appearance of the figures
library)
Graph07 - Draw Three Cylinders
Take a Guess #1 -
( This SJU professor had "hands on" tests, where you'd
get a problem and whip up some code on the spot. If you could guess what
he was going to do and prepare some code you'd be ahead of the game. If I
remember correctly he did something way off base for this and all the code was for
naught.)
Skunked Again (It was a December final in a Graphics class. Decent odds he'd have us draw a Christmas Tree? At a catholic university? No brainer, right? Wrong. More coding for the sake of coding. I included it for EC and he told me to go fly a kite.)
![]()
// GHDR01.H - Lars Sorensen
// Class Decs for Text Graphics Objs
class ScreenDisps {
public:
ScreenDisps();
void DisplayInits();
void DisplayAscii();
void ShowShapes();
};
void MenuScreen(void);
void MakeBox(int wherex,int wherey,int size,int tcolor,int bcolor);
void MakeTri(int wherex,int wherey,int size,int tcolor,char X);
// TEXTGRPS.CPP - The Implementation
// of the Class Declared in GHDR01.H
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#include <dos.h>
#include "GHDR01.H"
ScreenDisps::ScreenDisps(){} // dummy constructor...
// *******************************************************
void ScreenDisps::DisplayInits()
{
textbackground(BLACK);
clrscr();
_setcursortype(_NOCURSOR);
textcolor( BLUE | BLINK );
cprintf("\n\r\n\r\n\r");
cprintf(" LLLLLLLLLLLL SSSSSSS \n\r");
cprintf(" LLLLLLLLLL SSSSSSSSSSS \n\r");
cprintf(" LLLLLL SSSSSSSSSSSSS \n\r");
cprintf(" LLLLLL SSSSSS SSSSS \n\r");
cprintf(" LLLLLL SSSSSSS \n\r");
cprintf(" LLLLLL SSSSSSS \n\r");
cprintf(" LLLLLL SSSSSS \n\r");
cprintf(" LLLLLL SSSSSSS \n\r");
cprintf(" LLLLLL SSSSSSSSS \n\r");
cprintf(" LLLLLL SSSSSS \n\r");
cprintf(" LLLLLL SSSSSS \n\r");
cprintf(" LLLLLL SSSSS SSSSS \n\r");
cprintf(" LLLLLLL LLLL SSSSSSSSSSSSSSS \n\r");
cprintf(" LLLLLLLLLLLLLLLLLLLL SSSSSSSSSS \n\r");
cprintf(" LLLLLLLLLLLLLLLLLLLLLL SSSSSSS \n\r");
gotoxy(20,23);
textcolor( YELLOW );
cprintf("Press a Key to Return to the Menu...");
getch();
_setcursortype(_NORMALCURSOR);
textcolor(WHITE);
} // End of DisplayInits ** member func of ScreenDisps
// *******************************************************
void ScreenDisps::DisplayAscii()
{
// Function to Display the ASCII chars above 128
int x,z,y=1,row=25,col=8;
textbackground(BLACK);
clrscr();
_setcursortype(_NOCURSOR);
gotoxy(row,col);
for(x=128,z=1;x<256;x++,z++)
{
if (y==16) y=1;
textcolor(y++);
cprintf("%c ",x);
if((z%16)==0) gotoxy(row,++col);
}
gotoxy(23,23);
textcolor( YELLOW );
cprintf("Press a Key to Return to the Menu...");
textcolor(WHITE);
getch();
_setcursortype(_NORMALCURSOR);
} // end of DisplayAscii ** member func of ScreenDisps
// *******************************************************
void ScreenDisps::ShowShapes()
{
int x,y;
_setcursortype(_NOCURSOR);
textbackground(BLACK);
clrscr();
textbackground(BLACK);textcolor(RED);
gotoxy(30,4);cprintf(" 3¬ + 4¬ = 7« ");
gotoxy(10,23);cprintf(" 4ý = 16 ");
MakeTri(40,7,7,3,'ì');
MakeTri(17,17,4,2,'');
gotoxy(29,15);textcolor(WHITE|BLINK);
cprintf("TEXT GRAPHICS ARE BORING");
x=1; y=4;
while(!kbhit())
{
if(x==16) x=0; x++;
if(y==16) y=0; y++;
MakeBox(10,4,7,x,y);
if(x==16) x=0; x++;
if(y==16) y=0; y++;
MakeBox(50,19,4,x,y);
if(x==16) x=0; x++;
if(y==16) y=0; y++;
MakeBox(65,5,10,x,y);
sleep(1);
}
_setcursortype(_NORMALCURSOR);
}// end of ShowShapes ** member func of ScreenDisps
//************************************************************
// end of Member Functions........
void MenuScreen(void)
{
int x,y,z;
textbackground(BLACK);
clrscr();
gotoxy(2,2);
textcolor(YELLOW);textbackground(BLUE);
cprintf("É");for(x=1;x<78;x++)cprintf("Í");cprintf("»");
for(y=3;y<24;y++)
{
gotoxy(2,y);
cprintf("º");
for(x=1;x<78;x++)cprintf(" ");
cprintf("º");
}
gotoxy(2,24);
cprintf("È");for(x=1;x<78;x++)cprintf("Í");cprintf("¼");
textbackground(RED);textcolor(BLUE|BLINK);
gotoxy(27,7);cprintf(" Program GRAPH01 - Text Graphics ");
textcolor(YELLOW); textbackground(BLUE);
gotoxy(29,10);cprintf("1. Display Initials.");
gotoxy(29,12);cprintf("2. Display Extended ASCII.");
gotoxy(29,14);cprintf("3. Bang Out Shapes and Stuff.");
gotoxy(29,16);cprintf("4. Exit");
gotoxy(31,19);cprintf("Enter your choice: ");
} // end of function MenuScreen
// **************************************************************
void MakeBox(int wherex,int wherey,int size,int tcolor,int bcolor)
{
int x,y,z;
gotoxy(wherex,wherey);
textcolor(tcolor);textbackground(bcolor);
cprintf("É");for(x=1;x<size+1;x++)cprintf("Í");cprintf("»");
for(y=wherey+1;y<size+wherey;y++)
{
gotoxy(wherex,y);
cprintf("º");
for(x=1;x<size+1;x++)cprintf(" ");
cprintf("º");
}
gotoxy(wherex,wherey+size);
cprintf("È");for(x=1;x<size+1;x++)cprintf("Í");cprintf("¼");
}// end of function MakeBox
// **************************************************************
void MakeTri(int wherex,int wherey,int size,int tcolor,char X)
{
int x,y,z,offset=2;
textcolor(tcolor);
gotoxy(wherex,wherey);
cprintf("%c",X);
x=wherex; y=wherey;
for(z=wherey+1;z<wherey+size-1;z++)
{
x-=1;
y+=1;
gotoxy(x,y);cprintf("%c",X);
gotoxy(x+offset,y);cprintf("%c",X);
offset+=2;
}
gotoxy(wherex-(size-1),wherey+size-1);
for(x=1;x<(size+size);x++) cprintf("%c",X);
}// end of function MakeTri
//********************** End of Source ***************************
// The driver
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <process.h>
#include "GHDR01.H"
void main(void)
{
ScreenDisps x;
int Choice;
while (1)
{ //while
clrscr();
MenuScreen();
cin >> (Choice);
switch (Choice) {
case 1 :
{
x.DisplayInits();
break;
}
case 2 :
{
x.DisplayAscii();
break;
}
case 3 :
{
x.ShowShapes();
break;
}
case 4 : exit(0);
} //switch
} //while
}
![]()
// figures.h contains four classes.
//
// Class Location describes screen locations in X and Y
// coordinates.
//
// Class Point describes whether a point is hidden or visible.
//
// Class Circle describes the radius of a circle around a point.
//
// Class Rect describes the width of a rectangle around a point.
//
// To use this module, put #include <figures.h> in your main
// source file and compile the source file FIGS.CPP together
// with your main source file.
//
// Code Originally from BORLAND TURBO C++ example package.
// Slight Modifications made but original code was BORLAND's
//
enum Boolean {false, true};
class Location {
protected:
int X;
int Y;
public:
Location(int InitX, int InitY) {X = InitX; Y = InitY;}
int GetX() {return X;}
int GetY() {return Y;}
};
class Point : public Location {
protected:
Boolean Visible;
int PntColor;
public:
Point(int InitX, int InitY, int InitPntColor);
Point(int InitX, int InitY);
virtual void Show(); // Show and Hide are virtual
virtual void Hide();
virtual void Drag(int DragBy); // new virtual drag function
Boolean IsVisible() {return Visible;}
void MoveTo(int NewX, int NewY);
};
class Circle : public Point { // Derived from class Point and
// ultimately from class Location
protected:
int Radius;
int CirColor;
public:
Circle(int InitX, int InitY, int InitRadius, int InitCirColor);
void Show();
void Hide();
void Expand(int ExpandBy);
void Contract(int ContractBy);
};
class Rect : public Point { // Derived from class Point and
// ultimately from class Location
protected:
int Width;
int RecColor;
public:
Rect(int InitX, int InitY, int InitWidth, int InitRecColor);
void Show();
void Hide();
};
class SpaceShip : public Point { // Derived from class Point and
// ultimately from class Location
protected:
int Radius;
int SSColor;
public:
SpaceShip(int InitX, int InitY, int InitRadius, int InitSSColor);
void Show();
void Hide();
};
// prototype of general-purpose, non-member function
// defined in FIGURES.CPP
Boolean GetDelta(int& DeltaX, int& DeltaY);
// FIGS.CPP: This file contains the definitions for the Point
// class (declared in figures.h). Member functions for the
// Location class appear as inline functions in figures.h.
//
// Programmer's Notes:
// Originally "FIGURES.CPP" which came with the BORLAND
// TURBO C++ Package as an example. Slight modifications
// (such as the Rect class or the alternate Point constructor)
// are mine. Otherwise code was lifted verbatim. Lars.
#include "figures.h"
#include <graphics.h>
#include <conio.h>
// member functions for the Point class
//constructor
Point::Point(int InitX, int InitY) : Location (InitX, InitY)
{
Visible = false; // make invisible by default
PntColor=getcolor();
}
Point::Point(int InitX, int InitY, int InitPntColor)
: Location (InitX, InitY)
{
Visible = false; // make invisible by default
PntColor = InitPntColor;
}
void Point::Show()
{
Visible = true;
putpixel(X, Y, PntColor); // uses default color
}
void Point::Hide()
{
Visible = false;
putpixel(X, Y, getbkcolor()); // uses background color to erase
}
void Point::MoveTo(int NewX, int NewY)
{
Hide(); // make current point invisible
X = NewX; // change X and Y coordinates to new location
Y = NewY;
Show(); // show point at new location
}
// a general-purpose function for getting keyboard
// cursor movement keys (not a member function)
Boolean GetDelta(int& DeltaX, int& DeltaY)
{
char KeyChar;
Boolean Quit;
DeltaX = 0;
DeltaY = 0;
do
{
KeyChar = getch(); // read the keystroke
if (KeyChar == 13) // carriage return
return(false);
if (KeyChar == 0) // an extended keycode
{
Quit = true; // assume it is usable
KeyChar = getch(); // get rest of keycode
switch (KeyChar) {
case 72: DeltaY = -1; break; // down arrow
case 80: DeltaY = 1; break; // up arrow
case 75: DeltaX = -1; break; // left arrow
case 77: DeltaX = 1; break; // right arrow
default: Quit = false; // bad key
};
};
} while (!Quit);
return(true);
}
void Point::Drag(int DragBy)
{
int DeltaX, DeltaY;
int FigureX, FigureY;
Show(); // display figure to be dragged
FigureX = GetX(); // get initial position of figure
FigureY = GetY();
// This is the drag loop
while (GetDelta(DeltaX, DeltaY))
{
// Apply delta to figure at X, Y
FigureX += (DeltaX * DragBy);
FigureY += (DeltaY * DragBy);
MoveTo(FigureX, FigureY); // tell figure to move
};
}
// Member functions for the Circle class
//constructor
Circle::Circle(int InitX, int InitY, int InitRadius, int InitCirColor)
: Point (InitX, InitY)
{
Radius = InitRadius;
CirColor = InitCirColor;
}
void Circle::Show()
{
Visible = true;
setcolor(CirColor);
circle(X, Y, Radius); // draw the circle
setfillstyle(SOLID_FILL, CirColor);
floodfill(X, Y, CirColor);
}
void Circle::Hide()
{
unsigned int TempColor; // to save current color
TempColor = getcolor(); // set to current color
setcolor(getbkcolor()); // set drawing color to background
Visible = false;
circle(X, Y, Radius); // draw in background color to
setcolor(TempColor); // set color back to current color
}
void Circle::Expand(int ExpandBy)
{
Hide(); // erase old circle
Radius += ExpandBy; // expand radius
if (Radius < 0) // avoid negative radius
Radius = 0;
Show(); // draw new circle
}
void Circle::Contract(int ContractBy)
{
Expand(-ContractBy); // redraws with (Radius-ContractBy)
}
// Member functions for the Rect class
//constructor
Rect::Rect(int InitX, int InitY, int InitWidth, int InitRecColor)
: Point (InitX, InitY)
{
Width = InitWidth;
RecColor = InitRecColor;
}
void Rect::Show()
{
Visible = true;
setcolor(RecColor);
rectangle(X-Width, Y-Width, X+Width, Y+Width ); // draw the circle
setfillstyle(SOLID_FILL, RecColor);
floodfill(X, Y, RecColor);
}
void Rect::Hide()
{
unsigned int TempColor; // to save current color
TempColor = getcolor(); // set to current color
setcolor(getbkcolor()); // set drawing color to background
Visible = false;
rectangle(X-Width, Y-Width, X+Width, Y+Width ); // draw the rectangle
setcolor(TempColor); // set color back to current color
}
// Member functions for the SpaceShip class
//constructor
SpaceShip::SpaceShip(int InitX, int InitY, int InitRadius, int InitSSColor)
: Point (InitX, InitY)
{
Radius = InitRadius;
SSColor = InitSSColor;
}
void SpaceShip::Show()
{
Visible = true;
setcolor(SSColor);
arc(X, Y, 0, 180, Radius); // draw the Top of the Ship
line(X-Radius, Y, X+Radius, Y); // draw the Bottom of the Ship
}
void SpaceShip::Hide()
{
unsigned int TempColor; // to save current color
TempColor = getcolor(); // set to current color
setcolor(getbkcolor()); // set drawing color to background
Visible = false;
arc(X, Y, 0, 180, Radius); // Hide the Top of the Ship
line(X-Radius, Y, X+Radius, Y); // Hide the Bottom of the Ship
}
// GRAPH02.CPP -- Display a SpaceShip going across a Galaxy
// Programmer : Lars G Sorensen
// Link with GRAPHICS.LIB
// Uses "figures.h" Generously supplied by Borland Intl.
// Uses "figs.cpp" Implementations of Classes for Above
// Code Hijaaked from BORLAND's "FIGDEMO.CPP"
//
// The "MakeStars" function was hijaaked from
// the BORLAND TURBO C 2.0 BGIDEMO.C program....
//
#include "figures.h"
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <graphics.h>
#include <conio.h>
void MakeStars(void);
int main() // test the new Arc class
{
int x,y,z;
SpaceShip TheShip(10,240,15,3);
Circle TheSun(500,100,40,YELLOW);
Circle APlanet(100,380,55,BLUE);
Circle AnotherPlanet(540,380,15,RED);
// Initialize the Graphics mode
int graphdriver = DETECT, graphmode;
initgraph(&graphdriver, &graphmode, "f:\\applic\\lang\\tcpp\\bgi");
// Get Ready.....
clearviewport();
gotoxy(1,1);
printf(" GRAPH02.CPP - Demonstration of OOP shapes and motion.\n");
printf(" Lars Sorensen \n");
printf("\nPress Any Key to See the Space Show......\n");
getch();
// GO..
clearviewport();
MakeStars();
TheSun.Show();
APlanet.Show();
AnotherPlanet.Show();
// Now we have a galaxy, Sun, and Planets....
// Show the Ship and begin it's trip across the screen
TheShip.Show();
for(x=15;x<320;x+=5)
{
TheShip.MoveTo(x,240);
delay(80);
}
// At the Halfway point make a silly sound.....
sound(100);delay(50);
sound(200);delay(50);
sound(300);delay(50);
sound(400);delay(150);
nosound();
// Now finish the journey.....
for(x=320;x<640;x+=5)
{
TheShip.MoveTo(x,240);
delay(80);
}
// Now Clean Up....
gotoxy(1,1);
printf(" That's all Folks.. Press a Key to end the Program ");
getch();
closegraph();
return 0;
} // Main
// Function to make a bunch of stars......
void MakeStars(void)
{
int seed = 1958;
int i, x, y, h, w, color;
struct viewporttype vp;
getviewsettings( &vp );
h = vp.bottom - vp.top;
w = vp.right - vp.left;
srand( seed ); /* Restart random # function */
for( i=0 ; i<5000 ; ++i ){ /* Put 5000 pixels on screen */
x = 1 + random( w - 1 ); /* Generate a random location */
y = 1 + random( h - 1 );
color = random( 16 );
putpixel( x, y, color );
}
}
![]()
larsfigs.h
#ifndef MYGROOP_HEADERFILE
#define MYGROOP_HEADERFILE 1
#include <string.h>
#include <graphics.h>
const FALSE = 0;
const TRUE = 1;
typedef int Boolean;
enum SolidFillType {Filled, Hollow};
typedef unsigned char byte;
typedef unsigned int word;
typedef float Matrix3by3[3][3];
const MaxVertices = 50;
//******************************************************
class Location
{
protected:
float X;
float Y;
public:
Location (float InX, float InY);
float GetX ();
float GetY ();
void SetX (float InX);
void SetY (float InY);
void SetXY (float InX, float InY);
void IncX ();
void IncX (float InInc);
void IncY ();
void IncY (float InInc);
};
class Point : public Location
{
protected:
byte Color;
char Label[2];
Boolean ShowLabel;
Boolean Visible;
public:
Point (float InX, float InY, byte InColor = WHITE,
Boolean InVisible = TRUE,
char InLabel[2] = " ",
Boolean InShowLabel = FALSE);
Point (); //default
~Point (); //virtual?
void SetColor (byte InColor) {Color = InColor;};
void SetLabel (char InLabel[2]) {strcpy(Label,InLabel);};
void SetVisible (Boolean InVisible) {Visible = InVisible;};
void SetShowLabel (Boolean InShowLabel) {ShowLabel = InShowLabel;};
void Display();
void DisplayText();
virtual void Hide();
Boolean IsVisible();
void MoveTo(float NewX, float NewY);
virtual void Drag(int DragBy);
};
class Circle : public Point
{
protected :
float Radius;
SolidFillType Interior;
word Pattern;
byte FillColor;
public:
Circle (Point Center, float InR, byte InColor);
Circle (float InX, float InY, float InR, byte InColor);
Circle (float InX, float InY, float InR, byte InColor,
SolidFillType InSol, word InPat, byte InFill);
void Display();
virtual void Hide();
virtual void Expand(float ExpandBy);
virtual void Contract(float ContractBy);
void TCCircle();
void BresCircle();
void PlotCirclePoints(int xx, int yy);
void PolarCircle();
};
class Ellipse : public Point
{
protected :
float Radius1;
float Radius2;
SolidFillType Interior;
word Pattern;
int FillColor;
public :
Ellipse (float InX, float InY, float InR1, float InR2,
byte InColor, Boolean InV,
SolidFillType InSol, word InPat, int InFill);
virtual void Display();
virtual void Hide();
void TCEllipse();
void CalculateArc (int xx, int yy, byte flag);
void BresEllipse();
void PlotEllipsePoints (int xx, int yy);
};
class Triangle : Point
{
protected:
Point A;
Point B;
Point C;
public:
Triangle (Point InA, Point InB, Point InC, int InColor);
void Display();
};
class Rectangle : Point
{
protected:
Point A; //bottom left
Point B; //top right
Point C; //top left
Point D; //bottom right
public:
Rectangle (Point InA, Point InB, int InColor);
Rectangle (Point InA, Point InB, Point InC, Point InD, int InColor);
void Display();
void Display2();
};
enum PolarCurveType {PolarC,Cardi,Spira,Ros,Lima};
class PolarCurve : public Point
{
protected :
PolarCurveType Formula;
float Size;
float a,b;
public :
PolarCurve (float InX, float InY, float InSize,
Boolean InV, byte InColor,
PolarCurveType InForm);
PolarCurve (float InX, float InY, float InA, float InB,
Boolean InV, byte InColor);
void PolarCurveMenu();
virtual void Display();
};
class Rose : public PolarCurve
{
protected :
byte Leaves;
public :
Rose (float InX, float InY, float InSize,
Boolean InV, byte InColor,
PolarCurveType InForm, byte InitLeaves);
virtual void Display();
};
class Limacon : public PolarCurve
{
protected :
float Size2;
public :
Limacon (float InX, float InY, float InSize1, float InSize2,
Boolean InV, byte InColor,
PolarCurveType InForm);
virtual void Display();
};
class LineSeg : public Point
{
protected:
Point A;
Point B;
float DeltaX;
float DeltaY;
double Slope;
double LineLength;
int LineColor;
public:
LineSeg (Point InA, Point InB, int InColor);
LineSeg ();
virtual void Display();
Point GetA() {return A;};
Point GetB() {return B;};
float GetDeltaX() {return DeltaX;};
float GetDeltaY() {return DeltaY;};
double GetSlope() {return Slope;};
double GetLineLength() {return LineLength;};
int GetLineColor();
void TCLine();
void DirectMethod (float m, float b);
void DiffLine();
void FirstOctant(float x1, float y1, float x2, float y2, int YIncrement); //Small slope
void SecondOctant(float x1, float y1, float x2, float y2, int XIncrement); //large slope
void Swap(float &a, float &b);
void DDA();
void BresLine();
};
class PolyLine : public Point
{
protected:
word NumberOfVertices;
Point V[55];
public:
PolyLine (Point Pts[55], word InNV, byte InColor, Boolean InV );
PolyLine (char * PathName); //from a datafile
PolyLine () { };
virtual void Display();
virtual void Hide();
void SetVisible(Boolean InV) {Visible = InV;};
word GetNumberOfVertices() {return NumberOfVertices;}
Point* GetPoints() {return V;}
};
class Polygon : public PolyLine
{
protected :
SolidFillType Interior;
word Pattern;
byte FillColor;
float FillX, FillY;
struct EachEntry
{
int YTop; //larger y coordinate for line
float XInt; //x that goes with larger y
int DeltaY; //difference in y coordinates
float XChangePerScan; //x change per unit change in y
} sides[MaxVertices];
int SideCount,FirstS,LastS,scan,bottomscan,XIntCount,r;
public :
Polygon(Point Pts[25], word InNV, byte InColor, Boolean InV,
SolidFillType InSol, word InPat, byte InFill,
float InFillX, float InFillY );
Polygon (char PathName[80]);
Polygon () { };
virtual void Display();
virtual void Hide();
void FillAreaSolid();
int NextY (int k);
void PutInSidesList (int entry, int x1, int y1,
int x2, int y2, int NextY);
void SortOnBiggerY (int &SideCount, int &bottomscan);
void UpdateFirstAndLast (int count, int scan, int &FirstS, int &LastS);
void swap (EachEntry &entry1, EachEntry &entry2);
void SortOnX (int entry, int FirstS);
void ProcessXIntersections (int FirstS, int LastS, int &XIntCount);
void DrawLines (int scan, int XIntCount, int index);
void UpdateSidesList ();
void SetInterior (SolidFillType InSol) {Interior = InSol;};
void SetPattern (word InPat) {Pattern = InPat;};
void SetFillColor (byte InFill) {FillColor = InFill;};
};
class RegularPolygon : public Polygon
{
protected :
int Radius;
public :
RegularPolygon(float InX, float InY, float InR,
word InNV, byte InColor, Boolean InV,
SolidFillType InSol, word InPat, byte InFill);
};
class MatrixOps
{
protected :
//float M[3][3];
Matrix3by3 M;
//float T[3][3];
Matrix3by3 T;
public :
MatrixOps ();
void Display();
void MakeIdentity();
void CombineTransformations();
float RadianEquivalent (float a) { return a*3.14159265/180; };
void Scale (float sx, float sy, int xf, int yf);
void Rotate (float a, int xr, int yr);
void Translate (int tx, int ty);
void TransformPoints (Point P[], word NumberOfVertices);
};
void BoundaryFill (int x, int y, byte FillColor, byte Boundary);
void FreeHandDraw (byte DrawingColor, Point PickedPointArray[25],
byte &PickedPointNumber);
#endif
// The Goods <things get long here>
#ifndef MYGROOP_HEADERFILE
#include "larsfigs.h"
#endif
#ifndef MYLOGWS_HEADERFILE
#include "larslgws.h"
#endif
#include <graphics.h>
#include <string.h>
#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>
#include <conio.h>
#include <math.h>
#include <values.h>
#include <stdio.h>
#include <process.h>
//======================================================================
extern LogicalWorkstation LW;
char DriveSpec[4] = "f:\\"; //for intermediate data
char Gray50[8] = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55};
//LOCATION
Location::Location (float InX, float InY)
{
X = InX;
Y = InY;
}
float Location::GetX ()
{
return X;
}
float Location::GetY()
{
return Y;
}
void Location::SetX (float InX)
{
X = InX;
}
void Location::SetY(float InY)
{
Y = InY;
}
void Location::SetXY(float InX, float InY)
{
X = InX;
Y = InY;
}
void Location::IncX()
{
X++;
}
void Location::IncX(float InInc)
{
X += InInc;
}
void Location::IncY(float InInc)
{
Y += InInc;
}
void Location::IncY()
{
Y++;
}
//====================================================================
//POINT
Point::Point (float InX, float InY, byte InColor,
Boolean InVisible, char InLabel[2], Boolean InShowLabel) :
Location(InX,InY)
{
Color = InColor;
strcpy(Label,InLabel);
ShowLabel = InShowLabel;
Visible = InVisible;
}
Point::Point ():
Location(0,0)
{
Color = WHITE;
strcpy(Label," ");
ShowLabel = FALSE;
}
Point::~Point ()
{
}
void Point::Display()
{
float a = X;
float b = Y;
LW.TransformPoint(a,b); //don't mess with the X and Y
Visible = TRUE;
putpixel(a,b,Color); //plot the converted values
if (ShowLabel)
outtextxy (X - 10, getmaxy() - Y - 10,Label);
}
void Point::DisplayText()
{
cout << "(" << X << "," << Y << ")";
}
void Point::Hide()
{
float a = X;
float b = Y;
LW.TransformPoint(a,b);
Visible = FALSE;
putpixel(a, b, getbkcolor());
}
Boolean Point::IsVisible()
{
return Visible;
};
void Point::MoveTo(float NewX, float NewY)
{
Hide();
X = NewX;
Y = NewY;
Display();
};
// a general-purpose function for getting keyboard
// cursor movement keys (not a member function)
Boolean GetDelta(int& DeltaX, int& DeltaY)
{
char KeyChar;
Boolean Quit;
DeltaX = 0;
DeltaY = 0;
do
{
KeyChar = getch(); // read the keystroke
if (KeyChar == 13) // carriage return
return(FALSE);
if (KeyChar == 0) // an extended keycode
{
Quit = TRUE; // assume it is usable
KeyChar = getch(); // get rest of keycode
switch (KeyChar) {
case 72: DeltaY = -1; break; // down arrow
case 80: DeltaY = 1; break; // up arrow
case 75: DeltaX = -1; break; // left arrow
case 77: DeltaX = 1; break; // right arrow
default: Quit = FALSE; // bad key
};
};
} while (!Quit);
return(TRUE);
}
void Point::Drag(int DragBy)
{
int DeltaX, DeltaY;
int FigureX, FigureY;
Display(); // Display figure to be dragged
FigureX = GetX(); // Get the initial position of figure
FigureY = GetY();
// This is the drag loop:
while (GetDelta(DeltaX, DeltaY))
{ // Apply delta to figure X,Y:
FigureX += (DeltaX * DragBy);
FigureY += (DeltaY * DragBy);
MoveTo(FigureX, FigureY); // And tell the figure to move
}
};
//=============================================================
// Circle.....
//constructor
Circle::Circle(float InX, float InY, float InR, byte InColor,
SolidFillType InSol, word InPat, byte InFill)
: Point (InX, InY, InColor, FALSE,"wa",FALSE)
{
Radius = InR;
Color = InColor;
Interior = InSol;
Pattern = InPat;
FillColor = InFill;
}
void Circle::Display()
{
Visible = TRUE;
setcolor(Color);
float a = X;
float b = Y;
LW.TransformPoint(a,b);
circle(a, b, Radius); // draw the circle
setfillstyle(Pattern, FillColor);
floodfill(a, b, Color);
}
void Circle::Hide()
{
unsigned int TempColor; // to save current color
TempColor = Color; // set to current color
setcolor(getbkcolor()); // set drawing color to background
Visible = FALSE;
float a = X;
float b = Y;
LW.TransformPoint(a,b);
setfillstyle(SOLID_FILL, getbkcolor());
floodfill(a,b,TempColor);
circle(a,b,Radius); // draw in background color to
setcolor(TempColor); // set color back to current color
}
void Circle::Expand(float ExpandBy)
{
Hide(); // erase old circle
Radius += ExpandBy; // expand radius
if (Radius < 0.0) // avoid negative radius (are they drunk?)
Radius = 0.0;
Display(); // draw new circle
}
void Circle::Contract(float ContractBy)
{
Expand(-ContractBy); // redraws with (Radius-ContractBy)
}
void Circle::PolarCircle()
{
int i;
float theta;
for ( i = 1; i < 628; i++ )
{
theta = i/100.0;
Point P(X+Radius*sin(theta),Y+Radius*cos(theta),Color,TRUE," ",FALSE);
P.Display();
}
} // Polar Circle.....
// =============================================================
//LINESEG
LineSeg::LineSeg (Point InA, Point InB, int InColor) :
Point( (InA.GetX() + InB.GetX())/2, (InA.GetY() + InB.GetY())/2, InColor-1,
TRUE," ", FALSE)
{
A = InA;
B = InB;
LineColor = InColor;
DeltaX = B.GetX() - A.GetX();
DeltaY = B.GetY() - A.GetY();
if (DeltaX == 0)
Slope = MAXDOUBLE;
else
Slope = (double) DeltaY/DeltaX;
LineLength = sqrt((double)(DeltaX*DeltaX + DeltaY*DeltaY));
}
LineSeg::LineSeg () :
Point( 0, 0, WHITE, TRUE, " ", FALSE)
{
// How do I initialize A and B? A = InA; B = InB;
DeltaX = 0;
DeltaY = 0;
Slope = 0;
LineLength = 0;
LineColor = WHITE;
}
void LineSeg::Display()
{
float x1,x2,y1,y2;
setcolor(LineColor);
x1 = A.GetX();
y1 = A.GetY();
x2 = B.GetX();
y2 = B.GetY();
LW.TransformPoint(x1,y1);
LW.TransformPoint(x2,y2);
line(x1,y1,x2,y2);
}
void LineSeg::TCLine()
{
float x1,x2,y1,y2;
setcolor(LineColor);
x1 = A.GetX();
y1 = A.GetY();
x2 = B.GetX();
y2 = B.GetY();
LW.TransformPoint(x1,y1);
LW.TransformPoint(x2,y2);
line(x1,y1,x2,y2);
}
void LineSeg::DirectMethod (float m, float b)
{
Point P(0,b,LineColor,TRUE," ",FALSE);
for (int x = A.GetX(); x <= (A.GetX()+LineLength); x++)
{
P.SetXY(x, m*x+b);
P.Display();
}
} //DirectMethod
void LineSeg::FirstOctant(float x1, float y1, float x2, float y2, int YIncrement)
//Small slope
{
//Step through x, increment y
float Error,DeltaX,DeltaY;
DeltaX = x2 - x1;
DeltaY = y2 - y1;
Error = -(DeltaX/2);
Point P(x1,y1,LineColor,Visible," ",FALSE);
P.Display();
while (P.GetX() < x2)
{
Error += DeltaY;
if (Error >= 0)
{
P.IncY(YIncrement);
Error -= DeltaX;
}
P.IncX();
P.Display();
}
}
void LineSeg::SecondOctant(float x1, float y1, float x2, float y2, int XIncrement)
//Large slope
//Step through y, increment x
{
float Error,DeltaX,DeltaY;
DeltaX = x2 - x1;
DeltaY = y2 - y1;
Error = -(DeltaY/2);
Point P(x1,y1,LineColor,Visible," ",FALSE);
P.Display();
while (P.GetY() < y2) //from lower point to upper point
{
Error += DeltaX;
if (Error >= 0)
{
P.IncX(XIncrement);
Error -= DeltaY;
}
P.IncY();
P.Display();
}
}
void LineSeg::Swap(float &a, float &b)
{
float temp;
temp = a;
a = b;
b = temp;
}
void LineSeg::DiffLine()
{
//Bresenham's Line Algorithm pg80 First octant
float x1,y1,x2,y2;
int XIncrement, YIncrement;
if (A.GetX() > B.GetX()) //endpoints given in RL order
{
x1 = B.GetX();
y1 = B.GetY();
x2 = A.GetX();
y2 = A.GetY();
}
else
{
x1 = A.GetX();
y1 = A.GetY();
x2 = B.GetX();
y2 = B.GetY();
}
//so now (x1,y1) is the left endpoint
// and (x2,y2) is the right endpoint
if (fabs(Slope) < 1) //small slope
{
if (Slope > 0) //positive slope
YIncrement = 1;
else //negative slope
YIncrement = -1;
FirstOctant(x1,y1,x2,y2,YIncrement);
}
else //large slope
{
if (Slope > 0)
XIncrement = 1;
else
XIncrement = -1;
SecondOctant(x1,y1,x2,y2,XIncrement);
}
}
void LineSeg::DDA()
{
int dx,dy,steps;
float XIncrement,YIncrement;
dx = GetDeltaX();
dy = GetDeltaY();
if (abs(dx) > abs(dy))
steps = abs(dx);
else
steps = abs(dy);
XIncrement = dx/steps;
YIncrement = dy/steps;
Point Pt(A.GetX(),A.GetY(),LineColor,TRUE," ",FALSE);
Pt.Display();
for (int i = 1; i <= steps; i++)
{
Pt.IncX(XIncrement);
Pt.IncY(YIncrement);
Pt.Display();
}
} //LineSeg.dda
void LineSeg::BresLine()
{
float dx,dy;
int param1,NonDiagonalInc,DiagonalInc;
int DxNondiag,DyNondiag,DxDiag,DyDiag;
word i;
Point Pt(A.GetX(),A.GetY(),LineColor,TRUE," ",FALSE);
dx = B.GetX() - Pt.GetX();
dy = B.GetY() - Pt.GetY();
//Determine whether ending point lies to the right or left of
// the starting point
if (dx < 0)
{
dx = -dx;
DxDiag = -1;
}
else
DxDiag = 1;
//Determine whether ending point lies above or below starting point
if (dy < 0)
{
dy = -dy;
DyDiag = -1;
}
else
DyDiag = 1;
//Identify octant containing ending point
if (dx < dy)
{
Swap(dx,dy);
DxNondiag = 0;
DyNondiag = DyDiag;
}
else
{
DxNondiag = DxDiag;
DyNondiag = 0;
}
param1 = dy + dy - dx;
NonDiagonalInc = dy + dy;
DiagonalInc = dy + dy - dx - dx;
for (i = 1; i <= dx; i++)
{
Pt.Display();
if (param1 < 0)
{ //Step nondiagonally
Pt.IncX(DxNondiag);
Pt.IncY(DyNondiag);
param1 += NonDiagonalInc;
}
else
{ //Step diagonally
Pt.IncX(DxDiag);
Pt.IncY(DyDiag);
param1 += DiagonalInc;
}
}
} //LineSeg.BresLine
PolyLine::PolyLine (Point Pts[55], word InNV, byte InColor, Boolean InV) :
Point()
{
Visible = InV;
Color = InColor;
NumberOfVertices = InNV;
for ( int i = 0; i < NumberOfVertices; i++ )
{
V[i].SetXY(Pts[i].GetX(),Pts[i].GetY());
V[i].SetColor(InColor);
V[i].SetVisible(InV);
V[i].SetLabel(" ");
V[i].SetShowLabel(FALSE);
}
}
void PolyLine::Display()
{
float a,b,c,d;
byte TempColor;
if ( !Visible )
{
TempColor = Color;
Color = getbkcolor();
}
setcolor(Color);
for ( int i = 0; i < NumberOfVertices - 1; i++ )
{
a = V[i].GetX();
b = V[i].GetY();
LW.TransformPoint(a,b);
c = V[i+1].GetX();
d = V[i+1].GetY();
LW.TransformPoint(c,d);
line(a,b,c,d);
}
if (!Visible)
Color = TempColor;
}
void PolyLine::Hide() {}
Polygon::Polygon( Point pts[25], word InNV, byte InColor,Boolean InV,
SolidFillType InSol, word InPat, byte InFill,
float InFillX, float InFillY )
: PolyLine(pts,InNV,InColor,InV)
{
Interior = InSol;
Pattern = InPat;
FillColor = InFill;
FillX = InFillX;
FillY = InFillY;
V[InNV].SetXY(pts[0].GetX(),pts[0].GetY());
V[InNV].SetColor(InColor);
V[InNV].SetVisible(InV);
V[InNV].SetLabel(" ");
V[InNV].SetShowLabel(FALSE);
NumberOfVertices++;
} // Polygon.Create
void Polygon::Display()
{
Visible = TRUE;
PolyLine::Display();
switch(Interior)
{
case Filled : FillAreaSolid();
break;
case Hollow :;
}
} // Polygon Display
//Polygon::FillAreaSolid functions
int Polygon::NextY (int k)
{
int i = 0;
if (k == NumberOfVertices)
return V[i].GetY();
else
{
while (V[k].GetY() == V[k+i].GetY())
i++;
return V[k+i].GetY();
}
}
void Polygon::PutInSidesList (int entry, int x1, int y1,
int x2, int y2, int NextY)
{
int maxy;
float X2Temp,XChangeTemp;
//make adjustments for problem vertices
XChangeTemp = ((float)(x2 - x1))/(y2 - y1);
X2Temp = x2;
if ( (y2 > y1) && (y2 < NextY) )
{
y2--;
X2Temp -= XChangeTemp;
}
else
if ( (y2 < y1) && (y2 > NextY) )
{
y2++;
X2Temp += XChangeTemp;
}
//insert into sides list
if (y1 > y2)
maxy = y1;
else
maxy = y2;
while ( (entry > 1) && (maxy > sides[entry-1].YTop) )
{
sides[entry] = sides[entry-1];
entry--;
}
sides[entry].YTop = maxy;
sides[entry].DeltaY = abs(y2-y1) + 1;
if (y1 > y2)
sides[entry].XInt = x1;
else
sides[entry].XInt = X2Temp;
sides[entry].XChangePerScan = XChangeTemp;
}
void Polygon::SortOnBiggerY (int &SideCount, int &bottomscan)
{
int k,x1,y1;
float a,b,c,d;
SideCount = 0;
y1 = V[NumberOfVertices].GetY();
x1 = V[NumberOfVertices].GetX();
bottomscan = V[NumberOfVertices].GetY();
for (k = 0; k < NumberOfVertices; k++)
{
if (y1 != V[k].GetY())
{
SideCount++;
//pass old pt, current pt, and y of next nonhorizontal pt
PutInSidesList (SideCount,x1,y1,V[k].GetX(),V[k].GetY(),NextY(k));
}
else
{
setcolor(Color);
a = x1;
b = y1;
c = V[k].GetX();
d = y1;
LW.TransformPoint(a,b);
LW.TransformPoint(c,d);
line(a,b,c,d);
}
if (V[k].GetY() < bottomscan)
bottomscan = V[k].GetY();
y1 = V[k].GetY();
x1 = V[k].GetX(); //save for next side
}
}
void Polygon::UpdateFirstAndLast (int count, int scan,
int &FirstS, int &LastS)
{
while ( (sides[LastS+1].YTop >= scan) && (LastS < count) )
LastS++;
while (sides[FirstS].DeltaY == 0)
FirstS++;
}
void Polygon::swap (EachEntry &entry1, EachEntry &entry2)
{
EachEntry temp;
temp = entry1;
entry1 = entry2;
entry2 = temp;
}
void Polygon::SortOnX (int entry, int FirstS)
{
while ((entry > FirstS) && (sides[entry].XInt < sides[entry-1].XInt))
{
swap (sides[entry],sides[entry-1]);
entry--;
}
}
void Polygon::ProcessXIntersections (int FirstS, int LastS, int &XIntCount)
{
int k;
XIntCount = 0;
for (k = FirstS; k <= LastS; k++)
if (sides[k].DeltaY > 0)
{
XIntCount++;
SortOnX (k,FirstS);
}
}
void Polygon::DrawLines (int scan, int XIntCount, int index)
{
int k,x,x1,x2;
int ub;
ub = XIntCount/2;
for (k = 0; k < ub; k++)
{
while (sides[index].DeltaY == 0)
index++;
x1 = sides[index].XInt;
index++;
while (sides[index].DeltaY == 0)
index++;
x2 = sides[index].XInt;
/* Point P (x1,scan,FillColor,TRUE," ",FALSE);
for (x = x1; x <= x2; x++)
{
P.SetX(x);
P.Display();
}
*/
float a,b,c,d;
setcolor(FillColor);
a = x1;
b = scan;
c = x2;
d = scan;
LW.TransformPoint(a,b);
LW.TransformPoint(c,d);
line(a,b,c,d);
index++;
}
}
void Polygon::UpdateSidesList ()
{
int k;
for (k = FirstS; k <= LastS; k++)
if (sides[k].DeltaY > 0)
{
sides[k].DeltaY--;
sides[k].XInt -= sides[k].XChangePerScan;
}
}
void Polygon::FillAreaSolid()
{
int i;
for (i = 0; i < NumberOfVertices; i++)
{
sides[i].YTop = 0;
sides[i].XInt = 0.0;
sides[i].DeltaY = 0;
sides[i].XChangePerScan = 0.0;
}
SortOnBiggerY (SideCount,bottomscan);
//initialize pointers into sorted list
FirstS = 1;
LastS = 1;
for (scan = sides[1].YTop; scan >= bottomscan; scan--)
{
UpdateFirstAndLast (NumberOfVertices,scan,FirstS,LastS);
ProcessXIntersections (FirstS,LastS,XIntCount);
DrawLines (scan,XIntCount,FirstS);
UpdateSidesList ();
}
}
RegularPolygon::RegularPolygon(float InX, float InY, float InR,
word InNV, byte InColor, Boolean InV,
SolidFillType InSol, word InPat, byte InFill)
: Polygon()
{
int i;
float Alpha;
Visible = InV;
Color = InColor;
NumberOfVertices = InNV;
Radius = InR;
Alpha = ( 2*3.14159265 )/ InNV;
for ( i=0 ; i < InNV; i++ )
{
V[i].SetXY(InX+Radius*cos(i*Alpha), InY+Radius*sin(i*Alpha));
V[i].SetColor(InColor);
V[i].SetVisible(InV);
V[i].SetLabel(" ");
V[i].SetShowLabel(FALSE);
}
V[InNV].SetXY(V[0].GetX(), V[0].GetY());
V[InNV].SetColor(InColor);
V[InNV].SetVisible(InV);
V[InNV].SetLabel(" ");
V[InNV].SetShowLabel(FALSE);
NumberOfVertices++;
SetInterior(InSol);
SetPattern(InPat);
SetFillColor(InFill);
}
PolyLine::PolyLine(char* PathName)
: Point()
{
int x,y;
ifstream DataFile(PathName, ios::in);
Visible = TRUE;
Color = YELLOW;
int i = 0;
while (DataFile >> x >> y )
{
V[i].SetXY(x,y);
V[i].SetColor(YELLOW);
V[i].SetVisible(TRUE);
V[i].SetLabel(" ");
V[i].SetShowLabel(FALSE);
i++;
}
NumberOfVertices = i;
DataFile.close();
} // read from file...
void Polygon::Hide() {}
Ellipse::Ellipse (float InX, float InY, float InR1, float InR2,
byte InColor, Boolean InV,
SolidFillType InSol, word InPat, int InFill) :
Point (InX, InY, InColor, InV," ",FALSE)
{
Radius1 = InR1;
Radius2 = InR2;
Interior = InSol;
Pattern = InPat;
FillColor = InFill;
}
void Ellipse::Display()
{
setcolor(Color);
TCEllipse();
}
void Ellipse::Hide()
{
word TempColor;
SolidFillType TempSol;
TempColor = Color;
Color = getbkcolor();
Visible = FALSE;
float a,b,c,d;
Visible = TRUE;
setcolor(Color);
a = X;
b = Y;
LW.TransformPoint(a,b);
c = Radius1;
LW.TransformSize(c);
d = Radius2;
LW.TransformSize(d);
ellipse(a,b,0,360,c,d);
switch(Interior)
{
case Filled : setfillstyle(Pattern,FillColor);
floodfill(a,b,Color);
break;
case Hollow :;
}
Color = TempColor;
}
void Ellipse::TCEllipse()
{
float a,b,c,d;
Visible = TRUE;
setcolor(Color);
a = X;
b = Y;
LW.TransformPoint(a,b);
c = Radius1;
LW.TransformSize(c);
d = Radius2;
LW.TransformSize(d);
ellipse(a,b,0,360,c,d);
switch(Interior)
{
case Filled : setfillstyle(Pattern,FillColor);
floodfill(a,b,Color);
break;
case Hollow :;
}
} // end of TCEllipse
void Ellipse::PlotEllipsePoints (int xx, int yy)
{
// Plot the four symetric points for the ellipse
Point P1 (X + xx,Y + yy,Color,TRUE," ",FALSE); P1.Display();
Point P2 (X - xx,Y + yy,Color,TRUE," ",FALSE); P2.Display();
Point P3 (X + xx,Y - yy,Color,TRUE," ",FALSE); P3.Display();
Point P4 (X - xx,Y - yy,Color,TRUE," ",FALSE); P4.Display();
}
void Ellipse::CalculateArc (int xx, int yy, byte flag)
{
float EcentricitySquared = pow(Radius2/Radius1,2);
float p = 2*EcentricitySquared - 2*Radius2 + 1;
float slope = (EcentricitySquared*(-xx))/yy;
while ( (slope > -1) && (Y > 0) )
{
if (flag == 1)
PlotEllipsePoints(xx,yy);
if (flag == 2)
PlotEllipsePoints(-yy,xx);
if (p < 0)
// Increment the parameter stay at same y level....
p = p + 2*EcentricitySquared*(2*xx+3);
else
{
// increment the parameter.....
p = p + 2*EcentricitySquared*(2*xx+3) - 4*yy + 4;
yy--;
}
xx++;
if (yy != 0)
slope = (EcentricitySquared*(-xx))/yy;
}
} // calaculate_arc
void Ellipse::BresEllipse()
{
float temp;
int xx,yy;
byte flag;
xx = 0; //start at the top of the ellipse
yy = Radius2;
flag = 1;
CalculateArc(xx,yy,flag);
temp = Radius1; // Rotate the ellipse counterclockwise 90 deg
Radius1 = Radius2;
Radius2 = temp;
xx = 0; // start at the top of the new ellipse
yy = Radius2;
flag = 2;
CalculateArc(xx,yy,flag);
} // BresEllipse
// The Driver
// Graph03 Timing the three different line segments....
//
// MicroComputer Graphics...
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <Timer.h>
#include "larsfigs.h"
#include "larslgws.h"
LogicalWorkstation LW(1);
double min(double value1, double value2 )
{
return ( (value1 > value2) ? value2 : value1);
}
void main(void)
{
double A,B,C;
double z,y,x;
int i,k,j;
Timer Rolex;
// Do each type of Line segment on a different screen
// and save the times as you go... First a description.
clearviewport();
gotoxy(2,2);
cout << '\n';
cout << " Timing the Line Segments..... \n";
cout << " We will run a sample of 100 of each of the\n";
cout << " three line drawing methods. We will time each\n";
cout << " one and display the fastest at the end.\n";
cout << "\n Press Any Key to Continue...\n";
getch();
clearviewport();
gotoxy(2,2);
cout << "\n The Direct Method\n";
Rolex.reset();
Rolex.start();
for ( i=0; i < 1000; i+=10 )
{
Point W1(1000.0,1000.0+i,12,FALSE,"qa",FALSE);
Point W2(5000.0,1000.0+i,12,FALSE,"qa",FALSE);
LineSeg a_line(W1,W2,4);
a_line.DirectMethod(0.0,1000.0+i);
}
Rolex.stop();
A = Rolex.time();
cout << "The Time was : " << A << " seconds.";
cout << "\n(Press any key to continue...)";
getch();
clearviewport();
gotoxy(2,2);
cout << "\n The Bresenham Method\n";
Rolex.reset();
Rolex.start();
for ( i=0; i < 1000; i+=10 )
{
Point W1(1000.0,1000.0+i,12,FALSE,"qa",FALSE);
Point W2(5000.0,1000.0+i,12,FALSE,"qa",FALSE);
LineSeg a_line(W1,W2,4);
a_line.BresLine();
}
Rolex.stop();
B = Rolex.time();
cout << "The Time was : " << B << " seconds.";
cout << "\n(Press any key to continue...)";
getch();
clearviewport();
gotoxy(2,2);
cout << " The DDA Method\n";
Rolex.reset();
Rolex.start();
for ( i=0; i < 1000; i+=10 )
{
Point W1(1000.0,1000.0+i,12,FALSE,"qa",FALSE);
Point W2(5000.0,1000.0+i,12,FALSE,"qa",FALSE);
LineSeg a_line(W1,W2,4);
a_line.DDA();
}
Rolex.stop();
C = Rolex.time();
cout << "The Time was : " << C << " seconds.";
cout << "\n(Press any key to continue...)";
getch();
clearviewport();
gotoxy(2,2);
cout << "\nThe Direct Method : " << A;
cout << "\nBresenham's Method : " << B;
cout << "\nThe DDA Method : " << C;
double Z;
Z = min(A,B);
Z = min(C,Z);
if ( Z == A ) cout << "\n\nThe Winner is the Direct Method! ";
if ( Z == B ) cout << "\n\nThe Winner is the Bresenham Method! ";
if ( Z == C ) cout << "\n\nThe Winner is the DDA Method! ";
cout << "\n\n\n\nPress any Key to end the Program";
getch();
closegraph();
} // end of prog
![]()
// Graph04 The PolyLine for a mansion.....
//
#include <iostream.h>
#include <conio.h>
#include "larslgws.h"
#include "larsfigs.h"
LogicalWorkstation LW(1);
void main(void)
{
clearviewport();
cout << "\n This is the Mainsion Program using the \n";
cout << "PolyLine function from our graphics library.\n\n";
cout << "Press Any Key to See the Mansion.\n";
getch();
Point V1(1000.0,3000.0,7,FALSE,"qa",FALSE);
Point V2(1000.0,1000.0,7,FALSE,"qa",FALSE);
Point V3(5400.0,1000.0,7,FALSE,"qa",FALSE);
Point V4(5400.0,3000.0,7,FALSE,"qa",FALSE);
Point V5(1000.0,3000.0,7,FALSE,"qa",FALSE);
Point V6(1300.0,3700.0,7,FALSE,"qa",FALSE);
Point V7(5100.0,3700.0,7,FALSE,"qa",FALSE);
Point V8(5400.0,3000.0,7,FALSE,"qa",FALSE);
Point ThePoints[] = { V1, V2, V3, V4, V5, V6, V7, V8 };
PolyLine D(ThePoints,8,BROWN,TRUE);
D.Display();
for ( int i = 0; i < 4000; i+=200 )
{
Point W1(1250.0+i,2500.0,7,FALSE,"qa",FALSE);
Point W2(1350.0+i,2500.0,7,FALSE,"qa",FALSE);
Point W3(1350.0+i,2900.0,7,FALSE,"qa",FALSE);
Point W4(1250.0+i,2900.0,7,FALSE,"qa",FALSE);
Point W5(1250.0+i,2500.0,7,FALSE,"qa",FALSE);
Point MorePoints[] = { W1, W2, W3, W4, W5, };
PolyLine D2(MorePoints,5,RED,TRUE);
D2.Display();
}
for ( int k = 0; k < 4000; k+=200 )
{
Point W1(1250.0+k,1800.0,7,FALSE,"qa",FALSE);
Point W2(1350.0+k,1800.0,7,FALSE,"qa",FALSE);
Point W3(1350.0+k,2200.0,7,FALSE,"qa",FALSE);
Point W4(1250.0+k,2200.0,7,FALSE,"qa",FALSE);
Point W5(1250.0+k,1800.0,7,FALSE,"qa",FALSE);
Point MorePoints[] = { W1, W2, W3, W4, W5, };
PolyLine D2(MorePoints,5,RED,TRUE);
D2.Display();
}
for ( int j = 0; j < 1600; j+=200 )
{
Point W1(1250.0+j,1100.0,7,FALSE,"qa",FALSE);
Point W2(1350.0+j,1100.0,7,FALSE,"qa",FALSE);
Point W3(1350.0+j,1500.0,7,FALSE,"qa",FALSE);
Point W4(1250.0+j,1500.0,7,FALSE,"qa",FALSE);
Point W5(1250.0+j,1100.0,7,FALSE,"qa",FALSE);
Point MorePoints[] = { W1, W2, W3, W4, W5, };
PolyLine D2(MorePoints,5,RED,TRUE);
D2.Display();
}
for ( int l = 0; l < 1600; l+=200 )
{
Point W1(3650.0+l,1100.0,7,FALSE,"qa",FALSE);
Point W2(3750.0+l,1100.0,7,FALSE,"qa",FALSE);
Point W3(3750.0+l,1500.0,7,FALSE,"qa",FALSE);
Point W4(3650.0+l,1500.0,7,FALSE,"qa",FALSE);
Point W5(3650.0+l,1100.0,7,FALSE,"qa",FALSE);
Point MorePoints[] = { W1, W2, W3, W4, W5, };
PolyLine D2(MorePoints,5,RED,TRUE);
D2.Display();
}
Point Z1(3350.0,1000.0,7,FALSE,"qa",FALSE);
Point Z2(3350.0,1600.0,7,FALSE,"qa",FALSE);
Point Z3(3050.0,1600.0,7,FALSE,"qa",FALSE);
Point Z4(3050.0,1000.0,7,FALSE,"qa",FALSE);
Point DoorPoints[] = { Z1, Z2, Z3, Z4 };
PolyLine Door(DoorPoints,4,MAGENTA,TRUE);
Door.Display();
Point WW1(3350.0,1000.0,12,FALSE,"qa",FALSE);
Point WW2(3500.0,1.0,12,FALSE,"qa",FALSE);
LineSeg CC(WW1,WW2,2);
CC.Display();
Point WW3(3050.0,1000.0,12,FALSE,"qa",FALSE);
Point WW4(2900.0,1.0,12,FALSE,"qa",FALSE);
LineSeg CC2(WW3,WW4,2);
CC2.Display();
Point Grass1(01.0,1500.0,12,FALSE,"qa",FALSE);
Point Grass2(1000.0,1500.0,12,FALSE,"qa",FALSE);
LineSeg Back1(Grass1,Grass2,2);
Back1.Display();
Point Grass3(5400.0,1500.0,12,FALSE,"qa",FALSE);
Point Grass4(6399.0,1500.0,12,FALSE,"qa",FALSE);
LineSeg Back2(Grass3,Grass4,2);
Back2.Display();
getch();
} // end of program
![]()
// Graph 05 The Regular Polygon Program......
//
// Microcomputer Graphics...
//
#include <iostream.h>
#include <conio.h>
#include "larslgws.h"
#include "larsfigs.h"
LogicalWorkstation LW(1);
void main(void)
{
clearviewport();
setcolor(RED);
settextstyle(GOTHIC_FONT,HORIZ_DIR,2);
outtextxy(30,30,"Press any key to view");
outtextxy(30,60,"the fifteen sided,color,");
outtextxy(30,90,"Regular Polygon !!!");
getch();
// I just basterdized the Polygon::Display() code. It changes
// the color in the vertices loop.
RegularPolygon Lars(3200.0,2400.0,1000.0,15,4,TRUE,Hollow,1,1);
Lars.Display();
setcolor(YELLOW);
outtextxy(50,420,"That's all Folks!! press any key to end the program.");
getch();
closegraph();
}
![]()
// The Ellipse Program ... Make three Cylinders....
//
// MicroComputer Graphics....
//
#include <iostream.h>
#include <conio.h>
#include "larsfigs.h"
#include "larslgws.h"
LogicalWorkstation LW(1);
void main(void)
{
// The Ellipse Program.....
// Make three cylinders.....
// Ellipse Number One.....
clearviewport();
setcolor(5);
// Make the Ellipses
Ellipse E1(1000,1000,400,175,4,TRUE,Hollow,1,0);
Ellipse E2(1000,3000,400,175,4,TRUE,Hollow,1,0);
E1.BresEllipse();
E2.BresEllipse();
// Make the joining Lines....
Point W1(600.0,1000.0,4,FALSE,"qa",FALSE);
Point W2(600.0,3000.0,4,FALSE,"qa",FALSE);
Point W3(1400.0,1000.0,4,FALSE,"qa",FALSE);
Point W4(1400.0,3000.0,4,FALSE,"qa",FALSE);
LineSeg C(W1,W2,4);
LineSeg D(W3,W4,4);
C.Display();
D.Display();
// Put out the message...
setcolor(BLUE);
outtextxy(50,430,"Press Any Key For the Next Cylinder..");
getch();
// Ellipse Number Two.....
// Make the Ellipses
Ellipse EE1(3200,2000,1000,200,1,TRUE,Hollow,1,0);
Ellipse EE2(3200,4500,1000,200,1,TRUE,Hollow,1,0);
EE1.BresEllipse();
EE2.BresEllipse();
// Make the joining Lines....
Point WW1(2200.0,2000.0,4,FALSE,"qa",FALSE);
Point WW2(2200.0,4500.0,4,FALSE,"qa",FALSE);
Point WW3(4200.0,2000.0,4,FALSE,"qa",FALSE);
Point WW4(4200.0,4500.0,4,FALSE,"qa",FALSE);
LineSeg CC(WW1,WW2,1);
LineSeg DD(WW3,WW4,1);
CC.Display();
DD.Display();
// Put out the message...
setcolor(YELLOW);
outtextxy(50,430,"Press Any Key For the Next Cylinder..");
getch();
// Ellipse Number Three.....
// Make the Ellipses
Ellipse EEE1(5300,500,300,70,14,TRUE,Hollow,1,0);
Ellipse EEE2(5300,4000,300,70,14,TRUE,Hollow,1,0);
EEE1.BresEllipse();
EEE2.BresEllipse();
// Make the joining Lines....
Point WWW1(5600.0,4000.0,4,FALSE,"qa",FALSE);
Point WWW2(5600.0,500.0,4,FALSE,"qa",FALSE);
Point WWW3(5000.0,500.0,4,FALSE,"qa",FALSE);
Point WWW4(5000.0,4000.0,4,FALSE,"qa",FALSE);
LineSeg CCC(WWW1,WWW2,14);
LineSeg DDD(WWW3,WWW4,14);
CCC.Display();
DDD.Display();
// Put out the message...
setcolor(RED);
outtextxy(50,440,"Press Any Key To End The Program. ");
getch();
closegraph();
} // end of the program
![]()
Tried to Guess what a test would be.....
// Lars Sorensen Microcomputer Graphics.....
// shell for test 3 for Graphics....
// Prepared the day of the test at 2:45am
// Procrastination is a bad thing.....
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <graphics.h>
#include <process.h>
#include <ldate.h>
#include <ltime.h>
#include "larslgws.h"
#include "larsfigs.h"
LogicalWorkstation LW(1);
void main(void)
{
int Choice;
while (1)
{ //while
clearviewport();
gotoxy(1,1);
cout << " Test 3 Graphics Menu \n\n";
cout << " 1. Display a Point.\n";
cout << " 2. Display a Circle.\n";
cout << " 3. Display a LineSeg.\n";
cout << " 4. Display a PolyLine.\n";
cout << " 5. Display a Polygon. \n";
cout << " 6. Display a Regular Polygon.\n";
cout << " 7. Display a Polar Circle.\n";
cout << " 8. Display a 3 Leafed Rose.\n";
cout << " 9. Display a 15 Leafed Rose.\n";
cout << "10. Display LineSeg with new screen limits.\n";
cout << "11. Display a PolyLine from a file.\n";
cout << "12. Display an Ellipse.\n";
cout << "13. Display a Bresenham Circle.\n";
cout << "14. Display a Limacon.\n";
cout << "15. Display all Polar Curves.\n";
cout << " 0. Exit\n\n";
cout << "Enter The Choice : ";
cin >> (Choice);
switch (Choice) {
case 1 : // Display a Point
{
float InX, InY;
int Color;
clearviewport();
gotoxy(1,1);
cout << "Displaying a Point\n\n";
cout << "Please Enter the X Coordinate (Float) :";
cin >> InX;
cout << "Please Enter the Y Coordinate (Float) :";
cin >> InY;
cout << "Please Enter the Color (Int) :";
cin >> Color;
clearviewport();
Point Pnt1(InX,InY,Color,FALSE,"qa",FALSE);
Pnt1.Display();
outtextxy(10,10,"Display a Point");
getch();
break;
}
case 2 : // Display a Circle
{
float InX, InY, Radius;
int Color;
clearviewport();
gotoxy(1,1);
cout << "Displaying a Circle\n\n";
cout << "Please Enter the X Coordinate (Float) :";
cin >> InX;
cout << "Please Enter the Y Coordinate (Float) :";
cin >> InY;
cout << "Please Enter the Radius (Float) :";
cin >> Radius;
cout << "Please Enter the Color (Int) :";
cin >> Color;
clearviewport();
Circle Cir1(InX,InY,Radius,Color,Filled,0,0);
Cir1.Display();
outtextxy(10,10,"Display a Circle");
getch();
break;
}
case 3 : // Display a LineSeg
{
float InX1, InY1, InX2, InY2;
int Color;
clearviewport();
gotoxy(1,1);
cout << "Displaying a Line Segment\n\n";
cout << "Please Enter the X1 Coordinate (Float) :";
cin >> InX1;
cout << "Please Enter the Y1 Coordinate (Float) :";
cin >> InY1;
cout << "Please Enter the X2 Coordinate (Float) :";
cin >> InX2;
cout << "Please Enter the Y2 Coordinate (Float) :";
cin >> InY2;
cout << "Please Enter the Color (Int) :";
cin >> Color;
clearviewport();
Point End1(InX1,InY1,12,FALSE,"qa",FALSE);
Point End2(InX2,InY2,12,FALSE,"qa",FALSE);
LineSeg Line1(End1,End2,Color);
Line1.Display();
outtextxy(10,10,"Display a Line Segment");
getch();
break;
}
case 4 : // Display a PolyLine
{
Point ThePolyPoints[55];
int NumVerts, Color, i;
clearviewport();
gotoxy(1,1);
cout << "Displaying a Polyline\n\n";
cout << "Enter the Number of Vertices (Int / 55 Limit ) : ";
cin >> NumVerts;
cout << "Enter the Color (Int) : ";
cin >> Color;
for (i = 0 ; i < NumVerts; i++ )
{
float InX,InY;
cout << "Enter the X Coordinate for Vert " << i+1 << " : ";
cin >> InX;
cout << "Enter the Y Coordinate for Vert " << i+1 << " : ";
cin >> InY;
ThePolyPoints[i].SetXY(InX,InY);
}
clearviewport();
PolyLine PolyLine1(ThePolyPoints,NumVerts,Color,TRUE);
PolyLine1.Display();
outtextxy(10,10,"Display a Polyline");
getch();
break;
}
case 5 : // Display a Polygon
{
Point ThePolyPoints[55];
int NumVerts, Color, i;
clearviewport();
gotoxy(1,1);
cout << "Displaying a Polygon \n\n";
cout << "Enter the Number of Vertices (Int / 55 Limit ) : ";
cin >> NumVerts;
cout << "Enter the Color (Int) : ";
cin >> Color;
for (i = 0 ; i < NumVerts; i++ )
{
float InX,InY;
cout << "Enter the X Coordinate for Vert " << i+1 << " : ";
cin >> InX;
cout << "Enter the Y Coordinate for Vert " << i+1 << " : ";
cin >> InY;
ThePolyPoints[i].SetXY(InX,InY);
}
clearviewport();
Polygon Polygon1(ThePolyPoints,NumVerts,Color,TRUE,Hollow,1,4,4000.0,1000.0);
Polygon1.Display();
outtextxy(10,10,"Display a Polygon");
getch();
break;
}
case 6 : // Regular Polygon
{
float InX,InY,Size;
int Color,NumVerts;
clearviewport();
gotoxy(1,1);
cout << "Displaying a Regular Polygon\n\n";
cout << "Please Enter the X Coordinate (Float) :";
cin >> InX;
cout << "Please Enter the Y Coordinate (Float) :";
cin >> InY;
cout << "Please Enter the Size (Float) :";
cin >> Size;
cout << "Please Enter the Number of Vertices (Int) :";
cin >> NumVerts;
cout << "Please Enter the Color (Int) :";
cin >> Color;
clearviewport();
RegularPolygon RPoly1(InX,InY,Size,NumVerts,Color,TRUE,Hollow,1,1);
RPoly1.Display();
outtextxy(10,10,"Displaying a Regular Polygon");
getch();
break;
}
case 7 : // Polar Circle
{
float InX, InY, Radius;
int Color;
clearviewport();
gotoxy(1,1);
cout << "Displaying a Polar Circle\n\n";
cout << "Please Enter the X Coordinate (Float) :";
cin >> InX;
cout << "Please Enter the Y Coordinate (Float) :";
cin >> InY;
cout << "Please Enter the Radius (Float) :";
cin >> Radius;
cout << "Please Enter the Color (Int) :";
cin >> Color;
clearviewport();
Circle Cir1(InX,InY,Radius,Color,Filled,0,0);
Cir1.PolarCircle();
outtextxy(10,10,"Display a Polar Circle");
getch();
break;
}
case 8 : // 3 Sided Rose
{
float InX, InY, Size;
int Color;
clearviewport();
gotoxy(1,1);
cout << "Displaying a 3 Sided Rose\n\n";
cout << "Please Enter the X Coordinate (Float) :";
cin >> InX;
cout << "Please Enter the Y Coordinate (Float) :";
cin >> InY;
cout << "Please Enter the Size (Float) :";
cin >> Size;
cout << "Please Enter the Color (Int) :";
cin >> Color;
clearviewport();
Rose Rose1(InX,InY,Size,TRUE,Color,Ros,3.0);
Rose1.Display();
outtextxy(10,10,"Display a 3 Sided Rose");
getch();
break;
}
case 9 : // 15 Sided Rose
{
float InX, InY, Size;
int Color;
clearviewport();
gotoxy(1,1);
cout << "Displaying a 15 Sided Rose\n\n";
cout << "Please Enter the X Coordinate (Float) :";
cin >> InX;
cout << "Please Enter the Y Coordinate (Float) :";
cin >> InY;
cout << "Please Enter the Size (Float) :";
cin >> Size;
cout << "Please Enter the Color (Int) :";
cin >> Color;
clearviewport();
Rose Rose1(InX,InY,Size,TRUE,Color,Ros,15.0);
Rose1.Display();
outtextxy(10,10,"Display a 15 Sided Rose");
getch();
break;
}
case 10 :
{
float XMax, YMax;
float InX1, InY1, InX2, InY2;
int Color;
clearviewport();
gotoxy(1,1);
cout << "Resize the Screen\n\n";
cout << "Enter the new Max size for X Coords :";
cin >> XMax;
cout << "Enter the new Max size for Y Coords :";
cin >> YMax;
LW.SetWindow(1,0,XMax-1,0,YMax-1);
cout << "Displaying a Line Segment w/ new Coords.\n\n";
cout << "Please Enter the X1 Coordinate (Float) :";
cin >> InX1;
cout << "Please Enter the Y1 Coordinate (Float) :";
cin >> InY1;
cout << "Please Enter the X2 Coordinate (Float) :";
cin >> InX2;
cout << "Please Enter the Y2 Coordinate (Float) :";
cin >> InY2;
cout << "Please Enter the Color (Int) :";
cin >> Color;
clearviewport();
Point End1(InX1,InY1,12,FALSE,"qa",FALSE);
Point End2(InX2,InY2,12,FALSE,"qa",FALSE);
LineSeg Line1(End1,End2,Color);
Line1.Display();
outtextxy(10,10,"Display a Line Segment");
getch();
LW.SetWindow(1,0,6399,0,4799);
break;
}
case 11 :
{
char* thefile;
clearviewport();
gotoxy(1,1);
cout << "Read a Poly from a file\n\n";
cout << "Enter the path of the file :";
cin >> thefile;
clearviewport();
outtextxy(10,10,"Polyline read from a file!!");
PolyLine Poly2(thefile);
Poly2.Display();
getch();
break;
}
case 12 : // Ellipse
{
float InX, InY, Width, Height;
int Color;
clearviewport();
gotoxy(1,1);
cout << "Displaying an Ellipse\n\n";
cout << "Please Enter the X Coordinate (Float) :";
cin >> InX;
cout << "Please Enter the Y Coordinate (Float) :";
cin >> InY;
cout << "Please Enter the Width (Float) :";
cin >> Width;
cout << "Please Enter the Height (Float) :";
cin >> Height;
cout << "Please Enter the Color (Int) :";
cin >> Color;
clearviewport();
Ellipse Ell1(InX,InY,Width,Height,Color,TRUE,Hollow,1,0);
Ell1.BresEllipse();
outtextxy(10,10,"Display an Ellipse");
getch();
break;
}
case 13 : // Bresenhams Circle
{
float InX, InY, Radius;
int Color;
clearviewport();
gotoxy(1,1);
cout << "Displaying an Ellipse\n\n";
cout << "Please Enter the X Coordinate (Float) :";
cin >> InX;
cout << "Please Enter the Y Coordinate (Float) :";
cin >> InY;
cout << "Please Enter the Radius (Float) :";
cin >> Radius;
cout << "Please Enter the Color (Int) :";
cin >> Color;
clearviewport();
Ellipse Ell1(InX,InY,Radius,Radius,Color,TRUE,Hollow,1,0);
Ell1.BresEllipse();
outtextxy(10,10,"Display a Bresenham Circle");
getch();
break;
}
case 14 : // Limacon
{
float InX, InY, Size;
int Color;
clearviewport();
gotoxy(1,1);
cout << "Displaying a Limacon\n\n";
cout << "Please Enter the X Coordinate (Float) :";
cin >> InX;
cout << "Please Enter the Y Coordinate (Float) :";
cin >> InY;
cout << "Please Enter the Size (Float) :";
cin >> Size;
cout << "Please Enter the Color (Int) :";
cin >> Color;
clearviewport();
Limacon Lima1(InX,InY,Size,500.0,TRUE,Color,Lima);
Lima1.Display();
outtextxy(10,10,"Display a Limacon");
getch();
break;
}
case 15 :
{
clearviewport();
PolarCurve Lars35(3200.0,2400.0,500.0,TRUE,2,Ros);
Lars35.PolarCurveMenu();
getch();
break;
}
case 0 : exit(0);
} //switch
} //while
}
![]()
//
// Educated guess at the Graphics final exam stuff...
//
#include <iostream.h>
#include <conio.h>
#include "larslgws.h"
#include "larsfigs.h"
LogicalWorkstation LW(1);
void main(void)
{
// The Beginning of the Christmas Code.
clearviewport();
outtextxy(2,2,"Merry Christmas Everybody !!");
// The Tree
Point P1(4000.0,1200.0,7,FALSE,"qa",FALSE);
Point P2(5600.0,1200.0,7,FALSE,"qa",FALSE);
Point P3(4800.0,4200.0,7,FALSE,"qa",FALSE);
Point MorePoints[] = { P1, P2, P3 };
Polygon E(MorePoints,3,2,TRUE,Hollow,1,4,4000.0,1000.0);
E.Display();
setfillstyle(SOLID_FILL, GREEN);
floodfill(480,350,GREEN);
// The Tree Trunk
Point Q1(4600.0,1200.0,7,FALSE,"qa",FALSE);
Point Q2(5000.0,1200.0,7,FALSE,"qa",FALSE);
Point Q3(5000.0,500.0,7,FALSE,"qa",FALSE);
Point Q4(4600.0,500.0,7,FALSE,"qa",FALSE);
Point EvenMorePoints[] = { Q1, Q2, Q3, Q4 };
Polygon T(EvenMorePoints,4,6,TRUE,Hollow,1,4,2000.0,3000.0);
T.Display();
setfillstyle(SOLID_FILL, BROWN);
floodfill(480,370,BROWN);
// The Christmas Star...
Rose Lars33(4800.0,4200.0,150.0,TRUE,4,Ros,4.0);
Lars33.Display();
// The Balls on the Tree
Circle A(4800.0,3500.0,80.0,1,Filled,1,1);
Circle Z(4500.0,1600.0,80.0,4,Filled,1,4);
Circle Y(5100.0,1700.0,80.0,15,Filled,1,15);
Circle Z33(4350.0,2000.0,80.0,5,Filled,1,5);
Circle Y33(5200.0,2200.0,80.0,14,Filled,1,14);
Circle X(4700.0,2400.0,80.0,3,Filled,1,3);
Circle W(4950.0,2800.0,80.0,10,Filled,1,10);
Circle N(4750.0,3100.0,80.0,15,Filled,1,15);
A.Display();
Z.Display();
Y.Display();
Z33.Display();
Y33.Display();
X.Display();
W.Display();
N.Display();
// The Gift Under the tree
Point Z1(3700.0,800.0,7,FALSE,"qa",FALSE);
Point Z2(4300.0,800.0,7,FALSE,"qa",FALSE);
Point Z3(4300.0,500.0,7,FALSE,"qa",FALSE);
Point Z4(3700.0,500.0,7,FALSE,"qa",FALSE);
Point EvenMorePoints2[] = { Z1, Z2, Z3, Z4 };
Polygon T2(EvenMorePoints2,4,1,TRUE,Hollow,1,4,2000.0,3000.0);
T2.Display();
setfillstyle(SOLID_FILL, WHITE);
floodfill(400,420,BLUE);
// The Ribbon for the gift and the bow
Point Pnt1(3700.0,650.0,12,FALSE,"qa",FALSE);
Point Pnt2(4300.0,650.0,12,FALSE,"qa",FALSE);
LineSeg Line1(Pnt1,Pnt2,4);
Line1.Display();
Point Pnt3(4000.0,500.0,12,FALSE,"qa",FALSE);
Point Pnt4(4000.0,800.0,12,FALSE,"qa",FALSE);
LineSeg Line2(Pnt3,Pnt4,4);
Line2.Display();
Rose Bow1(4000.0,800.0,200.0,TRUE,5,Ros,2.0);
Bow1.Display();
getch();
// Thats the end of the Christmas code.
// Make the Ellipses
Ellipse E1(1000,1000,400,175,2,TRUE,Hollow,1,0);
Ellipse E2(1000,3000,400,175,2,TRUE,Hollow,1,0);
E1.BresEllipse();
E2.BresEllipse();
// Make the joining Lines....
Point W1(600.0,1000.0,4,FALSE,"qa",FALSE);
Point W2(600.0,3000.0,4,FALSE,"qa",FALSE);
Point W3(1400.0,1000.0,4,FALSE,"qa",FALSE);
Point W4(1400.0,3000.0,4,FALSE,"qa",FALSE);
LineSeg C(W1,W2,2);
LineSeg D(W3,W4,2);
C.Display();
D.Display();
// Put out the message...
getch();
}
![]()