當前位置:首頁 » 編程語言 » c語言的bar函數
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言的bar函數

發布時間: 2022-11-03 00:42:05

c語言的畫圖函數除了bar函數外還有哪些

與圖形有關的函數
GRAPHICS.H 庫文件

bar
【功能】畫出一條欄目。
【原型】void far bar(int left,int top,int right,int bottom)
【位置】graphics.hgraphics.h
【參見】bar3d,setfillstyle,rectangle
bar3d
【功能】畫出一條3-D欄目。
【原型】void far bar3d(int left,int top,int right,int bottom,int depth,int topflag)
【位置】graphics.h
【參見】bar
circle
【功能】以(x,y)為圓心按照指定的半徑畫出一個圓。
【原型】void far circle(int x,int y,int radius)
【位置】graphics.h
【參見】arc
cleardevice
【功能】清除圖形畫面。
【原型】void far cleardevice(void)
【位置】graphics.h
【參見】clearviewport
clearviewport
【功能】清除當前可視區域。
【原型】clearviewport(void)
【位置】graphics.h
【參見】setviewport,cleardevice
closegraph
【功能】關閉圖形系統。
【原型】void far closegraph(void)
【位置】graphics.h
【參見】initgraph
detecgraph
【功能】通過檢查硬體確定使用的圖形驅動程序和模式。
【原型】void far detectgraph(int far *graphdriver,int far *graphmode)
【位置】graphics.h
【參見】initgraph,graphresult
drawpoly
【功能】畫出一個多邊形的輪廓。
【原型】void far drawpoly(int numpoints,int far polypoints[])
【位置】graphics.h
【說明】polypoints中包括一共numpoints對數值。其中每一對都給出了多邊形中一個頂點的x和y值。
【參見】fillpoly
ellipse
【功能】畫出一條橢圓形的圓弧。
【原型】void far ellipse(int x,int y,int stangle,int endangle,int xradius,int yradius)
【位置】graphics.h
【說明】中心點在(x,y),stangle和endangle表示一角度為單位的起始角和終止角。Xradius和yradius表示水平軸和垂直軸。
【參見】arc,circle,fillellipse
fillellipose
【功能】畫出橢圓形圓弧,並填充。
【原型】void far fillllipse(int x,int y,int xradius,int yradius)
【位置】graphics.h
【說明】使用(x,y)作為中心點,然後使用當前的填充模式填充圓弧。Xradius和yradius表示水平軸和垂直軸。
【參見】arc,circle,ellipse,pieslice
fillpoly
【功能】畫出一個多邊形,並填充。
【原型】void far fillpoly(int numpoints,int far polypoints[])
【位置】graphics.h
【說明】polypoints中包含有numpoints對數值。其中每一對給出了多邊形一個頂點的x值和y值。
【參見】drawpoly,fill_patterns,floodfill,graphresult,setfillstyle
floodfill
【功能】填充一個有界區域范圍。
【原型】void far floodfill(int x,int y,int border)
【位置】graphics.h
【參見】drawpoly,fillpoly,fill_patterns,graphresult,setfillstyle
getarccoords
【功能】得到最後一次調用arc的坐標值。
【原型】void far getaerccoords(struct arccoordstype far *arccoords)
【位置】graphics.h
【參見】arc
getaspectratio
【功能】得到當前圖形模式的縱橫比。
【原型】void far getaspectratio(int far *xasp,int far *yasp)
【位置】graphics.h
【說明】are及類似函數使用縱橫比令圓圈更加圓,而不會像橢圓。Yasp應當為10000。當象素為<VGA>平方並且<10000時,xasp使用10000數值。
【參見】arc,setaspectratio
getbkcolor
【功能】返回當前背景顏色。
【原型】int far getbkcolor(void)
【位置】graphics.h
【參見】setbkcolor,getcolor,getpalette
getcolor
【功能】返回當前畫筆的顏色。
【原型】int far getcolor(void)
【位置】graphics.h
【參見】getbkcolor,setcolor,getmaxcolor,getpalette
getdefaultpalette
【功能】返回調色板定義結構。
【原型】struct palettetype *far getdefaultpalette(void)
【位置】graphics.h
【說明】返回一個指針,指向調用initgraph初始化時,當前驅動程序的默認調色板結構。
【參見】getpalette,initgraph
getdrivername
【功能】返回一個指針,指向當前圖形驅動程序的名稱。
【原型】char *far getdrivername(void)
【位置】graphics.h
【說明】返回的指針指向標識當前驅動器程序的字元串,從而可以探測到硬體適配器。
【參見】initgraph
getfillpattern
【功能】將用戶定義的填充模式復制到內存中。
【原型】void far getfillpattern(char far *pattern)
【位置】graphics.h
【參見】getfillsettings,setfillpattern,fill_patterns
getfillsettings
【功能】得到當前填充模式及其顏色的有關信息。
【原型】void far getfillsettings(struct fillsettingstype far *fillinfo)
【位置】graphics.h
【參見】floodfill, fillpoly, setfillstyple, pieslice, setfillpattern, bar3d, bar, getfillpattern
getgraphmode
【功能】返回當前圖形模式。
【原型】int far getgraphmode(void)
【位置】graphics.h
【說明】必須先調用initgraph或者setgraphmode。
【參見】setmoderange,restorectrtmode
getimage
【功能】將制定區域的點陣圖保存到內存中。
【原型】void far getimage(int left,int top,int right,int bottom,void far *bitmap)
【位置】graphics.h
【參見】imagesize,putimage

因為太多了,無法一一列出。比如下面的:
putimage

putpixel

rectangle

registerbgidriver

registerbgifont

restorecrtmode

sector

setactivepage

setallpalette

setaspectratio

setbkcolor

setcolor

setfillpattern

setfillstyle

setgraphbufsize

setgraphmode

setlinestyle

setpalette

setrgbcolor

setrgbpalette

settextjustify

settextstyle

setusercharsize

setviewport
setvisualpage

setwritemode

textheight

textwidth

建議你買本專業的書籍學習查看。

⑵ C語言中的棧、堆是什麼

C語言中的堆和棧都是一種數據項按序排列的數據結構。

棧就像裝數據的桶或箱子

我們先從大家比較熟悉的棧說起吧,它是一種具有後進先出性質的數據結構,也就是說後存放的先取,先存放的後取。

這就如同我們要取出放在箱子裡面底下的東西(放入的比較早的物體),我們首先要移開壓在它上面的物體(放入的比較晚的物體)。

堆像一棵倒過來的樹

而堆就不同了,堆是一種經過排序的樹形數據結構,每個結點都有一個值。

通常我們所說的堆的數據結構,是指二叉堆。堆的特點是根結點的值最小(或最大),且根結點的兩個子樹也是一個堆。

由於堆的這個特性,常用來實現優先隊列,堆的存取是隨意,這就如同我們在圖書館的書架上取書。

雖然書的擺放是有順序的,但是我們想取任意一本時不必像棧一樣,先取出前面所有的書,書架這種機制不同於箱子,我們可以直接取出我們想要的書。

(2)c語言的bar函數擴展閱讀:

關於堆和棧區別的比喻

使用棧就象我們去飯館里吃飯,只管點菜(發出申請)、付錢、和吃(使用),吃飽了就走,不必理會切菜、洗菜等准備工作和洗碗、刷鍋等掃尾工作,他的好處是快捷,但是自由度小。

使用堆就象是自己動手做喜歡吃的菜餚,比較麻煩,但是比較符合自己的口味,而且自由度大。

參考資料來源:網路-堆棧



⑶ C語言中的圖形函數有哪些

一) 像素函數
putpiel() 畫像素點函數
getpixel()返回像素色函數
(二) 直線和線型函數
line() 畫線函數
lineto() 畫線函數
linerel() 相對畫線函數
setlinestyle() 設置線型函數
getlinesettings() 獲取線型設置函數
setwritemode() 設置畫線模式函數
(三)、多邊形函數
rectangle() 畫矩形函數
bar() 畫條函數
bar3d() 畫條塊函數
drawpoly() 畫多邊形函數
(四)、 圓、弧和曲線函數
getaspectratio()獲取縱橫比函數
circle()畫圓函數
arc() 畫圓弧函數
ellipse()畫橢圓弧函數
fillellipse() 畫橢圓區函數
pieslice() 畫扇區函數
sector() 畫橢圓扇區函數
getarccoords()獲取圓弧坐標函數
(五)、 填充函數
setfillstyle() 設置填充圖樣和顏色函數
setfillpattern() 設置用戶圖樣函數
floodfill() 填充閉域函數
fillpoly() 填充多邊形函數
getfillsettings() 獲取填充設置函數
getfillpattern() 獲取用戶圖樣設置函數
(六)、圖像函數
imagesize() 圖像存儲大小函數
getimage() 保存圖像函數
putimage() 輸出圖像函數

⑷ C語言程序里"BAR"是什麼意思

函數名: bar
功 能: 畫一個二維條形圖
用 法: void far bar(int left, int top, int right, int bottom);
程序例:

#include
#include
#include
#include

int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy, i;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}

midx = getmaxx() / 2;
midy = getmaxy() / 2;

/* loop through the fill patterns */
for (i=SOLID_FILL; i
{
/* set the fill style */
setfillstyle(i, getmaxcolor());

/* draw the bar */
bar(midx-50, midy-50, midx+50,
midy+50);

getch();
}

/* clean up */
closegraph();
return 0;
}

⑸ c語言 函數名: bar3d 怎麼用

bar3d是Turbo C工具中繪制長方體(也可理解為繪制三維條形圖)的一個圖形函數。其基本語法如下:

bar3d(int left, int top, int right, int bottom, int depth, int topflag);

其中:int left, int top構成第一個坐標點,即屏幕中長方體前面(即離我們最近的長方形)左上角的一個點;

int right, int bottom構成第二個坐標點,即屏幕中長方體前面(即離我們最近的長方形)右下角的一個點;

由以上兩個坐標點就可以確定一個長方形,然後結合int depth(用於確定長方體的厚度,即長方體前後兩個面的間距),就可以完全確定長方體的形狀。

int topflag 用於對長方體的頂部顯示方式。

舉例:例如在Turbo C++工具中編寫的C程序:

# include <graphics.h>

# include <stdio.h>

void main()

{

int graphdriver=DETECT, graphmode;

initgraph(&graphdriver,&graphmode,"C:\TURBOC3\BGI"); //*圖形系統初始化*/

bar3d(0,0,250,250,10,1);

getch() ;

closegraph(); // 關閉圖形模式//

}

其運行結果為:


運行結果

⑹ C語言中的顏色和邊框的函數怎麼來運用···

if(c=='-')
{
if(strcmp(str2,"")==0) /*如果str2為空,說明是負號,而不是減號*/
flag=-1; /*設置負數標志*/
else
{
num1=atof(str2); /*將第二個操作數轉換為浮點數*/
strcpy(str2,""); /*將str2清空*/
act=2; /*做計算減法標志值*/
setfillstyle(SOLID_FILL,color+3);
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*畫矩形*/
outtextxy(5*width,height,"0."); /*顯示字元串*/
}
}
if(c=='*')
{
num1=atof(str2); /*將第二個操作數轉換為浮點數*/
strcpy(str2,""); /*將str2清空*/
act=3; /*做計算乘法標志值*/
setfillstyle(SOLID_FILL,color+3); bar(2*width+width/2,height/2,15*width/2,3*height/2);
outtextxy(5*width,height,"0."); /*顯示字元串*/
}
if(c=='/')
{
num1=atof(str2); /*將第二個操作數轉換為浮點數*/
strcpy(str2,""); /*將str2清空*/
act=4; /*做計算除法標志值*/
setfillstyle(SOLID_FILL,color+3);
bar(2*width+width/2,height/2,15*width/2,3*height/2);
outtextxy(5*width,height,"0."); /*顯示字元串*/
}
if(c=='^')
{
num1=atof(str2); /*將第二個操作數轉換為浮點數*/
strcpy(str2,""); /*將str2清空*/
act=5; /*做計算乘方標志值*/
setfillstyle(SOLID_FILL,color+3); /*設置用淡綠色實體填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*畫矩形*/
outtextxy(5*width,height,"0."); /*顯示字元串*/
}
if(c=='%')
{
num1=atof(str2); /*將第二個操作數轉換為浮點數*/
strcpy(str2,""); /*將str2清空*/
act=6; /*做計算模運算乘方標志值*/
setfillstyle(SOLID_FILL,color+3); /*設置用淡綠色實體填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*畫矩形*/
outtextxy(5*width,height,"0."); /*顯示字元串*/
}
if(c=='=')
{
num2=atof(str2); /*將第二個操作數轉換為浮點數*/
switch(act) /*根據運算符號計算*/
{
case 1:result=num1+num2;break; /*做加法*/
case 2:result=num1-num2;break; /*做減法*/
case 3:result=num1*num2;break; /*做乘法*/
case 4:result=num1/num2;break; /*做除法*/
case 5:result=pow(num1,num2);break; /*做x的y次方*/
case 6:result=fmod(num1,num2);break; /*做模運算*/
}
setfillstyle(SOLID_FILL,color+3); /*設置用淡綠色實體填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*覆蓋結果區*/
sprintf(temp,"%f",result); /*將結果保存到temp中*/
outtextxy(5*width,height,temp); /*顯示結果*/
}
if(c=='c')
{
num1=0; /*將兩個操作數復位0,符號標志為1*/
num2=0;
flag=1;
strcpy(str2,""); /*將str2清空*/
setfillstyle(SOLID_FILL,color+3); /*設置用淡綠色實體填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*覆蓋結果區*/
outtextxy(5*width,height,"0."); /*顯示字元串*/
}
if(c=='Q')exit(0); /*如果選擇了q回車,結束計算程序*/
}
putimage(x,y,rar,XOR_PUT); /*在退出之前消去游標箭頭*/
return; /*返回*/
}
/*窗口函數*/
void mwindow( char *header )
{
int height;
cleardevice(); /* 清除圖形屏幕 */
setcolor( MaxColors - 1 ); /* 設置當前顏色為白色*/
setviewport( 20, 20, MaxX/2, MaxY/2, 1 ); /* 設置視口大小 */
height = textheight( "H" ); /* 讀取基本文本大小 */
settextstyle( DEFAULT_FONT, HORIZ_DIR, 1 );/*設置文本樣式*/
settextjustify( CENTER_TEXT, TOP_TEXT );/*設置字元排列方式*/
outtextxy( MaxX/4, 2, header ); /*輸出標題*/
setviewport( 20,20+height+4, MaxX/2+4, MaxY/2+20, 1 ); /*設置視口大小*/
drawboder(); /*畫邊框*/
}
void drawboder(void) /*畫邊框*/
{
struct viewporttype vp; /*定義視口類型變數*/
setcolor( MaxColors - 1 ); /*設置當前顏色為白色 */
setlinestyle( SOLID_LINE, 0, NORM_WIDTH );/*設置畫線方式*/
getviewsettings( &vp );/*將當前視口信息裝入vp所指的結構中*/
rectangle( 0, 0, vp.right-vp.left, vp.bottom-vp.top ); /*畫矩形邊框*/
}
/*設計滑鼠圖形函數*/
int arrow()
{
int size;
int raw[]={4,4,4,8,6,8,14,16,16,16,8,6,8,4,4,4}; /*定義多邊形坐標*/
setfillstyle(SOLID_FILL,2); /*設置填充模式*/
fillpoly(8,raw); /*畫出一游標箭頭*/
size=imagesize(4,4,16,16); /*測試圖象大小*/
rar=malloc(size); /*分配內存區域*/
getimage(4,4,16,16,rar); /*存放游標箭頭圖象*/
putimage(4,4,rar,XOR_PUT); /*消去游標箭頭圖象*/
return 0;
}
/*按鍵函數*/
int specialkey(void)
{
int key;
while(bioskey(1)==0); /*等待鍵盤輸入*/
key=bioskey(0); /*鍵盤輸入*/
key=key&0xff? key&0xff:key>>8; /*只取特殊鍵的掃描值,其餘為0*/
return(key); /*返回鍵值*/
}

⑺ c語言的圖形函數庫有哪些

圖形和圖像函數包含在graphics.h裡面

(一) 像素函數
56. putpiel() 畫像素點函數
57. getpixel()返回像素色函數
(二) 直線和線型函數
58. line() 畫線函數
59. lineto() 畫線函數
60. linerel() 相對畫線函數
61. setlinestyle() 設置線型函數
62. getlinesettings() 獲取線型設置函數
63. setwritemode() 設置畫線模式函數
(三)、多邊形函數
64. rectangle() 畫矩形函數
65. bar() 畫條函數
66. bar3d() 畫條塊函數
67. drawpoly() 畫多邊形函數
(四)、 圓、弧和曲線函數
68. getaspectratio()獲取縱橫比函數
69. circle()畫圓函數
70. arc() 畫圓弧函數
71. ellipse()畫橢圓弧函數
72. fillellipse() 畫橢圓區函數
73. pieslice() 畫扇區函數
74. sector() 畫橢圓扇區函數
75. getarccoords()獲取圓弧坐標函數
(五)、 填充函數
76. setfillstyle() 設置填充圖樣和顏色函數
77. setfillpattern() 設置用戶圖樣函數
78. floodfill() 填充閉域函數
79. fillpoly() 填充多邊形函數
80. getfillsettings() 獲取填充設置函數
81. getfillpattern() 獲取用戶圖樣設置函數
(六)、圖像函數
82. imagesize() 圖像存儲大小函數
83. getimage() 保存圖像函數
84. putimage() 輸出圖像函數

四、圖形和圖像函數
對許多圖形應用程序,直線和曲線是非常有用的。但對有些圖形只能靠操作單個像素才能畫出。當然如果沒有畫像素的功能,就無法操作直線和曲線的函數。而且通過大規模使用像素功能,整個圖形就可以保存、寫、擦除和與屏幕上的原有圖形進行疊加。
(一) 像素函數

56. putpixel() 畫像素點函數
功能: 函數putpixel() 在圖形模式下屏幕上畫一個像素點。
用法: 函數調用方式為void putpixel(int x,int y,int color);
說明: 參數x,y為像素點的坐標,color是該像素點的顏色,它可以是顏色符號名,也可以是整型色彩值。
此函數相應的頭文件是graphics.h
返回值: 無
例: 在屏幕上(6,8)處畫一個紅色像素點:
putpixel(6,8,RED);

57. getpixel()返回像素色函數
功能: 函數getpixel()返回像素點顏色值。
用法: 該函數調用方式為int getpixel(int x,int y);
說明: 參數x,y為像素點坐標。
函數的返回值可以不反映實際彩色值,這取決於調色板的設置情況(參見setpalette()函數)。
這個函數相應的頭文件為graphics.h
返回值: 返回一個像素點色彩值。
例: 把屏幕上(8,6)點的像素顏色值賦給變數color。
color=getpixel(8,6);

⑻ c語言的bar()函數和 rectangle()函數

bar畫一個填充矩形 填充顏色由 setfillstyle決定
rectangle畫一個空矩形框,線條顏色由setcolor決定

⑼ C語言 easyx裡面 bar(120,130,340,250)具體是什麼意思只知道bar是畫

你好,這里是bar的詳細參數說明:
bar
這個函數用於畫無邊框填充矩形。
void bar(int left,int top,int right,int bottom);
參數:
left矩形左部 x 坐標。
top矩形上部 y 坐標。
right矩形右部 x 坐標。
bottom矩形下部 y 坐標。

麻煩採納一下。