dash effect

27 views
Skip to first unread message

mygu...@gmail.com

unread,
Sep 25, 2018, 1:35:22 PM9/25/18
to CodenameOne Discussions
I would like to know if I can make an effect similar to what the DashPathEffect object does in Android.

Thomas

unread,
Sep 25, 2018, 3:27:50 PM9/25/18
to CodenameOne Discussions
Unfortunatly the CN1 Stroke do not support dash patterns.
So unless your path is really basic (like a rectangle or a few straight lines), in which case you can probably paint the dash effect "by hand", (this is the approach used to render dashed components borders in CN1), it would be quite difficult.

mygu...@gmail.com

unread,
Oct 2, 2018, 6:23:01 AM10/2/18
to CodenameOne Discussions
Ok thanks,

In the end I used Bresenham's algorithm http://www.codecodex.com/wiki/Bresenham%27s_line_algorithm#Java there are more algorithms but to make a straight line I opted for this.

To make the dash pattern I used the lineTo and moveTo functions of GeneralPath.


Captura.JPG
Reply all
Reply to author
Forward
0 new messages