简体   繁体   English

如何使用 JavaFX 8 在画布上有效地绘制箭头?

[英]How to draw efficiently arrows on a canvas with JavaFX 8?

I am looking for a very simple and efficient way to draw arrows in JavaFX 8, what is the best way to achieve that (performance-wise if let's say I'm willing to draw hundreds or thousands of them)?我正在寻找一种在 JavaFX 8 中绘制箭头的非常简单有效的方法,实现这一目标的最佳方法是什么(如果说我愿意绘制成百上千个箭头,那么在性能方面)?

箭头

I've heard using a Canvas to draw on it is quite efficient.我听说使用 Canvas 进行绘制非常有效。

However, I do not know whether the best implementation is to go with:但是,我不知道最好的实现是否与:

The best method depends on various factors which we don't know so it's difficult to give a clear answer here.最好的方法取决于我们不知道的各种因素,因此在这里很难给出明确的答案。 I will try to give a few general hints though and you will have to decide yourself if these are applicable to your problem.不过,我将尝试给出一些一般性提示,您必须自行决定这些提示是否适用于您的问题。

For mass drawings using the canvas sounds like a good idea.对于使用画布的大量绘图听起来是个好主意。

Simple lines and rectangles are much faster than paths (also polylines and polygons).简单的线条和矩形比路径(还有折线和多边形)快得多。

Some line joins/caps are faster than others.某些行连接/大写比其他行更快。

Avoid transparency.避免透明。

It may be helpfull to consider specialized approaches like, eg creating images of your arrows and then just painting these images.考虑专门的方法可能会有所帮助,例如创建箭头的图像,然后只是绘制这些图像。

Michael迈克尔

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM