📄 draw.cpp
字号:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <windows.h>
#define pi 3.14159265358
#define L 100.0
#define MAX 21
#define N2 6
//(200,200)
void main(){
double temp;
double x[N2],y[N2];
char *M[MAX]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"};
HBRUSH hbrush_old;
HDC hdc = GetWindowDC( GetDesktopWindow() );
HPEN hpen1 = CreatePen( PS_SOLID, 1, RGB(0,128,64) );// 创建红色1像素宽度的实线画笔
HPEN hpen2 = CreatePen( PS_DASH, 5, RGB(0,255,0) ); // 创建绿色5像素宽度的破折画笔
HBRUSH hbrush1 = CreateSolidBrush( RGB(0,0,255) ); // 创建一个实体蓝色画刷
HBRUSH hbrush2 = CreateSolidBrush( RGB(128,0,255) ); //紫色
HBRUSH hbrush3 = CreateSolidBrush( RGB(0,255,64) );//绿色
HPEN hpen_old = (HPEN)SelectObject( hdc, hpen1 );
for(int i=0;i<N2;i++){
temp =i*(360.0/N2)*(pi/180);
y[i] =200 + L * sin(temp);
x[i] =200 + L * cos(temp);
if(i%3==0)
hbrush_old = (HBRUSH)SelectObject( hdc, hbrush1);
else if(i%3==1)
hbrush_old = (HBRUSH)SelectObject( hdc, hbrush2);
else
hbrush_old = (HBRUSH)SelectObject( hdc, hbrush3);
Ellipse( hdc,(int)x[i], (int)y[i], int(x[i]+10), int(y[i]+10) );//画圆
TextOut( hdc,(int)x[i],(int)y[i],M[i+1],2);
}
for(i=0;i<N2;i++)
for(int j = i+1;j<N2;j++){
MoveToEx( hdc, (int)x[i], (int)y[i], NULL );
LineTo( hdc, (int)x[j], (int)y[j] );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -