国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C++ > 正文

C語言fillpoly函數詳解

2020-05-23 14:13:51
字體:
來源:轉載
供稿:網友

在C語言中,fillpoly函數的功能是畫一個多邊形,并且把多邊形填充。填充邊框所定義的多邊形的內部。fillpoly 函數的用法:void far fillpoly(int numpoints, int far *polypoints);。

C語言中,fillpoly函數的功能是畫一個多邊形,今天我們就來學習學習。

C語言fillpoly函數:

填充一個多邊形

函數名:

fillpoly

功 能:

畫并填充一個多邊形

頭文件:#

include

原 型:

fillpoly(int numpoints, int far *polypoints);

參數說明:

numpoints 為多邊形的邊數;far *polypoints 為存儲各頂點坐標的數組,每兩個一組表示一個頂點的 X 和 Y 坐標。

實例代碼:

 

 
  1. #include <graphics.h> 
  2. #include <stdlib.h> 
  3. #include <stdio.h> 
  4. #include <conio.h> 
  5.  
  6. int main(void
  7. /* request auto detection */ 
  8. int gdriver = DETECT, gmode, errorcode; 
  9. int i, maxx, maxy; 
  10.  
  11. /* our polygon array */ 
  12. int poly[8]; 
  13.  
  14. /* initialize graphics, local variables */ 
  15. initgraph(&gdriver, &gmode, ""); 
  16.  
  17. /* read result of initialization */ 
  18. errorcode = graphresult(); 
  19. if (errorcode != grOk) 
  20. /* an error occurred */ 
  21. printf("Graphics error: %s/n", grapherrormsg(errorcode)); 
  22. printf("Press any key to halt:"); 
  23. getch(); 
  24. exit(1); 
  25. /* terminate with an error code */ 
  26.  
  27. maxx = getmaxx(); 
  28. maxy = getmaxy(); 
  29.  
  30. poly[0] = 20; /* 1st vertext */ 
  31. poly[1] = maxy / 2; 
  32.  
  33. poly[2] = maxx - 20; /* 2nd */ 
  34. poly[3] = 20; 
  35.  
  36. poly[4] = maxx - 50; /* 3rd */ 
  37. poly[5] = maxy - 20; 
  38.  
  39. /* 
  40. 4th vertex. fillpoly automatically 
  41. closes the polygon. 
  42. */ 
  43. poly[6] = maxx / 2; 
  44. poly[7] = maxy / 2; 
  45.  
  46. /* loop through the fill patterns */ 
  47. for (i=EMPTY_FILL; i<USER_FILL; i++) 
  48. /* set fill pattern */ 
  49. setfillstyle(i, getmaxcolor()); 
  50.  
  51. /* draw a filled polygon */ 
  52. fillpoly(4, poly); 
  53.  
  54. getch(); 
  55.  
  56. /* clean up */ 
  57. closegraph(); 
  58. return 0; 

注:fillpoly 函數是 TC 編譯環境下的函數,VC 中無法使用。

以上就是關于fillpoly函數填充多邊形功能的實現代碼,希望對大家的學習有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汪清县| 宜城市| 临泽县| 铜鼓县| 新兴县| 昌乐县| 临沂市| 枣庄市| 灯塔市| 北京市| 大安市| 罗甸县| 吐鲁番市| 嘉兴市| 惠安县| 安陆市| 余干县| 南丰县| 玉环县| 云安县| 宁城县| 金昌市| 类乌齐县| 盐源县| 乾安县| 鹰潭市| 巫溪县| 遂昌县| 临邑县| 巴楚县| 中阳县| 嘉祥县| 华容县| 茶陵县| 屯门区| 博客| 石台县| 元朗区| 邢台县| 团风县| 泽州县|