Coder Social home page Coder Social logo

ahgraphics's Introduction

AHGraphics

Blog EasyX

A tool in order to let EasyX lib drawing on all of windows. 用于让 EasyX lib 在所有窗口上绘图的库


使用 AHGraphics ,首先include它,然后调用InitDrawing来设置目标绘图HWND或者HDC:

#include "AHGraphics.h"
#include <conio.h>
 
int main()
{
    InitDrawing(GetConsoleWindow()/* 得到cmd句柄 */);
     
    _getch();
 
    EndDrawing();
 
    return 0;
}

以上的代码设置了绘图目标窗口为cmd。

设置了目标绘图窗口,就可以直接使用easyx函数绘图了,例子:

#include "AHGraphics.h"
#include <conio.h>
 
int main()
{
    InitDrawing(GetConsoleWindow()/* 得到cmd句柄 */);
     
    setlinestyle(PS_SOLID, 5);
 
    setlinecolor(BLUE);
    line(0, 0, 200, 200);
 
    setlinecolor(RED);
    line(30, 30, 200, 30);
 
    // 绘图后要将绘图内容输出 
    FlushDrawingToWnd();
 
    _getch();
 
    EndDrawing();
 
    return 0;
}

效果图片请看samples中各个例子的screenshot文件

注意事项

设置了绘图目标窗口后,

不要使用MouseHit和GetMouseMsg等函数,因为什么也得不到,请使用GetMousePoint来得到鼠标位置。

不要直接SetWorkingImage(NULL),因为设置了目标绘图窗口后,主画布(IMAGE对象)就不再是NULL可以表示的了,请将其改成: SetWorkingImage(GetMainImage()/* 得到主画布的地址 */);

更新日志

Ver2.0

修复了 FlushDrawingToWnd 函数的 Bug。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.