I'm working on a 60x60 pixel icon in Inkscape 0.48. Snap is on, grid is 1px by 1px. But I notice that it's the node of the path that gets snapped to the grid as I draw a 1px wide path, as shown below:
As the red circle shows, the positioning of the path is actually on a 0.5 pixel.
What happens is that even when I export at 1:1 pixels, 90 dpi...
I get a blurry line in the resulting .png, or one that is partially transparent:
In order to get a nice sharp line, I have to manually set the position to a .0 pixel boundary, or position the line in between the grid lines using alt-arrows.
The FAQ says all you have to do is snap, and export at 1:1 size, aka. 90 dpi to get a sharp PNG. But as I show above, this doesn't work for me.
Anybody know why?
Aliasing even when snapped and 90 dpi
Re: Aliasing even when snapped and 90 dpi
See e.g. this comment about offsetting the grid origin, as well as this article on designing icons in Inkscape (where pixelgrid-aligned paths matter): Martin's Chronicles: Echo Icon Common Mistakes - Blurry Icons
Re: Aliasing even when snapped and 90 dpi
Tip: when modifying the grid origin in the 'Document Properties > Grids' pane, you might trip over a known UI bug with an easy workaround - for details see the comments in Bug #561503 “Setting grid origin has no effect”.
Re: Aliasing even when snapped and 90 dpi
I had discovered the grid origin (proud of self!) but the results didn't seem quite right:
Aliasing still seems to be happening in the Y direction. Plus, the technique only makes odd-width lines look OK. Evens alias.
Seems to be the most useful snapping behaviour would be to have Inkscape snap the outside boundary of the shape/path to the pixel. That way no matter what the size, at least one edge would be sharp.
Aliasing still seems to be happening in the Y direction. Plus, the technique only makes odd-width lines look OK. Evens alias.
Seems to be the most useful snapping behaviour would be to have Inkscape snap the outside boundary of the shape/path to the pixel. That way no matter what the size, at least one edge would be sharp.
Re: Aliasing even when snapped and 90 dpi
sorry - testing if replies have to be approved too? i entered a long reply but don't see it...
Re: Aliasing even when snapped and 90 dpi
Only first 2 messages are moderated, whether original topic message or reply. You're good now 

Basics - Help menu > Tutorials
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Re: Aliasing even when snapped and 90 dpi
gbell12 wrote:Seems to be the most useful snapping behaviour would be to have Inkscape snap the outside boundary of the shape/path to the pixel. That way no matter what the size, at least one edge would be sharp.
Inkscape knows two basic snapping modes: 'Snap nodes and handles' (to node snap targets) and 'Snap bounding box corners' (to bounding box snap targets). The two modes don't mix, but both snap to common targets like grid, guides and page borders.
For more information about snapping, please see the section in the manual:
Inkscape » Positioning and Transforming » Snapping: Snapping Objects
About your example: here's a different method (based on modifying the spacing of the original grid instead of the grid origin offset of a second grid ):
… and a screenshot snapping a rectangle with the bounding box corner to the pixel grid (note the snap setting to the right: with grids, node snapping has higher priority than bounding box snapping: turn off node snapping if you want to snap with the bounding box corners to the grid):
When drawing pixel-grid aligned stroked straight lines, note that the line ends depend on the stroke style setting (Fill & Stroke > Stroke Style > Cap): default is 'Butt caps' (the stroke ends at the position of the node) - the visual bounding box in Inkscape 0.48 however extends on both ends by half of the stroke width (like 'Square cap') for performance reasons.
Re: Aliasing even when snapped and 90 dpi
… and the exported bitmap which is crisp and shows no antialiasing of the paths (1px, 2px, 3px and 4px stroke width).
- Attachments
-
- icon-design-pixelgrid-aligned-3.png (269 Bytes) Viewed 2458 times
Re: Aliasing even when snapped and 90 dpi
Thanks ~suv, I think I'm almost there. I'm able to replicate your results but am still confused about a few things.
I think you're giving me two different methods, and I have a question on each.
1) With 0.5 pixel grid spacing, I can then use Node-snapping, because the stroke edges then end up being at pixel boundaries... is that the idea? If so, then I have to be careful to only place my nodes on the 0.5 pixels, which is a bit inconvenient. Workable though.
2) With boundary-box spacing, I would not need 0.5 pixel grid spacing, correct? The problem with that method is that while drawing the path, no snapping happens. I have to complete the path then move or resize it for the boundary box snapping to happen.
I think you're giving me two different methods, and I have a question on each.
1) With 0.5 pixel grid spacing, I can then use Node-snapping, because the stroke edges then end up being at pixel boundaries... is that the idea? If so, then I have to be careful to only place my nodes on the 0.5 pixels, which is a bit inconvenient. Workable though.
2) With boundary-box spacing, I would not need 0.5 pixel grid spacing, correct? The problem with that method is that while drawing the path, no snapping happens. I have to complete the path then move or resize it for the boundary box snapping to happen.
Re: Aliasing even when snapped and 90 dpi
Objects without stroke or with even numbers strokes need to be snapped to the full pixel grid to make the edges sharp, but the objects with odd numbers strokes need to be snapped to the half pixel grid. This is because strokes are placed over the middle of the object edge, so half of the stroke is covering the object and half is sticking outside of it.
It's useful to create two grids, one pixel grid and the other half pixel grid and make them in different colors or displays (dots vs lines).
It's useful to create two grids, one pixel grid and the other half pixel grid and make them in different colors or displays (dots vs lines).
just hand over the chocolate and nobody gets hurt
Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download
Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download
Re: Aliasing even when snapped and 90 dpi
As prkos already described, only strokes with an odd (integer) width need to be snapped to 0.5 px to have both edges of the stroke aligned to the (integer) pixelgrid.gbell12 wrote:Thanks ~suv, I think I'm almost there. I'm able to replicate your results but am still confused about a few things.
I think you're giving me two different methods, and I have a question on each.
1) With 0.5 pixel grid spacing, I can then use Node-snapping, because the stroke edges then end up being at pixel boundaries... is that the idea? If so, then I have to be careful to only place my nodes on the 0.5 pixels, which is a bit inconvenient. Workable though.
As mentioned earlier, the two snap modes ('Nodes and Handles', 'Bounding Box Corners') don't mix: a bounding box corner does not snap to a node, nor does a node snap to a corner or edge of a (visual) bounding box.gbell12 wrote:2) With boundary-box spacing, I would not need 0.5 pixel grid spacing, correct? The problem with that method is that while drawing the path, no snapping happens. I have to complete the path then move or resize it for the boundary box snapping to happen.
When creating new objects (with the pencil/pen tool, or one of the shape tools) or editing paths (with the node tool) and shapes (with their corresponding shape tool), you essentially draw or modify the geometry of the objects i.e. their nodes (+ handles): in these tool contexts, only node snapping applies.
With the select tool however, you can snap objects with their bounding box corners to other bbox snap targets (and to the common targets grid, guides and page borders) as well as snap nodes of the objects to other node snap targets (and to the common targets). It depends on the current snap settings (on the snap controls bar) and the snapping preferences which snapping will have priority when e.g. dragging an object with the mouse with the grid visible.
The bounding box snap mode in the select tool can be helpful to e.g. align objects/lines with only one edge of the stroke to the pixelgrid (e.g. if they don't have an integer width for the stroke).
Note that the 'Align and Distribute' functions all refer to the visual bounding box (i.e. they align objects with the edges of the strokes, not the geometric center lines).
Re: Aliasing even when snapped and 90 dpi
As mentioned earlier, the two snap modes ('Nodes and Handles', 'Bounding Box Corners') don't mix: a bounding box corner does not snap to a node, nor does a node snap to a corner or edge of a (visual) bounding box.
I got all that. I'm not sure why you're restating previous points rather than answering my specific questions. I must be confusing the issue. By "not mix" do you mean not on simultaneously, or not switched between in one drawing?
I guess I'm wondering what my workflow should be if I'm designing a 30x30 icon and want sharp lines when I export. I'm thinking bounding box snap isn't useful since it doesn't snap while I'm drawing with a tool. So that leaves node snap with 0.5 grid spacing, and careful placement of nodes depending on line widths.
It's either that or I switch between snapping modes depending on whether I'm drawing or moving.
Thanks tons for the help! Love inkscape already and your support really makes it.
Re: Aliasing even when snapped and 90 dpi
Not "simultaneously", kind of (though that's not precise either: both modes can be active at the same time, but it depends on the tool context which one is effective, as well as other snap settings in the preferences). You can (or might have to, or might want to) choose the current snap options based on the current task - AFAIU that is one reason why they are on their own snap controls bar (and no longer hidden in the 'Snap' tab of the document properties dialog like in earlier versions) - to be easily accessible and changeable whenever you need to snap different things, in the same drawing at different stages of the work process.gbell12 wrote:I got all that. I'm not sure why you're restating previous points rather than answering my specific questions. I must be confusing the issue. By "not mix" do you mean not on simultaneously, or not switched between in one drawing?~suv wrote:As mentioned earlier, the two snap modes ('Nodes and Handles', 'Bounding Box Corners') don't mix: a bounding box corner does not snap to a node, nor does a node snap to a corner or edge of a (visual) bounding box.
I "restated previous points" it in a effort to give a more complete picture why the drawing & path tools only offer node snapping, whereas the selection tool can snap in either mode.
Personally, I frequently switch between different snap modes (and targets) depending on the current task (I don't simply enable all snap options - I use it to match best the needs of the current task: only the relevant options are active. Other users might prefer to have all options enabled and then try to catch the intended snap target by watching the snap indicator messages). It also depends on what type of objects are mainly used (one could also prefer to work with filled rects instead of stroked paths - depending on the overall design and its elements: with unstroked filled paths, snapping the visual bounding box corners is far less frequently required than when working mainly with stroked paths/objects).gbell12 wrote:I guess I'm wondering what my workflow should be if I'm designing a 30x30 icon and want sharp lines when I export. I'm thinking bounding box snap isn't useful since it doesn't snap while I'm drawing with a tool. So that leaves node snap with 0.5 grid spacing, and careful placement of nodes depending on line widths.
It's either that or I switch between snapping modes depending on whether I'm drawing or moving.
I can't advise on the best workflow for icon design (I don't believe there's a single 'best' one) - in my own experience, I don't limit myself by excluding e.g. bounding box snapping right from the start: I don't manage to create an icon with the drawing tools alone - the select tool to move/transform objects is as frequently used as the node and shape tools for later edits and adjustments, and in each tool context I use those snap settings which suite the current task best for me. But then again - I'm not a professional designer either. Maybe someone else can comment and help you with "the" workflow for pixel-precise icon design.
Re: Aliasing even when snapped and 90 dpi
...choose the current snap options based on the current task
Got it. Awesome, many thanks!
For the record, Inkscape could add functionality to snap the node based on the boundary box (if you were laying down a new path and snap to bounding box were enabled). This would allow me to have a 1px grid, and always be pixel aligned whether I was drawing a new path, resizing, or moving. Maybe the developers (you?) already thought of that and decided it would be too goofy, though from a noob viewpoint, that'd be the most obvious/useful behavior.
Thanks again.