Hi all. Is there any easy way to draw a dotted stroke?
Just want to draw an empty rectangle (bar chart) with a dotted line around its borders (stroke), instead of solid. Don't see any easy way to do that. No shortcuts?
now write one function A (name it dottedLine)that can take two points and connect them with a dotted line (using lerp)
then write one function B that is called rectDotted which takes x,y,width and height and calls function A 4 times like
dottedLine (x,y,x+w,y); // upper line -
dottedLine (x,y,x,y+h); // line left |
dottedLine (x+w,y,x+w,y+h); // line right |
dottedLine (x,y+h, x+w,y+h); // lower line -
Answers
you need this :
https://www.processing.org/reference/lerp_.html
now write one function A (name it dottedLine)that can take two points and connect them with a dotted line (using
lerp
)then write one function B that is called rectDotted which takes x,y,width and height and calls function A 4 times like
Ah, I see. Thanks. Very manual! Would be cool to have a strokeline('dotted') method built in, but this'll do just fine. Thx.
An old thread but i came across it during a search, so other people must. Here is my solution (l = line in px, g = gap in px):
@Gazzeh -- thank you -- could you please also edit your comment (gear icon) and format your code? (highligh, CTRL-o): https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text#latest
Also of interested, an open issue on dotted lines:
@jeremydouglass - Thanks for the link i tried editing 4 times but couldn't get it. Done now
@Gazzeh Thaxs for sharing.
@MirielLind Your line function would be very useful for this post after some minor modifications: https://forum.processing.org/two/discussion/comment/93734/#Comment_93734
Kf