C/D画线包

发布于 2024-07-18 20:48:48 字数 328 浏览 4 评论 0原文

我发现自己需要一个画线包。 我需要弹出一个窗口并绘制线条和点。 文字固然很好,但没有文字我也能活下去。 最重要的是,我需要一些非常简单的东西来运行。 我没有时间和库闲聊(如果我有时间我会愿意,但我已经远远落后了)。

我更喜欢 D 语言 解决方案(Windows XP、D1.0、Phobos),但我也许能够使用任何带有 C 链接和源代码的东西。

我还可以使用进程外解决方案,例如:生成输入文件,调用程序。

有任何想法吗?

I find my self in need of a line drawing package. I need to pop a window and draw lines and points. Text would be nice but I can live without it. Most importantly, I need something that is dirt simple to get running. I don't have time to dink around with libs (if I did have time I'd be willing but I'm already way behind as it is).

I'd prefer a D language solution (Windows XP, D1.0, Phobos) but I might be able to use anything with C linkage and source.

I'd also be able to use an out of process solution as in: generate input file, call program.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

撩心不撩汉 2024-07-25 20:48:48

如果您想要一个进程外解决方案,为了快速启动并运行某些内容,生成 PostScript 并启动 PostScript 查看器是最好的选择。 这个技巧的巨大优点是,你生成一些东西,你不喜欢它的外观,你可以手动编辑它,直到它看起来更好。 然后你返回并编辑生成器。 所以你的原型制作周期非常快。

If you want an out-of-process solution, for getting something up and running quickly it's hard to beat generating PostScript and launching a PostScript viewer. The great advantage of this trick is that you generate something, you don't like the way it looks, you can edit it by hand until it looks better. Then you go back and edit the generator. So your prototyping cycle is very quick.

忘你却要生生世世 2024-07-25 20:48:48

QD

它就是为此而设计的。

只需导入 qd,链接 SDL.lib(如果需要文本,则为 SDL_ttf),然后设置 screen(width, height),line(x1, y1, x2, y2) 画一条线,pset(x1, y1) 到画一个点, print(x1, y1, Bottom|Right, "text") 打印文本。 cls 重置,翻转更新屏幕。 events() 来处理事件。 将 rgb(r, g, b) 附加到上述任何命令以更改线条颜色,将 Fill(rgb(r, g, b)) 附加到更改填充颜色。

有关示例,请参阅 test*.d

祝你好运!

QD.

It was made for this.

Just import qd, link with SDL.lib (SDL_ttf if you want text), then screen(width, height) to set up, line(x1, y1, x2, y2) to draw a line, pset(x1, y1) to draw a point, print(x1, y1, Bottom|Right, "text") to print text. cls to reset, flip to update the screen. events() to handle events. Append , rgb(r, g, b) to any of the above commands to change the line color, Fill(rgb(r, g, b)) to change the fill color.

For examples, see test*.d

Good luck!

生生不灭 2024-07-25 20:48:48

另一种选择是使用 Cairo。 它有一个非常容易学习的 API,功能相当强大,并且可以开箱即用地编写 PNG、PS、PDF 和 SVG。 它还支持绘制到 GDI、X 和 Quartz 窗口。

有一个旧的 D 绑定 cairo (由一些缺乏才华的黑客编写)这可能仍然有效。 如果不出意外,它将演示如何在 D 中链接和使用 cairo。

Another alternative is to use Cairo. It has a very easy to learn API, is quite powerful, and can write PNG, PS, PDF and SVG out of the box. It also supports drawing to GDI, X and Quartz windows.

There is an old D binding for cairo (written by some talent-less hack) which might still work. If nothing else, it'll demonstrate how to link and use cairo in D.

不寐倦长更 2024-07-25 20:48:48

您可以使用 SDL 弹出窗口,并使用 SDL_gfx 中的 SDL_gfxPrimitves.h 绘制线条(它还可以渲染基本文本和形状)。 设置不需要太多时间并且便于携带。

#include <SDL/SDL.h>
#include <SDL/SDL_gfxPrimitives.h>

main() {
    SDL_Surface *screen = NULL;

    if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
        exit(EXIT_FAILURE);

    atexit(SDL_Quit);

    screen = SDL_SetVideoMode(500, 500, 32, SDL_SWSURFACE|SDL_ANYFORMAT);

    if ( screen == NULL )
        exit(EXIT_FAILURE);

    lineColor(screen, 50, 50, 200, 200, 0xff0000ff);
    SDL_Flip(screen);

    sleep(5);
}

You can use SDL to pop a window and SDL_gfxPrimitves.h from SDL_gfx to draw the lines (it can also render basic text and shapes). It doesn't take much time to set up and is portable.

#include <SDL/SDL.h>
#include <SDL/SDL_gfxPrimitives.h>

main() {
    SDL_Surface *screen = NULL;

    if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
        exit(EXIT_FAILURE);

    atexit(SDL_Quit);

    screen = SDL_SetVideoMode(500, 500, 32, SDL_SWSURFACE|SDL_ANYFORMAT);

    if ( screen == NULL )
        exit(EXIT_FAILURE);

    lineColor(screen, 50, 50, 200, 200, 0xff0000ff);
    SDL_Flip(screen);

    sleep(5);
}
独木成林 2024-07-25 20:48:48

wxwidgets 是功能更强大、移植更广泛的 GUI 工具包之一。 该工具包本身是 C 语言,但也有许多其他语言的绑定。 不知道D有没有在其中。

wxwidgets is among the more featureful and more widely ported GUI toolkits. The toolkit is natively C, but there are bindings for plenty of other languages. I don't know if D is among them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文