JavaFX: How can a Path be painted on a GraphicsContext?

前端 未结 1 672
青春惊慌失措
青春惊慌失措 2021-01-14 17:31

JavaFX provides both low-level path painting methods on a GraphicsContext and a high-level Path node.

I want to store shapes in classes and draw them in a Grap

相关标签:
1条回答
  • 2021-01-14 17:57

    Do I have to iterate over the Path elements by hand and translate them into low-level GraphicsContext methods?

    Yes. You will need to write a translator to take data extracted from a Path and invoke appropriate graphics context methods (see the Path Rendering methods), for example beginPath(), moveTo(), lineTo(), closePath(), fill, stroke(), etc.


    Rather than using a Path, you could perhaps use an SVGPath. It is easy to translate an SVGPath from a Scene graph node data to a GraphicsContext method - you can just do gc.appendSVGPath(svgPath.getContent()).

    0 讨论(0)
提交回复
热议问题