本實例繪製 20 個同心橢圓,長軸遞減、短軸遞增,形成動態視覺效果。
// Created by www.runoob.com on 15/11/9.
// Copyright © 2015年 菜鳥教程. All rights reserved.
//
#include "stdio.h"
#include "graphics.h"
#include "conio.h"
int main() {
int x = 360, y = 160, driver = VGA, mode = VGAHI;
int num = 20, i;
int top, bottom;
initgraph(&driver, &mode, "");
top = y - 30; bottom = y - 30;
for (i = 0; i < num; i++) {
ellipse(250, 250, 0, 360, top, bottom);
top -= 5; bottom += 5;
}
getch();
}
ellipse(x, y, stangle, endangle, xradius, yradius) 繪製橢圓弧,此處繪製完整橢圓(0-360度)。