[英]Draw ellipse into rectangle in C
以下C代碼將繪制一個矩形。 我知道如何繪制橢圓,但是如何將橢圓繪制到此矩形中?
#include<graphics.h>
#include<conio.h>
main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\TC\\BGI");
rectangle(100,100,200,200);
getch();
closegraph();
return 0;
}
假設您正在使用graphics.h
的ellipse
函數 ,則可以執行以下操作:
int left = 100;
int right = 200;
int top = 100;
int bottom = 200;
rectangle(left, top, right, bottom);
int x = (left + right) / 2;
int y = (top + bottom) / 2;
int start = 0;
int end = 360;
int xrad = (right - left) / 2;
int yrad = (bottom - top) / 2;
ellipse(x, y, start, end, xrad, yrad);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.