I've tried hard to solve this but I still couldn't make it right.

``````#include <graphics.h>
#include <ctype.h>
#include <math.h>
#include <conio.h>
#include <stdio.h>
#include <process.h>

int check(int,char);
void Initialize(void);void drawEllipse1(int color);
void drawEllipse1(int color);
void drawEllipse2(int color);
void main() {
int color, color1;
char ch;

Initialize();
ch = 'R';color1=1;color=1;
do {
if (ch == 'R' || ch == 'L') {
if (ch == 'L') {
if (color1 == 4) color = 1;
else color = ++color1;
}
drawEllipse1(color);
color1 = color;
color = check(color, ch);
drawEllipse2(color);
}
ch = toupper(getche());
} while (ch!='X');
closegraph();
}

void Initialize(void) {
int driver = DETECT,mode, errorcode;
initgraph(&driver,&mode, "c:\\tc\\bgi");
errorcode = graphresult();
if (errorcode != grOk) {
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("<Copy egavga.bgi to c:\\tc\\bgi>");
getch();
exit(1);
}
}

void drawEllipse1(int color) {
setfillstyle(SOLID_FILL,color);
setcolor(color);
fillellipse((getmaxx()/2),(getmaxy()/2), 25, 50);
}

void drawEllipse2(int color) {
setfillstyle(SOLID_FILL,color);
setcolor(color);
fillellipse(((getmaxx()/2)),(getmaxy() / 2),50,25);
}

int check(int color,char ch) {
if (ch == 'R') {
if (color < 4)
++color;
else if (color == 4)
color = 1;
}
if (ch == 'L') {
if (color == 4)
color = 1;
else color++;
}
return color;
}
``````

## All 3 Replies

If I'm not mistaken, fillellipse draws standard (unrotated) ellipse, and there's nothing you can do to rotate it. You could try to draw your own ellipse, and then do something with that...

Indeed, That's what I want to say. I've also tried "void far ellipse(int x, int y, int stangle, int endangle, int xradius, int yradius);" function. I mean ellipse(x,y,a,b,r,n); But it just can't help and then I try to search more, there's nothing. What should I do. I should complete this before tomorow. Do you have a function that can handle it?

Hmm....

code tags, there a nice thing
[code=c] [/code]

Also this looks like C to me not C++
Could just be me but i'm quite sure its not C++

Chris

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.