EasyX库简单中文手册

作者:

时间: 2021/2/2

第一个例程

#include <graphics.h>            // 图像相关库

#include <conio.h>          // 按键获取相关库

int main()

{

       initgraph(640, 480);  // 创建一个图像画板

       circle(200, 200, 100); // 以(200,200)为圆心画一个r100的圆

       _getch();                            // 获取一个按键值

       closegraph();                     // 关闭画板

       return 0;

}

//conioConsole Input / Output(控制台输入输出)的简写,其中定义了通过控制台进行数据输入和数据输出的函数,主要是一些用户通过按键盘产生的对应操作,比如getch()函数等等。

基本元素——颜色

Setlinecolor,有四种格式

setlinecolor(0xff0000);

setlinecolor(BLUE);

setlinecolor(RGB(0, 0, 255));

setlinecolor(HSLtoRGB(240, 1, 0.5));

Constant

Value

Color description

BLACK

0

Black

BLUE

0xAA0000

Blue

GREEN

0x00AA00

Green

CYAN

0xAAAA00

Cyan

RED

0x0000AA

Red

MAGENTA

0xAA00AA

Magenta

BROWN

0x0055AA

Brown

LIGHTGRAY

0xAAAAAA

Light Gray

DARKGRAY

0x555555

Dark Gray

LIGHTBLUE

0xFF5555

Bright Blue

LIGHTGREEN

0x55FF55

Bright Green

LIGHTCYAN

0xFFFF55

Bright Cyan

LIGHTRED

0x5555FF

Bright Red

LIGHTMAGENTA

0xFF55FF

Bright Magenta

YELLOW

0x55FFFF

Yellow

WHITE

0xFFFFFF

White

基本元素——圆

void circle(int x, int y, int radius);

void fillcircle(int x, int y, int radius);

setfillcolor(BLUE);

无边界实现圆

void solidcircle(

    int x,

    int y,

    int radius

);

基本元素——直线

void line(

       int x1,

       int y1,

       int x2,

       int y2

);

基本元素——长方形

void rectangle(

       int left,

       int top,

       int right,

       int bottom

);

Solidrectangle  无边框填充长方形

Fillrectangle  填充长方形

基本元素——文字

       setbkmode(TRANSPARENT); // 文字除了字体外透明 

       settextstyle(40, 0, L"Verdana");   //设置字体高,宽(0自适应),字体

       wchar_t s[] = L"游戏开始";

       outtextxy(10, 20, s);

图片显示

// 从图片文件获取图像(bmp/jpg/gif/emf/wmf/ico)

void loadimage(

       IMAGE* pDstImg,            // 保存图像的 IMAGE 对象指针

       LPCTSTR pImgFile,         // 图片文件名

       int nWidth = 0,           // 图片的拉伸宽度

       int nHeight = 0,         // 图片的拉伸高度

       bool bResize = false   // 是否调整 IMAGE 的大小以适应图片

);

pDstImg:保存图像的 IMAGE 对象指针。如果为 NULL,表示图片将读取至绘图窗口。

pImgFile:图片文件名。支持 bmp / jpg / gif / emf /
wmf / ico 类型的图片。gif 类型的图片仅加载第一帧,不支持透明。

nWidth:图片的拉伸宽度。加载图片后,会拉伸至该宽度。如果为 0,表示使用原图的宽度。

nHeight:图片的拉伸高度。加载图片后,会拉伸至该高度。如果为 0,表示使用原图的高度。

bResize:是否调整 IMAGE 的大小以适应图片。

#

include <iostream>

#include <graphics.h>      // 引用图形库头文件

#include <conio.h>

int main()

{

       initgraph(640, 480);   // 创建绘图窗口,大小为 640x480 像素

       IMAGE img;                 //创建IMAGE对象

       loadimage(&img, L"01.png");//绝对地址载入图片

       putimage(100, 0, &img);

       _getch();              // 按任意键继续

       closegraph();          // 关闭绘图窗口

}

鼠标的使用

struct MOUSEMSG

{

       UINT uMsg;                // Current mouse message.

       bool mkCtrl;         // The CTRL key is down.

       bool mkShift;       // The SHIFT key is down.

       bool mkLButton;         // The left mouse button is down.

       bool mkMButton;        // The middle mouse button is down.

       bool mkRButton;         // The right mouse button is down.

       int x;                           // The x-coordinate of the cursor. (physical coordinates)

       int y;                           // The y-coordinate of the cursor. (physical coordinates)

       int wheel;                    // The mouse wheel scroll value.};

Value

Description

WM_MOUSEMOVE

The message of the mouse
movement.

WM_MOUSEWHEEL

The message of the mouse
wheel scroll.

WM_LBUTTONDOWN

The message of the left
mouse button down.

WM_LBUTTONUP

The message of the left
mouse button up.

WM_LBUTTONDBLCLK

The message of the left
mouse button double click.

WM_MBUTTONDOWN

The message of the middle
mouse button down.

WM_MBUTTONUP

The message of the middle
mouse button up.

WM_MBUTTONDBLCLK

The message of the middle
mouse button double click.

WM_RBUTTONDOWN

The message of the right
mouse button down.

WM_RBUTTONUP

The message of the right
mouse button up.

WM_RBUTTONDBLCLK

The message of the right
mouse button double click.

#include<graphics.h>

#include<conio.h>

#include<stdio.h>

//鼠标左键点击

int main()

{

       initgraph(800, 600);

       setbkcolor(WHITE);

       cleardevice();

       while (1)

       {

              MOUSEMSG m;

              if (MouseHit())

              {

                     m = GetMouseMsg();

                     if (m.uMsg == WM_LBUTTONDOWN)

                     {

                            setfillcolor(GREEN);

                            fillcircle(m.x, m.y, 30);

                     }

              }

       }

       return 0;

}
//

//// 鼠标移动

//int main()

//{

//     initgraph(800, 600);

//     setbkcolor(WHITE);

//     cleardevice();

//

//     while (1)

//     {

//            MOUSEMSG m;

//            if (MouseHit())

//            {

//                   m = GetMouseMsg();

//                   if (m.uMsg == WM_MOUSEMOVE)

//                   {

//                          setfillcolor(GREEN);

//                          fillcircle(m.x, m.y, 3);

//

//                   }

//

//            }

//

//     }

//     return 0;

//}

音乐播放

#include <windows.h>

#include <mmsystem.h>

#include<conio.h>

#pragma comment(lib, "winmm.lib")

int main()

{

       //mci: media control interface(多媒体控制接口)

       mciSendStringW(L"play 01.mp3", 0, 0, 0);

       mciSendString(L"play 01.mp3", 0, 0, 0);

       _getch();

       mciSendString(L"pause 01.mp3", 0, 0, 0);

       _getch();

       mciSendString(L"resume 01.mp3", 0, 0, 0);

       system("pause");

       return 0;

}

//open    打开设备

//close    关闭设备

//play    开始设备播放

//stop    停止设备的播放或记录

//record   开始记录

//save    保存设备内容

//pause    暂停设备的播放或记录

//resume   恢复暂停播放或记录的设备

//seek    改变媒体的当前位置

//capacility 查询设备能力

//info    查询设备的信息

//status   查询设备状态信息

批量绘图

BeginBatchDraw   这个函数用于开始批量绘图。执行后,任何绘图操作都将暂时不输出到屏幕上,直到执行
  FlushBatchDraw   或
   EndBatchDraw   才将之前的绘图输出。

随机数

rand()   
参数随机数,但是每次都是一个相同序列

srand(time(0));       time(0)一般只用于重新运行时要产生不同随机数的情况,否则在这一秒内产生的随机数将会是一样的。

按键

_getchar();

EasyX库简单中文手册的更多相关文章

  1. Swift网络封装库Moya中文手册之Authentication

    Authentication 安全验证可能有点复杂,一些网络请求需要认证,这里我们讨论两种常见的. Basic HTTP Auth HTTP auth是HTTP协议自带的用户名/密码验证.如果你使用的 ...

  2. Swift网络封装库Moya中文手册之Endpoints

    Endpoints Endpoint是一种半私有的数据结构,Moya用来解释网络请求的根本构成.一个endpoint储存了以下数据: The URL. The HTTP method (GET,POS ...

  3. Swift网络封装库Moya中文手册之Plugins

    Plugins Moya plugins用于反映请求的发起或接收.Plugins定义为 PluginType 属性,可以在请求准备发起和接收到返回数据时回调. Built in plugins Moy ...

  4. Swift网络封装库Moya中文手册之Providers

    Providers 使用Moya,你可以通过一个 MoyaProvider 的实例发送所有网络请求,通过枚举来指定你要访问的具体API.在配置你的 Endpoint 之后,你差不多就做好了基础配置: ...

  5. Swift网络封装库Moya中文手册之RxSwift

    RxSwift Maya提供了一个可选的MoyaProvider 子类 - RxMoyaProvider.在网络请求完成时,我们不再使用 request() 函数的回调闭包,而是使用 Observab ...

  6. Swift网络封装库Moya中文手册之Targets

    Targets 使用Moya,我们首先需要定义一个target - 这通常是继承 TargetType 协议的 枚举 变量.接下来,你的app只需要处理这些targets,也就是一些你希望调用API完 ...

  7. phpredis中文手册——《redis中文手册》 php版

    本文是参考<redis中文手册>,将示例代码用php来实现,注意php-redis与redis_cli的区别(主要是返回值类型和参数用法). 目录(使用CTRL+F快速查找命令): Key ...

  8. [转]phpredis中文手册

    本文是参考<redis中文手册>,将示例代码用php来实现,注意php-redis与redis_cli的区别(主要是返回值类型和参数用法). 目录(使用CTRL+F快速查找命令): Key ...

  9. man mountd(rpc.mountd中文手册)

    本人译作集合:http://www.cnblogs.com/f-ck-need-u/p/7048359.html rpc.mountd() System Manager's Manual rpc.mo ...

随机推荐

  1. PPT制作手机滑动效果

    原文链接: https://www.toutiao.com/i6495341287196066317/ 我们添加一个手机图片 选择"插入"选项卡,插入两条直线,如下图所示.插入直线 ...

  2. Flowable实战(八)BPMN2.0 任务

      任务是流程中最重要的组成部分.Flowable提供了多种任务类型,以满足实际需求.   常用任务类型有: 用户任务 Java Service任务 脚本任务 业务规则任务 执行监听器 任务监听器 多 ...

  3. 《剑指offer》面试题43. 1~n整数中1出现的次数

    问题描述 输入一个整数 n ,求1-n这n个整数的十进制表示中1出现的次数. 例如,输入12,1-12这些整数中包含1 的数字有1.10.11和12,1一共出现了5次. 示例 1: 输入:n = 12 ...

  4. 【解决了一个小问题】golang build中因为缓存文件损坏导致的编译错误

    编译的过程中出现了一个吓人的错误: GOROOT=C:\Go #gosetup GOPATH=C:\Users\ahfuzhang\go #gosetup C:\Go\bin\go.exe mod t ...

  5. 【解决了一个问题】腾讯云中使用ckafka生产消息时出现“kafka server: Message contents does not match its CRC.”错误

    初始化的主要代码如下: config := sarama.NewConfig() config.Producer.RequiredAcks = sarama.WaitForAll // Wait fo ...

  6. unity3d之sokect通信

    using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using S ...

  7. unity3d百度语音合成mp3流转换byte[]失败

    using (Stream stream = response.GetResponseStream())         {             buffer2 = new byte[stream ...

  8. 使用Cesium Stories在3D Tilesets中检查Features

    Cesium中文网:http://cesiumcn.org/ | 国内快速访问:http://cesium.coinidea.com/ 我们创建了3D Tiles用以流式化.可视化和分析大量的三维内容 ...

  9. golang中sha256、md5加密,base64encode、base64decode

    package tool import ( "crypto/md5" "crypto/sha256" "encoding/base64" & ...

  10. gin中绑定表单数据至自定义结构体

    package main import "github.com/gin-gonic/gin" type StructA struct { FieldA string `form:& ...