设定颜色类型数据 col (color)
无论以
col | color |
---|---|
纯语言 | 如WHITE,BLACK,CYAN或是LIGHTMAGETA等形式 |
十六进制的值 | 如0xFFFFFF,0x000000,0xAAAA00或是0xFF55FF |
RGB | RGB(256,256,256),RGB(0,0,0)或RGB(int,int,int) |
HSV | Hue(色相) 分量,0 <= H < 360;Saturation(饱和度) 分量,0 <= S <= 1;Value(明度) 分量,0 <= V <= 1。如HSV() |
HSL | H原 HSL 颜色模型的 Hue(色相) 分量,0 <= H < 360;S原 HSL 颜色模型的 Saturation(饱和度) 分量,0 <= S <= 1;L原 HSL 颜色模型的 Lightness(亮度) 分量,0 <= L <= 1。 |
HSLtoRGB HSVtoRGB RGBtoGRAY RGBtoHSL RGBtoHSV等 | 不加赘述 |
获取使用者的输入,
即是获取信息,
有以下四大类:
Category identifier | Description |
---|---|
EM_MOUSE | Mouse message |
EM_KEY | Key message |
EM_CHAR | Character message |
EM_WINDOW | Window message |
- Mouse message
使用示例
ExMessage m; // Define a message variable
while(true) //continuously get mouse message if get no input
//or you can exchange this sentence to
//MOUSEMSG m;
//if (MouseHit())
// m = GetMouseMsg();
//this writing does not require so much system memory,can also get mousemsg
{
// Get a mouse message or a key message
m = getmessage(EM_MOUSE | EM_KEY);//indicate message type
switch(m.uMsg) //from structure MOUSEMSG
{
case WM_MOUSEMOVE: //defined in enum "Incurrent Mousemsg"
// Draw a red pixel when the mouse move
putpixel(m.x, m.y, RED);
break;
case WM_LBUTTONDOWN: //defined in enum "Incurrent Mousemsg"
// If the left button is clicked while pressing the Ctrl key
if (m.ctrl) //from structure MOUSEMSG
// Draw a big square
rectangle(m.x - 10, m.y - 10, m.x + 10, m.y + 10);
else
// Draw a small square
rectangle(m.x - 5, m.y - 5, m.x + 5, m.y + 5);
break;
case WM_KEYDOWN:
if (m.vkcode == VK_ESCAPE) //VK_ESCAPE from KEYMSG
return 0; // Press ESC key to exit
}
}
or you just want to get a very event ,you can only code like
MOUSEMSG m;
if(m==(1,1,1)) //Ctrl+Shift+LButtonDown
C_operate(R-301);//any operation
just as it is displayed forehead ,it can be commonly used in any cases alike
the importance is just:
1.the structure of MOUSEMSG
struct MOUSEMSG
{
UINT uMsg; // 当前鼠标消息
bool mkCtrl; // Ctrl 键是否按下
bool mkShift; // Shift 键是否按下
bool mkLButton; // 鼠标左键是否按下
bool mkMButton; // 鼠标中键是否按下
bool mkRButton; // 鼠标右键是否按下
int x; // 当前鼠标 x 坐标
int y; // 当前鼠标 y 坐标
int wheel; // 鼠标滚轮滚动值
};
2.enum INCURRENT_MOUSEMSG(EM_MOUSE)
enum | operation |
---|---|
WM_MOUSEMOVE | 鼠标移动消息 |
WM_MOUSEWHEEL | 鼠标滚轮拨动消息 |
WM_LBUTTONDOWN | 左键按下消息 |
WM_LBUTTONUP | 左键弹起消息 |
WM_LBUTTONDBLCLK | 左键双击消息 |
WM_MBUTTONDOWN | 中键按下消息 |
WM_MBUTTONUP | 中键弹起消息 |
WM_MBUTTONDBLCLK | 中键双击消息 |
WM_RBUTTONDOWN | 右键按下消息 |
WM_RBUTTONUP | 右键弹起消息 |
WM_RBUTTONDBLCLK | 右键双击消息 |
mouse is the same with keyboard:
1.struct KEYMSG
{
BYTE vkcode; // 按键的虚拟键码
BYTE scancode; // 按键的扫描码(依赖于 OEM)
bool extended :1; // 按键是否是扩展键
bool prevdown :1; // 按键的前一个状态是否按下
};
2.enum INCURRENT_KEYMSG(EM_key)
enum | operation |
---|---|
WM_KEYDOWN | 按键按下消息 |
WM_KEYUP | 按键弹起消息 |
3.enum vkcode and scancode
int A=0x41;
int B=0x42;
int C=0x43;
int D=0x44;
int E=0x45;
int F=0x46;
int G=0x47;
int H=0x48;
int I=0x49;
int J=0x4A;
int K=0x4B;
int L=0x4C;
int M=0x4D;
int N=0x4E;
int O=0x4F;
int P=0x50;
int Q=0x51;
int R=0x52;
int S=0x53;
int T=0x54;
int U=0x55;
int V=0x56;
int W=0x57;
int X=0x58;
int Y=0x59;
int Z=0x5A;
details in
https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
window message
1.struct WINDOWMSG
{
WPARAM wParam;
LPARAM lParam;
};
2.EM_WINDOW
WM_ACTIVATE | 窗口激活状态改变消息 |
WM_MOVE | 窗口移动消息 |
WM_SIZE | 窗口大小改变消息 |
图形文本标准字体
字体符号名 | 等价值 | 含义 |
---|---|---|
DEFAULT_FONT | 0 | 8*8点阵字型(缺省字体) |
TRIPLEx_FONT | 1 | 笔划式三倍字型(三倍字体) |
SMALL_FONT | 2 | 笔划式小字型(小字体) |
SANS_SERIF_FONT | 3 | 笔划式字(Sanserif字体) |
GOTHIC_FONT | 4 | 笔划黑体字型(哥特体) |
the basic operations of a simple easyx operation
- initialize window_gragh
initgragh(int length,int width);
setbkcolor(col color); //WHITE or 0xFFFFFF or RGB(0,0,0)
cleardevice(); //void cleardevice() guarantees
setfillcolor(color col));/ //initial backgrround is white
setorigin(int x0,int y0); //set the logic origin of the coordinate
2.pre-treatment of plotting
{
setcolor(col color);
setlinestyle(PS_SOLID,int width);
//if drawing close shapes
setfillcolor(col color); //initial is transparent
}
- Get Message
Exmessage mk,c,w;
c = getmessage(EM_CHAR); //CHARMSG c;
w = getmessage(EM_WINDOW); //WINDOWMSG w;
int A=0x41;
int B=0x42;
int C=0x43;
int D=0x44;
int E=0x45;
int F=0x46;
int G=0x47;
int H=0x48;
int I=0x49;
int J=0x4A;
int K=0x4B;
int L=0x4C;
int M=0x4D;
int N=0x4E;
int O=0x4F;
int P=0x50;
int Q=0x51;
int R=0x52;
int S=0x53;
int T=0x54;
int U=0x55;
int V=0x56;
int W=0x57;
int X=0x58;
int Y=0x59;
int Z=0x5A;
while(true)
{
mk = getmessage(EM_MOUSE | EM_KEY); //MOUSEMSG m,KEYMSG k;
if(mousehit())
{
switch(mk.message) //mk.uMsg
{
case WM_MOUSEMOVE:
putpixel(m.x ,m.y ,WHITE);break;
case WM_LBUTTONDOWN:
shoot();break;
case WM_RBUTTONDOWN:
open_optics();break;
case WM_MOUSEWHEEL:
swap_weapon();break;
case VK_XBUTTON1:
mk.mkCtrl = 1;
case VK_XBUTTON2:
mk.mkShift = 1;
};
}
elif(keyhit())
{
switch(keyhit())
{
case W:
move_foreward();
case A:
move_left();
case S:
move_backward();
case D:
move_right();
case VK_UP:
layer_up();
case VK_DOWN:
layer_down();
case VK_RIGHT:
turn_left();
case VK_LEFT:
turn_right();
}
}
}
- s
- d
- f
- g