📄 graphics.cpp
字号:
#include <windows.h>
#include <math.h>
#include "world.h"
/* End of draw arrow */
/* Crazy GDI code to draw a vector graphics arrow */
void draw_arrow(HDC dc, double x, double y, double dir, double size)
{
double arrow_base_x = x - size * cos(dir);
double arrow_base_y = y - size * sin(dir);
MoveToEx(dc, get_screen_x(arrow_base_x), get_screen_y(arrow_base_y), NULL);
double arrow_tip_x = x + size * cos(dir);
double arrow_tip_y = y + size * sin(dir);
LineTo(dc, get_screen_x(arrow_tip_x), get_screen_y(arrow_tip_y));
double arrow_left_x = x + 0.75 * size * cos(dir - M_PI / 4.0);
double arrow_left_y = y + 0.75 * size * sin(dir - M_PI / 4.0);
MoveToEx(dc, get_screen_x(arrow_left_x), get_screen_y(arrow_left_y), NULL);
LineTo(dc, get_screen_x(arrow_tip_x), get_screen_y(arrow_tip_y));
double arrow_right_x = x + 0.75 * size * cos(dir + M_PI / 4.0);
double arrow_right_y = y + 0.75 * size * sin(dir + M_PI / 4.0);
LineTo(dc, get_screen_x(arrow_right_x), get_screen_y(arrow_right_y));
}
/* End of draw arrow */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -