使用 Java 的简单 2D 图形的最佳 API

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/207938/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 11:22:59  来源:igfitidea点击:

Best API for simple 2D graphics with Java

javagraphicsjava-2d

提问by bjwbell

I'm not sure what the best api for simple 2d graphics with Java is. I know java.awt.Graphics2Dwas the standard but has it been replaced? Swing is the new API for Java GUI apps but it seems a bit heavy for what I want. What I really want is something like the C SDL library.

我不确定使用 Java 进行简单 2d 图形的最佳 api 是什么。我知道java.awt.Graphics2D是标准,但它被取代了吗?Swing 是 Java GUI 应用程序的新 API,但对于我想要的东西来说似乎有点沉重。我真正想要的是类似于 C SDL 库的东西。

采纳答案by Chris Jester-Young

Java 2D(Graphics2Dand friends) is indeed the best choice that I know of. Swing is actually implemented on top of Java 2D, so yes, if you want non-GUI-type graphics, Java 2D is the way to go.

Java 2DGraphics2D和朋友们)确实是我所知道的最佳选择。Swing 实际上是在 Java 2D 之上实现的,所以是的,如果您想要非 GUI 类型的图形,Java 2D 是要走的路。

回答by Buggieboy

A Java binding to SDL can be found here:

可以在此处找到与 SDL 的 Java 绑定:

http://sdljava.sourceforge.net/

http://sdljava.sourceforge.net/

回答by i30817

If you want to have the least work possible if you're building a game (or even if not) use http://slick.cokeandcode.com/

如果您想在构建游戏时尽可能少地工作(或者即使不是),请使用http://slick.cokeandcode.com/

UPDATE: The link has since changed to http://slick.ninjacave.com/

更新:此链接已更改为http://slick.ninjacave.com/

回答by Spoike

Processing.orghas some good easy-to-use 2D stuff (and 3D). It has a PAppletclass that implements Applet from AWT together with a bunch of useful operations and works well together with Java2D.

Processing.org有一些很好的易于使用的 2D 内容(和 3D)。它有一个PApplet类,它实现了来自 AWT 的 Applet 以及一堆有用的操作,并且与Java2D一起工作得很好。

If you just want to mess around with 2d graphics it has a "sketchpad IDE" where you don't need to put it in your java IDE if you just want to experiment with it.

如果你只是想处理 2d 图形,它有一个“sketchpad IDE”,如果你只是想试验它,你不需要把它放在你的 java IDE 中。

回答by Muhammad Asaduzzaman

Piccolocan be a good choice for drawing graphics. It is a 2D graphics toolkit that supports zoomable user interface. Available for both Java and .Net.

Piccolo是绘制图形的不错选择。它是一个支持可缩放用户界面的 2D 图形工具包。适用于 Java 和 .Net。