Objects not snapping properly

Post questions on how to use or achieve an effect in Inkscape.
DR33ss
Posts: 1
Joined: Thu Feb 23, 2017 9:56 pm

Objects not snapping properly

Postby DR33ss » Thu Feb 23, 2017 10:07 pm

I need to have several objects next to each other, but I can't get them to snap properly, there's always a little space between them. Can anybody tell me how to position those hexagons so that there is no space between them?
try5.png
try5.png (5.47 KiB) Viewed 1884 times

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

Re: Objects not snapping properly

Postby theozh » Fri Feb 24, 2017 12:24 am

Hi DR33ss, welcome to the forum!
I guess your snapping is ok. If I remember correctly it is probably a display/rendering artefact.
Maybe this helps...
https://inkscape.org/en/learn/faq/#ther ... n-patterns
Win7/64, Inkscape 0.92.2

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

Re: Objects not snapping properly

Postby Lazur » Fri Feb 24, 2017 5:40 am

Yes, that's hard-coded with the rendering. "Anti-aliasing gap issue".

The only complete solution (no gap at all) is to slightly overlap the objects -- only a 1 or 2 pixel overlap is necessary. Although if the objects contain any transparency, that won't work. If they are partially transparent, a very small amount of blurring could help, in certain situations.


Would add that the 1-2 pixel overlap has to be actual screen pixels with the current renderer. That is important because a 2 pixel overlapping still produces a rendering gap if you zoom out the drawing.

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

Re: Objects not snapping properly

Postby brynn » Fri Feb 24, 2017 2:54 pm

Lazur wrote:Yes, that's hard-coded with the rendering. "Anti-aliasing gap issue".

The only complete solution (no gap at all) is to slightly overlap the objects -- only a 1 or 2 pixel overlap is necessary. Although if the objects contain any transparency, that won't work. If they are partially transparent, a very small amount of blurring could help, in certain situations.


Would add that the 1-2 pixel overlap has to be actual screen pixels with the current renderer. That is important because a 2 pixel overlapping still produces a rendering gap if you zoom out the drawing.


Oh, I didn't realize that zooming affected this gap. Should I change the FAQ answer? And how many pixels should it suggest? Or should it simply explain that zooming affects it?

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

Re: Objects not snapping properly

Postby Lazur » Fri Feb 24, 2017 7:36 pm

Not sure, needs testing.
Like, compare these two: example 1 and example 2.
See how the example 1 is fading to transparent("white") at the centre as the overlapping goes less and less. By zooming far out the pattern remains.
While on the example 2 the overlapping is way larger than the visible part of the tile so at the point where you would see rendering gap you wouldn't see the tile itself.

But the faq can be improved nonetheless.
e) suggests exporting @ 90 dpi instead of 96, and, which still wouldn't solve the problem if b) wasn't used (and exporting area also aligned to the same grid). Meaning diagonal edges would still be off.

The filtering solution in f) only adds a colormatrix which enlarges the alpha value of the object by 180%. Doesn't really work with semi-transparent ones.
Idea pushed forward would be eliminating all transparencies, resulting in aliased edges -pixellize filter does that, sort of.
In general it has the same concept as duplicating the objects atop eachother a few times. Theoretically that wouldn't produce a full coverage of the gap ever.
Pixellize filter uses a colormatrix as well, although that could have been updated to a component transfer in discrete mode on the alpha values, which would really make the "alpha cut".


In general the problem is related to anti-aliasing and alpha compositing. By a different compositing method gaps can be filled up, like here. Each objects were pulled in with an image filter pimitive and composited in arithmetic mode. A downside of it is when the objects overlap it produces a white fill. (See the head on the right.)
It is very tedious filter to rig, probably an extension could generate it...

Somehow cannot reproduce the exact same effect with a simpler filter, by compositing to the background image.
Although it works better, it's not 100% perfect. See here.

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

Re: Objects not snapping properly

Postby brynn » Fri Feb 24, 2017 9:12 pm

Hhm, will have to look at this again when I'm not so tired. This weekend probably.

Definitely the FAQ needs to be fixed, to change 90 dpi to 96. (I should probably check the whole faq, because there might be a couple of other references to 90 dpi.) And correct, the pixel snap is only recommended when the drawing is made only of horizontal and vertical lines. Pixelsnap can't affect diagonal lines, although sometimes it still helps a little bit, depending on the drawing.

For the last 3 links you gave, I need to study more when I'm not sleepy. But one problem is the last link. On the OCA page, I see 3 yellow rectangles, lying on an angle. When I click on it, I can see that the rectangles are made of 2 squares each. But instead of 3, there are only 2, and one of them the squares are pulled apart. I'm not sure if the apparent difference is related to my browser maybe not displaying properly, or exactly what's happening. I wouldn't think it would be possible for the OCA site to be redirecting to a different image. But it does seem like different images, between what I see on the info page, and the image when I click on it.

Anyway, thanks for the overview. When I'm fresh, I will study and try to find a way to incorporate the info into the faq.

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

Re: Objects not snapping properly

Postby Lazur » Fri Feb 24, 2017 9:28 pm

That example image shows pairs of squares next to eachother.

On the left, they are not filtered -see gap in between.

In the middle, a compositing filter is added -object is blend with the background image,
composited out from the original object, and that composited in arithmetic mode with the original object.
As a result the gap is almost filled up.

The object on the right is a single filtered square, where the other square was pulled in with an image filter primitive.
As that filter primitive uses the top left corner of the page as an origin, the pulled in object needed to be translated to a different position than it appears -was moved to a layer and the layer's visibility switched off.

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

Re: Objects not snapping properly

Postby brynn » Sun Feb 26, 2017 4:53 am

Here's what I mean about the last link. Are those different images? I thought the first page was a thumbnail of the SVG. But they look different to me.
Attachments
gap2.png
gap2.png (35.78 KiB) Viewed 1763 times
gap1.png
gap1.png (102.66 KiB) Viewed 1763 times

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

Re: Objects not snapping properly

Postby brynn » Sun Feb 26, 2017 5:15 am

Ok, for the faq. I'll fix the 90 vs 96 issue.

For overlap vs zooming, I'll suggest that the user should test whether the gap is fixed, at the zoom level where they will be using the image.

If you have a filter which does a better job than than the existing Stitch filter, I could add a link to it. But it can't be something very heavy, like some of your filters are. It would need to be something that most people can use, without bogging down performance too much.

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

Re: Objects not snapping properly

Postby Lazur » Sun Feb 26, 2017 6:00 am

brynn wrote:Here's what I mean about the last link. Are those different images? I thought the first page was a thumbnail of the SVG. But they look different to me.



The thumbnail is a generated image of a 2400 px / 2400 px png, using inkscape 0.91 -os something similar. Noticed that some thumbnails got a checkerboard background, so not sure if they changed the thumbnail generator to inkscape 0.92 because other images with the changed gradient mesh code won't show up.

What you see "moved" is the actual svg -rendered by firefox.
That is, a firefox bug -inkscape renders the same as chrome this case.
(Although chrome uses another approach on clipping -if you clip a group of objects, where two paths with different fills were used overlapping the clip edge, both show up. Where inkscape renders only the top object's fill, resulting in a clean edge.)

Now at a second glance, chrome renders the second pair of squares with no gaps at all. That is a quite sleek filter. Maybe it produces a bit aliased edges? Would need more testing...

On the "stitch path" filter, a pixellize "could be" the limit of the concept. However which filter would need updating, switching the colormatrix to component transfer filter primitive instead.
However that (component transfer) is rendering off in 0.91 due to a "transparent black" bug and it's accuracy could be improved...
And that basically such an "alpha cut" couldn't work if some of the objects were semi-transparent.

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

Re: Objects not snapping properly

Postby Lazur » Sun Feb 26, 2017 6:30 am

Also see my comment on that 12 year old bug report.

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

Re: Objects not snapping properly

Postby brynn » Sun Feb 26, 2017 8:57 am

Wow, per-object anti-aliasing was probably a pretty far out wish 12 years go! But now that we just got the option to disable anti-alias per document, maybe it's closer than ever now??


Return to “Help with using Inkscape”