用于图形应用程序的快速,像素精度2D绘图API?

时间:2023-02-09 09:11:44

I woud like to create a cross-platform drawing program. The one requirement for writing my app is that I have pixel level precision over the canvas. For instance, I want to write my own line drawing algorithm rather than rely on someone elses. I do not want any form of anti-aliasing (again, pixel level control is required.) I would like the users interactions on the screen to be quick and responsive (pending my ability to write fast algorithms.)

我想创建一个跨平台的绘图程序。编写我的应用程序的一个要求是我在画布上具有像素级精度。例如,我想编写自己的线条绘制算法,而不是依赖别人。我不想要任何形式的抗锯齿(再次,需要像素级控制。)我希望屏幕上的用户交互能够快速响应(等待我编写快速算法的能力。)

Ideally, I would like to write this in Python, or perhaps Java as a second choice. The ability to easily make the final app cross-platform is a must. I will submit to different API's on different OS'es if necessary as long as I can write an abstraction layer around them. Any ideas?

理想情况下,我想用Python编写它,或者将Java作为第二选择。能够轻松制作最终应用程序跨平台是必须的。只要我能在它们周围编写一个抽象层,我会在必要时提交不同的OS上的不同的API。有任何想法吗?

addendum: I need the ability to draw on-screen. Drawing out to a file I've got figured out.

附录:我需要能够在屏幕上绘图。绘制出一个我已经弄明白的文件。

5 个解决方案

#1


3  

I just this week put together some slides and demo code for doing 2d graphics using OpenGL from python using the library pyglet. You can see my stuff here: http://tartley.com/?p=378

我本周刚将使用库pyglet从python中使用OpenGL进行2D渲染的幻灯片和演示代码放在一起。你可以在这里看到我的东西:http://tartley.com/?p = 378

It is very fast (relatively speaking, for python) I have managed to get around 1,000 independently positioned and oriented objects moving around the screen, each with about 50 vertices.

这是非常快的(相对来说,对于python)我已经设法获得大约1,000个独立定位和定向的对象在屏幕上移动,每个对象有大约50个顶点。

It is very portable, all the code I have written in this environment works on windows and Linux and mac (and even obscure environments like Pypy) without me ever having to think about it.

它非常便携,我在这个环境中编写的所有代码都适用于Windows,Linux和Mac(甚至像Pypy这样的模糊环境),而我不必考虑它。

Update: There are a bunch of newer posts on the same topic too: http://tartley.com/?cat=27

更新:同一主题上还有一些较新的帖子:http://tartley.com/?cat = 27

#2


2  

The Pyglet library for Python might suit your needs. It lets you use OpenGL, a cross-platform graphics API. You can disable anti-aliasing and capture regions of the screen to a buffer or a file. In addition, you can use its event handling, resource loading, and image manipulation systems. You can probably also tie it into PIL (Python Image Library), and definitely Cairo, a popular cross-platform vector graphics library.

Python的Pyglet库可能适合您的需求。它允许您使用OpenGL,一种跨平台的图形API。您可以禁用消除锯齿并将屏幕区域捕获到缓冲区或文件中。此外,您还可以使用其事件处理,资源加载和图像处理系统。您也可以将它绑定到PIL(Python图像库),绝对是开罗,一个流行的跨平台矢量图形库。

I mention Pyglet instead of pure PyOpenGL because Pyglet handles a lot of ugly OpenGL stuff transparently with no effort on your part.

我提到Pyglet而不是纯PyOpenGL,因为Pyglet透明地处理了许多丑陋的OpenGL内容而不需要你付出任何努力。

A friend and I are currently working on a drawing program using Pyglet. There are a few quirks - for example, OpenGL is always double buffered on OS X, so we have to draw everything twice, once for the current frame and again for the other frame, since they are flipped whenever the display refreshes. You can look at our current progress in this subversion repository. (Splatterboard.py in trunk is the file you'll want to run.) If you're not up on using svn, I would be happy to email you a .zip of the latest source. Feel free to steal code if you look into it.

我和朋友正在使用Pyglet编写绘图程序。有一些怪癖 - 例如,OpenGL总是在OS X上进行双缓冲,因此我们必须绘制两次,一次用于当前帧,另一次用于另一帧,因为每当显示刷新时它们都会被翻转。您可以查看我们在此subversion存储库中的当前进度。 (主干中的Splatterboard.py是您要运行的文件。)如果您没有使用svn,我很乐意通过电子邮件向您发送最新来源的.zip。如果你研究它,请随意窃取代码。

#3


1  

If language choice is open, a Flash file created with Haxe might have a place. Haxe is free, and a full, dynamic programming language. Then there's the related Neko, a virtual machine (like Java's, Ruby's, Parrot...) to run on Mac, Windows and Linux. Being in some ways a new improved form of Flash, naturally it can draw stuff. http://haxe.org/

如果语言选择是打开的,则使用Haxe创建的Flash文件可能有一个位置。 Haxe是免费的,是一种完整的动态编程语言。然后是相关的Neko,一个在Mac,Windows和Linux上运行的虚拟机(如Java,Ruby,Parrot ......)。在某些方面,一种新的改进形式的Flash,自然它可以绘制东西。 http://haxe.org/

#4


0  

QT's Canvas an QPainter are very good for this job if you'd like to use C++. and it is cross platform.

如果您想使用C ++,QT的Canvas和QPainter非常适合这项工作。它是跨平台的。

There is a python binding for QT but I've never used it.

QT有一个python绑定但我从未使用它。

As for Java, using SWT, pixel level manipulation of a canvas is somewhat difficult and slow so I would not recommend it. On the other hand Swing's Canvas is pretty good and responsive. I've never used the AWT option but you probably don't want to go there.

至于Java,使用SWT,画布的像素级操作有点困难和缓慢,所以我不推荐它。另一方面,Swing的Canvas非常好并且反应灵敏。我从来没有使用AWT选项,但你可能不想去那里。

#5


0  

I would recommend wxPython

我会推荐wxPython

It's beautifully cross platform and you can get per pixel control and if you change your mind about that you can use it with libraries such as pyglet or agg.

它是精美的跨平台,你可以获得每像素控制,如果你改变主意,你可以使用pyglet或agg等库。

You can find some useful examples for just what you are trying to do in the docs and demos download.

您可以在docs和demos下载中找到一些有用的示例。

#1


3  

I just this week put together some slides and demo code for doing 2d graphics using OpenGL from python using the library pyglet. You can see my stuff here: http://tartley.com/?p=378

我本周刚将使用库pyglet从python中使用OpenGL进行2D渲染的幻灯片和演示代码放在一起。你可以在这里看到我的东西:http://tartley.com/?p = 378

It is very fast (relatively speaking, for python) I have managed to get around 1,000 independently positioned and oriented objects moving around the screen, each with about 50 vertices.

这是非常快的(相对来说,对于python)我已经设法获得大约1,000个独立定位和定向的对象在屏幕上移动,每个对象有大约50个顶点。

It is very portable, all the code I have written in this environment works on windows and Linux and mac (and even obscure environments like Pypy) without me ever having to think about it.

它非常便携,我在这个环境中编写的所有代码都适用于Windows,Linux和Mac(甚至像Pypy这样的模糊环境),而我不必考虑它。

Update: There are a bunch of newer posts on the same topic too: http://tartley.com/?cat=27

更新:同一主题上还有一些较新的帖子:http://tartley.com/?cat = 27

#2


2  

The Pyglet library for Python might suit your needs. It lets you use OpenGL, a cross-platform graphics API. You can disable anti-aliasing and capture regions of the screen to a buffer or a file. In addition, you can use its event handling, resource loading, and image manipulation systems. You can probably also tie it into PIL (Python Image Library), and definitely Cairo, a popular cross-platform vector graphics library.

Python的Pyglet库可能适合您的需求。它允许您使用OpenGL,一种跨平台的图形API。您可以禁用消除锯齿并将屏幕区域捕获到缓冲区或文件中。此外,您还可以使用其事件处理,资源加载和图像处理系统。您也可以将它绑定到PIL(Python图像库),绝对是开罗,一个流行的跨平台矢量图形库。

I mention Pyglet instead of pure PyOpenGL because Pyglet handles a lot of ugly OpenGL stuff transparently with no effort on your part.

我提到Pyglet而不是纯PyOpenGL,因为Pyglet透明地处理了许多丑陋的OpenGL内容而不需要你付出任何努力。

A friend and I are currently working on a drawing program using Pyglet. There are a few quirks - for example, OpenGL is always double buffered on OS X, so we have to draw everything twice, once for the current frame and again for the other frame, since they are flipped whenever the display refreshes. You can look at our current progress in this subversion repository. (Splatterboard.py in trunk is the file you'll want to run.) If you're not up on using svn, I would be happy to email you a .zip of the latest source. Feel free to steal code if you look into it.

我和朋友正在使用Pyglet编写绘图程序。有一些怪癖 - 例如,OpenGL总是在OS X上进行双缓冲,因此我们必须绘制两次,一次用于当前帧,另一次用于另一帧,因为每当显示刷新时它们都会被翻转。您可以查看我们在此subversion存储库中的当前进度。 (主干中的Splatterboard.py是您要运行的文件。)如果您没有使用svn,我很乐意通过电子邮件向您发送最新来源的.zip。如果你研究它,请随意窃取代码。

#3


1  

If language choice is open, a Flash file created with Haxe might have a place. Haxe is free, and a full, dynamic programming language. Then there's the related Neko, a virtual machine (like Java's, Ruby's, Parrot...) to run on Mac, Windows and Linux. Being in some ways a new improved form of Flash, naturally it can draw stuff. http://haxe.org/

如果语言选择是打开的,则使用Haxe创建的Flash文件可能有一个位置。 Haxe是免费的,是一种完整的动态编程语言。然后是相关的Neko,一个在Mac,Windows和Linux上运行的虚拟机(如Java,Ruby,Parrot ......)。在某些方面,一种新的改进形式的Flash,自然它可以绘制东西。 http://haxe.org/

#4


0  

QT's Canvas an QPainter are very good for this job if you'd like to use C++. and it is cross platform.

如果您想使用C ++,QT的Canvas和QPainter非常适合这项工作。它是跨平台的。

There is a python binding for QT but I've never used it.

QT有一个python绑定但我从未使用它。

As for Java, using SWT, pixel level manipulation of a canvas is somewhat difficult and slow so I would not recommend it. On the other hand Swing's Canvas is pretty good and responsive. I've never used the AWT option but you probably don't want to go there.

至于Java,使用SWT,画布的像素级操作有点困难和缓慢,所以我不推荐它。另一方面,Swing的Canvas非常好并且反应灵敏。我从来没有使用AWT选项,但你可能不想去那里。

#5


0  

I would recommend wxPython

我会推荐wxPython

It's beautifully cross platform and you can get per pixel control and if you change your mind about that you can use it with libraries such as pyglet or agg.

它是精美的跨平台,你可以获得每像素控制,如果你改变主意,你可以使用pyglet或agg等库。

You can find some useful examples for just what you are trying to do in the docs and demos download.

您可以在docs和demos下载中找到一些有用的示例。