当前位置:网站首页>Graphics learned from jigsaw puzzles h
Graphics learned from jigsaw puzzles h
2022-06-29 10:29:00 【X.IO】
Recently, with C Language to do a puzzle game to use graohic.h Graphics library , Then I summarized some functions involved in my program .( I'm cute , No joy, no spray. )
One .Graphics.h
First , Now let me remind you .( According to my recent experience of stepping on the pit )
1. stay vc And vs Use in the environment graphics.h The function of Can download EasyX Graphics library
( Be careful : This is a C++ The graphics library of If you have to C Language environment graphics.h You can use windows gdi))
2. I believe some friends use Dev-C++ Compiler , But after downloading EasyX The graphics library is still useless ( I'm crazy, too , Found many blogs )
The final reason is :easyx Currently not supported dev-c++. because dev-c Use gcc, Some precompiled instructions are missing , So every time you create a project, you must reference the library , More trouble , Not friendly enough for many beginners , Therefore, we do not support .
Next is the text ( Mainly to understand some functions )
The first is the basic construction :
initgraph(int x,int y,);
// Initialize the graphics system ( It can be understood as re creating a new window ) Among them x、y Represents the width and height of the window respectively .
closegraph();
// close window
rectangle(x1,y1,x2,y2);
// Building a hollow rectangle ,x1,y1 Top left coordinates ,x2,y2 Lower right coordinates
line(x1,y1,x2,y2);
// Build a line . The parameters are the coordinates of both ends
The second is the basic settings
setbkcolor(): Set the background color , Parameter color .
setfillcolor(): Set the color used to fill the drawing form
setlinecolor(): Set the line color
settextcolor(): Set text color ( My understanding is to set the font color )
set( Set up )、color( Color )、bk( background )、fill( fill )、line( line )、text( Text ) After understanding , These functions are actually easy to remember .
The above is mainly about setting some colors , Available when setting colors RGB(a,b,c) Express , You can also use color directly in brackets Capital letters Express , Color macro .
setfillstyle();
// Set the fill pattern , Such as vertical line , Horizontal line , Square filling .
setlinestyle();
// Set the fill pattern of the line
setbkmode();
// pattern , Or text filled background mode ( Background color , transparent ).
Then there is the output
outtextxy(x,y,str);
// stay x,y Position output string str
The plot
IMAGE img;
loadimage(&img,path[, width, height]);
// Image reading .IMAGE Object address , route . Extension parameters , Width and height have been set , Stretch read .
putimage(x,y,&img);
// Display images . The display starts at the coordinates of the upper left corner of the graphics window img graphics .
putimage(int x,int y,int width,int height,&img,int posx,int posy);
// Display images . Compared with the above ,w,h For how many pixels of graphics to display ,x,y by img The object is displayed from this position ( That is, to which position in the window , The width of the graph taken , The height taken , From where in the picture )
Finally, the mouse operation
1. Define mouse messages (MOUSEMSG m;)
2. Get mouse message (m=GETMouseMsg();)
3. Sort and process mouse messages
(switch(m.uMsg)
{
case WM_LBUTTONDOWN:
break;
}
)
边栏推荐
- Symphony tutorial
- 如何快速完成磁盘分区
- Devaxpress double click to get cell data
- Beautiful ruins around Kiev -- a safe guide to Chernobyl!
- 《CLR via C#》读书笔记-单实例应用程序
- 1098 insertion or heap sort (25 points)
- 在实践中学习Spark计算框架(01)
- L2-025 分而治之 (25 分)
- Is it safe to open a stock account with the QR code given by the manager of a securities firm? I want to open an account
- 通过Win32API调用另一界面的按钮
猜你喜欢
随机推荐
函数指针、函数指针数组、计算器+转移表等归纳总结
Using rancher to build kubernetes cluster
Ural1517 freedom of choice [suffix array: longest common continuous substring]
1099 build a binary search tree (30 points)
Installing and configuring wmware esxi 6.5.0 in VMware Workstation
Oracle重置序列发生器(非重建)
Is it safe to open a stock account with the QR code given by the manager of a securities firm? I want to open an account
通过Win32API调用另一界面的按钮
2019.11.13 training summary
Reverse thinking - short story
2021年团体程序设计天梯赛-模拟赛
Wandering -- the last programming challenge
HDU 6778 car (group enumeration -- > shape pressure DP)
Common usage of LINQ in C #
Call another interface button through win32API
Function pointer, function pointer array, calculator + transfer table, etc
《CLR via C#》读书笔记-单实例应用程序
六度空间 bfs
Arc view and arc viewpager
PGP在加密技术中的应用









