Inkscape Experiments: Mesh Gradients

Share

Inkscape Experiments logo

 

The latest release of Inkscape (version 0.92.3) brought aboard the much anticipated Create And Edit Meshes Tool (C&EM). It allows Inkscape users to create and edit gradient meshes. It pretty much behaves like the Mesh Tool in Adobe Illustrator, with the exception of having a convoluted name. But that’s okay. I’ll start with a brief rundown on this new tool.

Basics On Create And Edit Meshes Tool

The location of the Create and Edit Meshes tool within Inkscape

The C&EM tool is located within the Main Tools panel on the left-hand side of the screen, right below the Create and Edit Gradients tool. It has an odd-looking icon, like it represents a warp tool.

Basic Functions

the basics of a gradient mesh

C&EM functions much like the Mesh Tool in Illustrator. Double-click on a vector object and it’ll create a new set of vectors with nodes and strange-looking handles. This is your brand new gradient mesh.

The diamonds are your Mesh Nodes. They are your main points of interest. Why? Because Mesh Nodes are the points within your gradient mesh that control the color. Plus you can move them where ever you please. The further away from the Mesh Node’s original position, the harder an edge that will be created in the direction that you move it.

The circles are Mesh Handles. Whenever a Mesh Node is selected, the Mesh Handles turn to triangles. You don’t have to select a Mesh Node to use any of the Node Handles. You can use any handle and manipulate it. Pulling a handle basically manipulates the gradation. Pulling a handle from a Mesh Node expands the color from that side of the Mesh Node. Bringing a handle closer to its mesh node constricts the gradation.

Now I need to address the nodes and handles along the parameter of the vector object. They function just like the interior nodes and handles. But you’ll notice that when you pull a node or handle within or outside of the object it expands or contracts just the mesh, not the object. This is similar to the contents of a clipping path/mask.

According to Inkscape’s Wiki (or online documentation), the sections divided up by the vector segments are referred to as Patches.

A comparison of a gradient mesh verses a vector object

The gradient meshes will fill the shape of any object that you create when created. For vector objects created with a pen, you will have a gradient mesh within an overlapping box.

A gradient mesh applied to a pen created shape verses a gradient mesh applied to a shape object.

 

Types of Gradient Meshes

There are two types of gradient meshes. There’s the standard grid-like mesh and the circular Conical Gradient mesh. You’ll find both of these options within the upper toolbar above the canvas, to the far left-hand side. For a grid mesh, select Create Mesh Gradient and double-click using the C&EM tool on the vector object. For a conical mesh, select Create Conical Gradient button then double-click using the C&EM tool.

a sphere with a conical mesh applied and a sphere with a standard gradient mesh applied.

You’ll notice that conical gradients don’t fill either shapes or vector objects that you create. In rectangular shapes, the conical mesh with fit within the shape. Everything else will have the conical mesh overlap the vector objects.

One of the downfalls of a conical mesh is that it’s not a solid mesh. There’s a split on one side. It runs from the center to the edge. This split isn’t obvious until you change colors or move nodes around.

the split seperated in a conical gradient mesh

Gradient Meshes for Strokes

That’s right kids! Even strokes can have a gradient mesh! A gradient mesh can be applied to strokes without having to convert them to vectors. That means that you can still adjust the size, joints, etc. To apply a gradient mesh to a stroke, select the Create Gradient in the Stroke button within the upper toolbar before applying a gradient mesh.

A gradient mesh applied to a stroke in inkscape

Adding To A Gradient Mesh

Adding new nodes to a gradient mesh is a snap. Just double-click on a segment (a vector or line between any two give nodes on your mesh.) with the C&EM tool. It’ll create a new set of nodes in a direction that’s base upon the segment you double-clicked.

Just in case your confused by the previous sentence, let’s say that you double-click on a segment that runs horizontally across your mesh. The C&EM tool will create a new row of nodes running perpendicular to the horizontal segment.

In the case of a Conical Mesh, if you double-click on a segment that runs from the center of your mesh to your perimeter, the C&EM tool will create a new circle of segments. If you happen to double-click upon one of the circular segments, the C&EM tool will create a new series of nodes and segments that run from the mesh’s center to its edge.

Examples of adding a new set of nodes to a gradient mesh.

Examples of adding a new set of nodes to a gradient mesh. (Click to enlarge.)

Controlling The Parameters Of A Gradient Mesh

Now that we’ve gone though the basics of Gradient Meshes in Inkscape, let’s dig into the details! Whenever the C&EM tool is selected, you’ll see its tool settings across the top of Inkscape’s canvas.

Choosing Where To Make Your Mesh

Create Gradient In The Fill and the Create Gradient In The Stroke buttonsGoing from left to right, after the Create Gradient Mesh and Create Conical Gradient buttons (which we covered previously in this article), you find the following two buttons to the left of “on:” — Create Gradient In The Fill and the Create Gradient In The Stroke buttons. These two buttons allow you to have gradient meshes within both the fill and stroke of any vector object. Selecting either button allows you to directly create a mesh within the stroke or the fill of your vector object.

How Many Do You Want?

gradient mesh create rows and columns

The next two parameters are text fields are labeled as Rows and Columns. These are pretty straight forward. They determine how your gradient mesh gets divided. The numbers that you enter are the number of patches in a given direction. These are not dynamic, so if you wish to create fewer rows or columns, you’ll need to undo. (Command/Control Z)

For Conical Meshes, the number of Rows determine the number of circular/arched patches. The number of Columns determines the number of slices or areas created by segments drawn from the center of the mesh to the perimeter.

Manipulating Segments & Nodes

gradient mesh node manipulation buttons

The next button, which may not even have a name, toggles a segment from a bezier curve to a line and back again. The practical result will cause a selected segment or the vector connected by two nodes to lose their handles, resulting in a straight line. To convert that straight line into a bezier curve, recovering the handles, you’ll click the button again and the handles will appear. The key stroke for this operation is Alt B.

The next segment button tries to convert the select segment into an elliptical arc by adjusting the length of the handles. I get what it tries to do, but I personally don’t find this operation useful. It doesn’t seem to provide consistent results. The key stroke for this operation is Alt C.

The button with the dropper is an interesting operation. As mentioned previously, mesh nodes are the points in the mesh where you can determine the color. When a node is selected and there’s another object directly beneath the node, the dropper will select the color beneath the mesh node and apply the color to it. This will be extremely useful if you’re creating an illustration base upon a photo. The key stroke for this operation is Alt K.

The next button with the odd icon basically scales the mesh down to fit within the bounding box of your object.

Other Corner Operations

There are operation that require you to dig pretty deep within Inkscape’s Wiki to discover. But being the nice guy that I am, I’ll save you the trouble…

Tensor Points

Tensor Points allow users to tighten up or spread out a gradation with in a patch. This is another way to refine the transitions within your mesh. They do not appear on gradient meshes by default. But when you activate them, they can be identified as squares. To make Tensor Points appear, select the four nodes that make up a specific patch (This can be done while holding down the Shift key and using the C&EM tool.) and using the keystroke Alt G. You can make the Tensor Points disappear by using the same keystroke.

Smoothing Color Transitions

This may or may not be useful due to the inconsistent nature of this operation. It attempts to smooth gradations or transitions by change the length of the mesh handles. The keystroke is Alt J.

Editing Meshes

The next three buttons within the tools settings will be extremely useful.

turn handler on/off, edit mesh fill, edit mesh stroke

Turn On/Off The Handles!

Okay it’s not that exciting. This next button basically causes handlers to disappear and reappear.

Which Mesh Do You Need To Edit?

The next two buttons allow you to turn on the mesh that you wish to edit, either the fill or stroke or neither or you can do both. These buttons will become extremely useful if you choose to create gradient meshes for both the stroke and the fill of an object. The meshes created can be identical when created. Having them both on at once will cause all sorts of confusion while working.

Warning!

mesh gradient warning button about SVG syntaxThis button doesn’t serve much of a purpose at the time of writing. (May 30th, 2018) But it basically brings up a message advising you on what to do if you choose to use your illustration for the web via SVG2 or for print via PDF.

It is claimed that gradient meshes are apart of SVG2 scripting language, but they’re not set in stone yet. So it’s still subject to be changed.

SVG2 syntax warning on gradient meshes

If you plan to use an illustration utilizing a gradient mesh for print, I would rasterize or convert the mesh into a bitmap regardless. The fewer problems that you have, the easier it will be to get your job printed without any major errors at the printer.

How You Smooth

Inkscape mesh gradient smoothing options

 

The last operation allows you to choose how you which to smooth your mesh’s gradations. By default, Inkscape is set to Coons method of smoothing, which utilizes bilinear interpolation. This allows for softer transitions in your meshes. Bicubic method of smoothing creates a seemingly harsher transition in your colors. These methods of smoothing can be set per object.

My Personal Take

sample spheres created using gradient meshes

Two samples using gradient meshes. The orange spheres started with a much simpler mesh.

Gradient Meshes have been in development for quite a while. It still needs a bit of polish tho. I can do without the seam in the Conical Meshes. It’s not as intuitive as in Adobe Illustrator. But so far, it’s a great start.

When working with a gradient mesh, it feels a lot like modeling a 3D mesh. You start simple and slowly get more complicated as you work. Going nuts with a lot of nodes seems to make my life more difficult than necessary.

Making smooth transitions is still a little difficult. For my spheres, I had to use Bicubic Smoothing. When modeling my spheres, I noticed that the transition/glow emanating from the nodes was rounded under Bicubic as opposed the a more diamond glow that hugs the vectors when using Coon Smoothing.

Honestly, I would be strategic when using gradient meshes. I wouldn’t use it for everything. In my spheres, I can can think of easier ways to shade them.

 

Bibliography and Further Reading:

“Mesh Gradients” Inkscape Wiki. http://wiki.inkscape.org/wiki/index.php/Mesh_Gradients, Jan 3, 2017.

Brown, Paul. “Inkscape’s Hidden Little Feature: Mesh Gradients” Open Content & Software Magazine. http://www.ocsmag.com/2016/02/27/inskcapes-hidden-little-feature-mesh-gradients/, Feb 27, 2016.