Shapes with dashed lines

Post questions on how to use or achieve an effect in Inkscape.
Raspi
Posts: 229
Joined: Fri Oct 21, 2016 12:51 am

Shapes with dashed lines

Postby Raspi » Tue Jan 24, 2017 11:59 pm

I want to draw a bunch of triangles with dashed lines.

When i apply the Dashes in the Stroke Style Tab, i get Dashes but they are distributed equally.
Even with Pattern Offset, its not possible to get it all equally distributed.

This is not behaviour im used to from Illustrator.

When i try to use the Pap LPE, i can distribute the dashes better equally with Repeated Stretched, but now im missing the tips of the triangle.

So i developed a complicated routine, generating the gaps between the dashes with the Interpolate Subpaths LPE and cloning one side of my dashes in a circle.
Its fully editable but a bit overkill.
Okay for a single triangle but has problems when i need a lot of them.
Attachments
TriDash.png
TriDash.png (4.6 KiB) Viewed 6583 times
PAP.png
PAP.png (5.99 KiB) Viewed 6583 times

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Shapes with dashed lines

Postby Lazur » Wed Jan 25, 2017 12:46 am

An idea that might work for you.
Select all 3 nodes, add new nodes to the segment midpoints, then split those new nodes.

This way the length mismatch error is distributed evenly (-and multiplied).
dash.svg
(3.71 KiB) Downloaded 237 times

Raspi
Posts: 229
Joined: Fri Oct 21, 2016 12:51 am

Re: Shapes with dashed lines

Postby Raspi » Wed Jan 25, 2017 1:02 am

Lazur wrote:An idea that might work for you.
Select all 3 nodes, add new nodes to the segment midpoints, then split those new nodes.

This way the length mismatch error is distributed evenly (-and multiplied).

Sounds good in theory but is not what i need.

This is what i want to achieve:
Attachments
TriExample.png
TriExample.png (25.76 KiB) Viewed 6564 times

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Shapes with dashed lines

Postby Lazur » Wed Jan 25, 2017 1:47 am

Getting brute forced but with custom markers you can achieve something similar.
(As probably would't render well outside inkscape.)

dash2.svg
(27.16 KiB) Downloaded 233 times

Raspi
Posts: 229
Joined: Fri Oct 21, 2016 12:51 am

Re: Shapes with dashed lines

Postby Raspi » Wed Jan 25, 2017 1:57 am

Lazur wrote:Getting brute forced but with custom markers you can achieve something similar.
(As probably would't render well outside inkscape.)

dash2.svg

Maybe a bit too complicated.

Im not clear on what the marker looks like ?
So its a rectangle for the dash, and another shape for the corner ?

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Shapes with dashed lines

Postby Lazur » Wed Jan 25, 2017 2:29 am

Stroke set with dashes and with butt caps.
To ensure the symmetric look the path nodes were split up at the triangle corners as well, and path directions reversed accordingly.
This results in a symmetrical dashing, however the joins are missing.
If round caps would be ok they could hide those in the triangle corners.
But as you want the look of miters, only other option by the stroke style panel is adding markers.
There are three position options for them -but every path does have only one start and one end node, so you cannot put markers at the triangle corners on one path.
That's why the path is now broken apart and the previous subpaths grouped together.
Dashed stroke style with butt cap is added to the group attribute, while custom markers are added to the two noded paths inside the group.
For the symmetrical look two kind of marker is necessary for the corners. Probably should have added like a rounded or diamond shaped marker to the other ends of these paths (and adjust the existing ones) because now there is a rendering gap at the side's "midpoints".

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: Shapes with dashed lines

Postby theozh » Thu Jan 26, 2017 7:46 am

Do you explicitely need dashed lines or are you satisfied with something which looks like dashed lines?
In the latter case you could just cover the sides lines with appropriate white "gaps".
And which parameters do you want to keep constant and which should be varied? Line width, gap width, line segment length?
If you use clones for the "gaps" for each side it will be pretty easy to vary and adjust these parameters while keeping a symmetric look.
DashedPolygons.png
DashedPolygons.png (4.93 KiB) Viewed 6470 times
Win7/64, Inkscape 0.92.2

Raspi
Posts: 229
Joined: Fri Oct 21, 2016 12:51 am

Re: Shapes with dashed lines

Postby Raspi » Thu Jan 26, 2017 7:53 am

theozh wrote:Do you explicitely need dashed lines or are you satisfied with something which looks like dashed lines?
In the latter case you could just cover the sides lines with appropriate white "gaps".
And which parameters do you want to keep constant and which should be varied? Line width, gap width, line segment length?
If you use clones for the "gaps" for each side it will be pretty easy to vary and adjust these parameters while keeping a symmetric look.
DashedPolygons.png

This is exactly the "complicated routine" i developed and talked about in my first post.

Shame its so hard to do, in Illustrator you just click the dashed line brush and the program does it all for you.

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: Shapes with dashed lines

Postby theozh » Thu Jan 26, 2017 8:06 am

OK, I haven't used Interpolate Subpaths LPE and no circle. Just moved the rotation center of a prototype "group of gaps" to the rotation center of the polygon, clone it (n-1)times and rotate the clones by 360°/n, where n is the number of corners.
Win7/64, Inkscape 0.92.2

Raspi
Posts: 229
Joined: Fri Oct 21, 2016 12:51 am

Re: Shapes with dashed lines

Postby Raspi » Thu Jan 26, 2017 8:17 am

theozh wrote:OK, I haven't used Interpolate Subpaths LPE and no circle. Just moved the rotation center of a prototype "group of gaps" to the rotation center of the polygon, clone it (n-1)times and rotate the clones by 360°/n, where n is the number of corners.

If you add the Interpolate Subpaths LPE its even more customable. You just combine two gaps and adjust with the LPE to your wishes.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Shapes with dashed lines

Postby brynn » Thu Jan 26, 2017 1:47 pm

I have run into this kind of problem too, and wish for a better solution.

It seems like we need a way to calculate a custom dash pattern, with solid space and empty space which can be customized, so that it comes out even, for specific path lengths. In the past, I have used only trial and error, with different dash patterns, and different offsets, until I find something I can tolerate. But I've never found any kind of precise solution.

I've never tried this solution with interpolate subpaths, because it's just too much work. And I only use Inkscape as a hobby. But most of the time when I want a dashed line, I want it to be symmetrically spaced.

Maybe worth a feature request??

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: Shapes with dashed lines

Postby theozh » Thu Jan 26, 2017 5:43 pm

brynn wrote:It seems like we need a way to calculate a custom dash pattern, with solid space and empty space which can be customized, so that it comes out even, for specific path lengths. ... Maybe worth a feature request??

Agree...
If you mark your triangle and press Shift+Ctrl+X you can manually edit the style properties as you like, i.e. the parameter "stroke-dasharray:"
Then you have real dashed lines and not just overlying gaps. But for sure, trial and error is not very efficient and convenient.
It should be possible to write a simple extension to calculate a symmetric pattern based on the path information. Maybe somebody knows how to do this and is willing to do that...?
XML-Editor.png
XML-Editor.png (14.09 KiB) Viewed 6423 times
Win7/64, Inkscape 0.92.2

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Shapes with dashed lines

Postby Lazur » Thu Jan 26, 2017 10:03 pm

In your example there are tree equal sides of the triangle, meaning you have three equal length path segments.
What if it's a scalene triangle without a lowest common multiple in their side lengths?

But even if each sides are equal long, let's say the dasharray -always starting at the start-end node of the path- is somehow symmetrical to the midpoint of the first side. What would guarantee the other sides will be symmetrical too?

The dasharray only tells the renderer the ration between the stroke segments and spaces in between but the stroke width is another factor that is connected with the actual lengths.
The sides are need to be "cut" to equal long parts by the dashes, which would result in a strict dasharray setting for a stroke width.
You try to change the stroke width, the dasharray would need to be updated every time.
Should it then have the same gap lengths as before, or the same stroke lengths?
You can't preserve the same dasharray because of it starting from the start-end node of the path
and not separately on each path segment's midpoint symmetrically -which would result in wrong segment lengths in the corners of the triangle by the way.

There is no trivial solution for that with the svg's stroke dasharray rendering model alone. Wondering what illustrator does and how they save such dashed triangles to svg-s or to pdf-s for that matter, and how illustrator responds changing the stroke widths on such a triangle.

Raspi
Posts: 229
Joined: Fri Oct 21, 2016 12:51 am

Re: Shapes with dashed lines

Postby Raspi » Thu Jan 26, 2017 11:27 pm

This image is what started my experiments.
Attachments
dashes.jpg
dashes.jpg (120.07 KiB) Viewed 6392 times

Raspi
Posts: 229
Joined: Fri Oct 21, 2016 12:51 am

Re: Shapes with dashed lines

Postby Raspi » Thu Jan 26, 2017 11:49 pm

Lazur wrote:There is no trivial solution for that with the svg's stroke dasharray rendering model. Wondering what illustrator does and how they save such dashed triangles to svg-s or to pdf-s for that matter, and how illustrator responds changing the stroke widths on such a triangle.

Here is a screnshot how AI handles the dashes, you dont even need a specific brush, its build in the Stroke dialogue.
Im also attaching a svg made in AI. Everything is automatically grouped (standard in AI) and each element is a individual stroke.
Attachments
AI-Dashes-Screenshot.png
AI-Dashes-Screenshot.png (61.99 KiB) Viewed 6390 times
AI-Dashes.svg
(1.5 KiB) Downloaded 213 times

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Shapes with dashed lines

Postby Lazur » Fri Jan 27, 2017 12:12 am

I see. So they don't just use a custom dasharray either but sectionate the path at new generated nodes too.
Adding custom dasharray to each side separately and adding no dasharray to the corners.

Guess it can be covered by a live path effect.
Would suggest making a bug report for the feature request at the bug tracker.
Edit: made a bug report here.
Click the "this bug affects me" button and add some notes/attach files if I missed something.


With the svg coming from ai the stroke width resizing still messing up the dasharray, a live update of those generated sections would be necessary.
AI-Dashes stroke width II.svg
(5.02 KiB) Downloaded 223 times


Edit 2: the report already got the attention of Jabiertxof. Definitely was worth posting.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Shapes with dashed lines

Postby brynn » Fri Jan 27, 2017 8:44 pm

How awesome is that! I mean jabierxtof jumping right on that feature request!

Raspi
Posts: 229
Joined: Fri Oct 21, 2016 12:51 am

Re: Shapes with dashed lines

Postby Raspi » Fri Jan 27, 2017 11:41 pm

Lazur wrote:Edit 2: the report already got the attention of Jabiertxof. Definitely was worth posting.

Maybe its so simple, he can do it in his coffeebreak ;)

jabiertxof
Posts: 184
Joined: Wed Feb 06, 2013 6:47 am

Re: Shapes with dashed lines

Postby jabiertxof » Sun Apr 01, 2018 11:19 am

Hi I Just commit a LPE on trunk. Thanks Lazur for the feedback.
https://archive.org/details/dash-stroke-lpe


Return to “Help with using Inkscape”