Forum: Inkscape crisp lines and floating point

Aca6f054b2112b41afb84dca542ce143?d=identicon&s=25 "Máirín Duffy" <duffy@fedoraproject.org> (Guest)
on 2012-04-16 02:48
(Received via mailing list)
Hi,

I need a sanity check from you, my fellow Inkscape users, if you don't
mind:

Draw a 1 px straight vertical line using the pen tool, holding down Ctrl
to make sure it's straight.

Is there any way to do this such that the line does not end up on an X
value that is X.5, where X is any integer?

Same for a 1 px straight horizontal line - no matter where I click, no
matter which snapping options I enable, that sucker will only land on Y
values of something + 0.5.

Is this right? Is there anyway to avoid this? I've trained myself to
manually go in and delete the 0.5 and not even think about it, but I'm
trying to explain something to a new Inkscape user and I feel quite
silly explaining my odd way of going in to the X and Y coordinate boxes
and erasing the .5 off the end of the number to her.

Thanks,
~m
765d28cd3f038cc3784150523be9361c?d=identicon&s=25 Johan Engelen (Guest)
on 2012-04-16 12:48
(Received via mailing list)
On 16-4-2012 2:28, Mirn Duffy wrote:
>
> Same for a 1 px straight horizontal line - no matter where I click, no
> matter which snapping options I enable, that sucker will only land on Y
> values of something + 0.5.
>
> Is this right? Is there anyway to avoid this? I've trained myself to
> manually go in and delete the 0.5 and not even think about it, but I'm
> trying to explain something to a new Inkscape user and I feel quite
> silly explaining my odd way of going in to the X and Y coordinate boxes
> and erasing the .5 off the end of the number to her.

I guess you are using the "visual bounding box" (preferences -> tools).
The path itself is at an integer coordinate. But because the stroke
width is 1 px, the path spills out 0.5 px on both sides of the
coordinates specified for the path. The X and Y coordinates in the
toolbar correspond to the boundingbox values. (so you see a width of 1
px, for example).

I don't know exactly what you want to end up with. If you want your path
to align exactly with pixels, I think you want the path itself to be at
integer+0.5 (!!!). To do this, you could use a grid that is set to 0.5
px spacing, and then a major grid line every 2 lines. The major lines
will then be pixel boundaries, and you can snap your paths to the minor
grid lines at 0.5px.

Cheers,
   Johan
Aca6f054b2112b41afb84dca542ce143?d=identicon&s=25 "Máirín Duffy" <duffy@fedoraproject.org> (Guest)
on 2012-04-17 03:27
(Received via mailing list)
On Mon, 2012-04-16 at 12:47 +0200, Johan Engelen wrote:
> I guess you are using the "visual bounding box" (preferences -> tools).

I don't think I ever modified this so it must be the default setting?

Oddly, my 1 px line is at .00 x .00 coordinates when I turn on geometric
bounding box but the line is blurry / inbetween pixels. If I make the
coordinates .05 x .05 then the line is crisp. (?!)

> The path itself is at an integer coordinate. But because the stroke
> width is 1 px, the path spills out 0.5 px on both sides of the
> coordinates specified for the path. The X and Y coordinates in the
> toolbar correspond to the boundingbox values. (so you see a width of 1
> px, for example).
>
> I don't know exactly what you want to end up with.

I think if the pen tool is set by default to draw 1 px and it is
impossible to draw a crisp, pixel-grid aligned 1 px wide (or any odd
integer width) line, it's a bug, isn't it?

> If you want your path
> to align exactly with pixels, I think you want the path itself to be at
> integer+0.5 (!!!). To do this, you could use a grid that is set to 0.5
> px spacing, and then a major grid line every 2 lines. The major lines
> will then be pixel boundaries, and you can snap your paths to the minor
> grid lines at 0.5px.

It just seems odd to me that it's not possible to draw a straight
pixel-grid aligned line in Inkscape out-of-the-box. Thanks for the
workarounds and for confirming I'm not crazy though, I thought I must be
missing something.

~m
Bd0203dc8478deb969d72f52e741bd4f?d=identicon&s=25 Daniel Baird (Guest)
on 2012-04-17 03:58
(Received via mailing list)
2012/4/17 Mirn Duffy <duffy@fedoraproject.org>

> On Mon, 2012-04-16 at 12:47 +0200, Johan Engelen wrote:
> > I guess you are using the "visual bounding box" (preferences -> tools).
>
> I don't think I ever modified this so it must be the default setting?
>
> Oddly, my 1 px line is at .00 x .00 coordinates when I turn on geometric
> bounding box but the line is blurry / inbetween pixels. If I make the
> coordinates .05 x .05 then the line is crisp. (?!)
>
>
I think I understand what's going on.. a square pixel is 1.0 pixels
wide.
 For a one pixel wide line to be "pixel aligned", it should be centered
on
the pixel, meaning the line's middle needs to be at 0.5.

If you think of a pixel as being a square with corners at (0,0), (0,1),
(1,1) and (1,0) then you can see that the coordinates of a line going
through the centre of that pixel needs to be at 0.5.

I'll try to do some ascii art..

(0,1)        (1,1)       (2,1)
  +-----------+-----------+
  |           |           |
  |  a pixel  |  another  |
  |           |   pixel   |
  |           |           |
  |           |           |
  +-----------+-----------+
(0,0)        (1,0)       (2,0)

See how a line that's one pixel wide, if you want it to be drawn on just
one pixel rather than overhanging across two pixels, needs to be through
the centre of the pixels at x=0.5.

Cheers
Aca6f054b2112b41afb84dca542ce143?d=identicon&s=25 "Máirín Duffy" <duffy@fedoraproject.org> (Guest)
on 2012-04-17 04:35
(Received via mailing list)
On Tue, 2012-04-17 at 11:57 +1000, Daniel Baird wrote:

> See how a line that's one pixel wide, if you want it to be drawn on
> just one pixel rather than overhanging across two pixels, needs to be
> through the centre of the pixels at x=0.5.

Thanks for the explanation, hopefully others reading will be able to
follow better than my cavewoman descriptions of the problem now. :)

I wonder if it should be expected that Inkscape behaves this way, or
should it have some way to deal with these situations? It's just that,
in the course of my teaching Inkscape to beginners, you'd think drawing
a straight line would be easy-peasy basics, and inevitably the beginners
notice their lines are mushy compared to other Inkscape work and I have
to try to explain this... while it's not so difficult a concept, it's
not exactly something you should have to think about when creating a
drawing or a diagram or whatnot, is it?

E.g., I think we also have the issue that when you add a stroke to a
path, you can't switch the stroke from being centered along the outer
edge of the path to being along the outer part or the inner part as a
stroke style option, correct? I wonder if the solution to that issue
could also help solve this 'I can't draw a clean straight line
out-of-the-box' issue.

By the way, in no way do I mean to be overly critical of Inkscape, I
love it, it's my favorite program ever, and it always gets the job done
for me. I'm finding it challenging to teach creating pixel-aligned
artwork to others is the problem, perhaps other software they've used
handled this in a different way.

~m
8194273c931e44d4ade233c325cb1c9a?d=identicon&s=25 Marcel Tippmann (Guest)
on 2012-04-17 08:26
(Received via mailing list)
Attachment: ITMA_ASIA___CITME_2012.jpg (300 KB)
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
56ec01a5220915dd463db71ba225796a?d=identicon&s=25 Jurgen Gaeremyn (Guest)
on 2012-04-18 18:29
(Received via mailing list)
Okay... now if you're in an educational setting, it's quite easy to
motivate the design decision Inkscape makes.

Imagine your 1px wide line you're drawing... and you draw it on a grid
that it pixel aligned... if you expect to have the border aligned with
the grid, should Inkscape put it over or under the pixel?

Now imagine you create a shape (logo) and you change the stroke width...
(f.e. to 5 px) What's the behaviour you would expect? Should the stroke
shrink the inner of the image? Because that's what will happen if you
would consider the line edge to be the reference.

Grtz,
Jurgen
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.