/******************************************************
* EasyX Library for C++ (Ver:20240601)
* https://easyx.cn
*
* EasyX.h
* Provides the latest API.
******************************************************/
#pragma once
#ifndef WINVER
#define WINVER 0x0400 // Specifies that the minimum required platform is Windows 95 and Windows NT 4.0.
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500 // Specifies that the minimum required platform is Windows 2000
#endif
#ifndef _WIN32_WINDOWS
#define _WIN32_WINDOWS 0x0410 // Specifies that the minimum required platform is Windows 98
#endif
#ifdef UNICODE
#pragma comment(lib,"EasyXw.lib")
#else
#pragma comment(lib,"EasyXa.lib")
#endif
#ifndef __cplusplus
#error EasyX is only for C++
#endif
#include <windows.h>
#include <tchar.h>
// EasyX Window Properties
#define EX_SHOWCONSOLE 1 // Maintain the console window when creating a graphics window
#define EX_NOCLOSE 2 // Disable the close button
#define EX_NOMINIMIZE 4 // Disable the minimize button
#define EX_DBLCLKS 8 // Support double-click events
// Color constant
#define BLACK 0
#define BLUE 0xAA0000
#define GREEN 0x00AA00
#define CYAN 0xAAAA00
#define RED 0x0000AA
#define MAGENTA 0xAA00AA
#define BROWN 0x0055AA
#define LIGHTGRAY 0xAAAAAA
#define DARKGRAY 0x555555
#define LIGHTBLUE 0xFF5555
#define LIGHTGREEN 0x55FF55
#define LIGHTCYAN 0xFFFF55
#define LIGHTRED 0x5555FF
#define LIGHTMAGENTA 0xFF55FF
#define YELLOW 0x55FFFF
#define WHITE 0xFFFFFF
// Color conversion macro
#define BGR(color) ( (((color) & 0xFF) << 16) | ((color) & 0xFF00FF00) | (((color) & 0xFF0000) >> 16) )
class IMAGE;
// Line style class
class LINESTYLE
{
public:
LINESTYLE();
LINESTYLE(const LINESTYLE &style);
LINESTYLE& operator = (const LINESTYLE &style);
virtual ~LINESTYLE();
DWORD style;
DWORD thickness;
DWORD *puserstyle;
DWORD userstylecount;
};
// Fill style class
class FILLSTYLE
{
public:
FILLSTYLE();
FILLSTYLE(const FILLSTYLE &style);
FILLSTYLE& operator = (const FILLSTYLE &style);
virtual ~FILLSTYLE();
int style; // Fill style
long hatch; // Hatch pattern
IMAGE* ppattern; // Fill image
};
// Image class
class IMAGE
{
public:
int getwidth() const; // Get the width of the image
int getheight() const; // Get the height of the image
private:
int width, height; // Width and height of the image
HBITMAP m_hBmp;
HDC m_hMemDC;
float m_data[6];
COLORREF m_LineColor; // Current line color
COLORREF m_FillColor; // Current fill color
COLORREF m_TextColor; // Current text color
COLORREF m_BkColor; // Current background color
DWORD* m_pBuffer; // Memory buffer of the image
LINESTYLE m_LineStyle; // Current line style
FILLSTYLE m_FillStyle; // Current fill style
virtual void SetDefault(); // Set the graphics environment as default
public:
IMAGE(int _width = 0, int _height = 0);
IMAGE(const IMAGE &img);
IMAGE& operator = (const IMAGE &img);
virtual ~IMAGE();
virtual void Resize(int _width, int _height); // Resize image
};
// Graphics window related functions
HWND initgraph(int width, int height, int flag = 0); // Create graphics window
void closegraph(); // Close graphics window
// Graphics environment related functions
void cleardevice(); // Clear device
void setcliprgn(HRGN hrgn); // Set clip region
void clearcliprgn(); // Clear clip region
void getlinestyle(LINESTYLE* pstyle); // Get line style
void setlinestyle(const LINESTYLE* pstyle); // Set line style
void setlinestyle(int style, int thickness = 1, const DWORD *puserstyle = NULL, DWORD userstylecount = 0); // Set line style
void getfillstyle(FILLSTYLE* pstyle); // Get fill style
void setfillstyle(const FILLSTYLE* pstyle); // Set fill style
void setfillstyle(int style, long hatch = NULL, IMAGE* ppattern = NULL); // Set fill style
void setfillstyle(BYTE* ppattern8x8); // Set fill style
void setorigin(int x, int y); // Set coordinate origin
void getaspectratio(float *pxasp, float *pyasp); // Get aspect ratio
void setaspectratio(float xasp, float yasp); // Set aspect ratio
int getrop2(); // Get binary raster operation mode
void setrop2(int mode); // Set binary raster operation mode
int getpolyfillmode(); // Get polygon fill mode
void setpolyfillmode(int mode); // Set polygon fill mode
void graphdefaults(); // Reset the graphics environment as default
COLORREF getlinecolor(); // Get line color
void setlinecolor(COLORREF color); // Set line color
COLORREF gettextcolor(); // Get text color
void settextcolor(COLORREF color); // Set text color
COLORREF getfillcolor(); // Get fill color
void setfillcolor(COLORREF color); // Set fill color
COLORREF getbkcolor(); // Get background color
void setbkcolor(COLORREF color); // Set background color
int getbkmode(); // Get background mode
void setbkmode(int mode); // Set background mode
// Color model transformation related functions
COLORREF RGBtoGRAY(COLORREF rgb);
void RGBtoHSL(COLORREF rgb, float *H, float *S, float *L);
void RGBtoHSV(COLORREF rgb, float *H, float *S, float *V);
COLORREF HSLtoRGB(float H, float S, float L);
COLORREF HSVtoRGB(float H, float S, float V);
// Drawing related functions
COLORREF getpixel(int x, int y); // Get pixel color
void putpixel(int x, int y, COLORREF color); // Set pixel color
void line(int x1, int y1, int x2, int y2); // Draw a line
void rectangle (int left, int top, int right, int bottom); // Draw a rectangle without filling
void fillrectangle (int left, int top, int right, int bottom); // Draw a filled rectangle with a border
void solidrectangle(int left, int top, int right, int bottom); // Draw a filled rectangle without a border
void clearrectangle(int left, int top, int right, int bottom); // Clear a rectangular region
void circle (int x, int y, int radius); // Draw a circle without filling
void fillcircle (int x, int y, int radius); // Draw a filled circle with a border
void solidcircle(int x, int y, int radius); // Draw a filled circle without a border
void clearcircle(int x, int y, int radius); // Clear a circular region
void ellipse (int left, int top, int right, int bottom); // Draw an ellipse without filling
void fillellipse (int left, int top, int right, int bottom); // Draw a filled ellipse with a border
void solidellipse(int left, int top, int right, int bottom); // Draw a filled ellipse without a border
void clearellipse(int left, int top, int right, int bottom); // Clear an elliptical region
void roundrect (int left, int top, int right, int bottom, int ellipsewidth, int ellipseheight); // Draw a rounded rectangle without filling
void fillroundrect (int left, int top, int right, int bottom, int ellipsewidth, int ellipseheight); // Draw a filled rounded rectangle with a border
void solidroundrect(int left, int top, int right, int bottom, int ellipsewidth, int ellipseheight); // Draw a filled rounded rectangle without a border
void clearroundrect(int left, int top, int right, int bottom, int ellipsewidth, int ellipseheight); // Clear a rounded rectangular region
void arc (int left, int top, int right, int bottom, double stangle, double endangle); // Draw an arc
void pie (int left, int top, int right, int bottom, double stangle, double endangle); // Draw a sector without filling
void fillpie (int left, int top, int right, int bottom, double stangle, double endangle); // Draw a filled sector with a border
void solidpie(int left, int top, int right, int bottom, double stangle, double endangle); // Draw a filled sector without a border
void clearpie(int left, int top, int right, int bottom, double stangle, double endangle); // Clear a rounded rectangular region
void
没有合适的资源?快使用搜索试试~ 我知道了~
c++ easyX库官方原版下载安装包
共5个文件
a:3个
h:2个
需积分: 0 2 下载量 152 浏览量
2024-10-20
20:37:35
上传
评论
收藏 132KB ZIP 举报
温馨提示
适用于c++初学者进阶使用easyX库时需要用easyX.h库,graphics.h库时不至于编译失败,适用于Dev-c++、Vs或小熊猫Dev-c++。教程在CSDN上、博客园和github上到处都有配置教程,可以自己找,我就不再此叙述啦,可参考https://blog.csdn.net/Dustinthewine/article/details/129431962这位大神写的教程或https://blog.csdn.net/weixin_61777209/article/details/124185685这篇大神写的。 easyX库使用教程请参考https://blog.csdn.net/qq_52661581/article/details/125124212 命令请参考https://blog.csdn.net/weixin_44690490/article/details/100679271 (仅转载与推荐,无恶意,望大神见谅。)
资源推荐
资源详情
资源评论
收起资源包目录
easyx4mingw_20240601.zip (5个子文件)
include
easyx.h 16KB
graphics.h 8KB
lib64
libeasyx.a 178KB
lib-for-devcpp_5.4.0
libeasyx.a 145KB
lib32
libeasyx.a 137KB
共 5 条
- 1
资源评论
a789156
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功