0

Is there a simple way to draw a squiggly line across a path in JavaFX? Something like the horizontal line in enter image description here

(Source: https://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Electron-positron-annihilation.svg/2000px-Electron-positron-annihilation.svg.png)

I know I can achieve this by breaking up the path to multiple parts, and drawing each with a cubic bezier curve, but I was hoping there was an easier way.

hotzst
  • 6,834
  • 8
  • 36
  • 59
Itai
  • 6,331
  • 6
  • 24
  • 48
  • You've got a svg; It would be easy to use `SVGPath` to create the path (Which of course uses cubic Bézier curves...). The only way to do this not using Bézier curves that comes to my mind is using the `DisplacementMap` effect on a `Line` but this results in horrible quality and isn't really easier. Using Bézier curves isn't that complicated. It can be done with approx 40 LOC for any given start/end point / wave height / wave length. – fabian Jan 27 '16 at 18:44
  • Yes, I just thought maybe there is a built-in way. Take dashes for example - you could easily accomplish a dashed line with interchanging `MoveTo` and `LineTo`, but JavaFX provides a built in which is much simpler to use. – Itai Jan 27 '16 at 19:15

0 Answers0