Inkscape 0.48 Illustrator's Cookbook
上QQ阅读APP看书,第一时间看更新

Picking and assigning colors with the Dropper tool

It's hard to imagine any graphics application without a Dropper tool (often also called color picker). In Inkscape, you simply select an object, select the Dropper tool, and click anywhere on canvas to assign the color under the cursor to the object fill (or stroke if you hold Shift while clicking). This works as expected if the object you are picking from is fully opaque.

There are more options when picking the color from a partially transparent object and this is what we will investigate in this recipe.

Getting ready

Having the Fill and Stroke dialogue window open helps with tracking how different Dropper tool options interact with object opacity so make sure you open it (Shift + Ctrl + F).

How to do it...

The following steps show the various interactions of the Dropper tool with different objects:

  1. Select the rectangle tool (F4) and create a tall rectangle. Set its fill to Green (#008000), and its Opacity, % to 50.
  2. Create three squares on the right-hand side of the tall rectangle and make sure their Opacity, % is set to 100.
  3. Select the first square. Select the Dropper tool How to do it... (F7 or D); the first square will remain selected. Make sure that neither Pick nor Assign opacity options are active on the Dropper toolbar. Click anywhere on the tall rectangle.
  4. Switch to Selector tool (Space or F1). Select the second square. Select the Dropper tool (Space, F7 or D) and make sure that the Pick option is active but Assign is not. Click anywhere on the tall rectangle. The square will remain unchanged.
  5. Switch to the Selector tool (Space or F1). Select the third square. Select the Dropper tool (Space, F7 or D) and make sure that both Pick and Assign options are active. Click anywhere on the tall rectangle.

The following image displays the workflow and the result of this recipe:

How it works...

When using the Dropper tool to pick colors from partially transparent objects there are two options: Pick and Assign that can be combined in three different ways that influence the outcome.

The checkerboard pattern was applied to the background of the earlier image so it's more clear which areas are partially transparent and which are opaque. The transparency information can also be read from the screenshots of color information for each object. The squares all have full overall opacity so their transparency is only governed by the A (alpha) box as seen in the screenshots. The following are the results:

  • For the first square, the opacity wasn't picked, so Inkscape use the same color that the rectangle appears to have due to the transparency: a lighter shade of green.
  • For the second square, the opaque color is picked but the 50% opacity isn't assigned. Therefore, the square remained unchanged with the same color and no transparency.
  • For the third and last rectangle, both color and opacity were picked and applied, therefore the style appears to be copied and pasted, as if we were using the Paste Style option (Shift + Ctrl + V). The dropper, however, only modified the RBGA values of the color, not the object's opacity. Use Edit | Paste Style to paste all the attributes of the style.

There's more...

So far we have only been clicking on the canvas to pick color, but clicking and dragging is also available. Dragging with the Dropper tool creates a circular selection, the average color of that region is picked to be applied to the object:

This can especially be useful with bitmap textures. Here we are selecting the average color of all the pixels inside the circular selection:

Inverse picked color

Holding the Alt key while using the Dropper tool inverts the color:

Copy color under cursor

One other useful feature of Dropper tool is that with Ctrl + C we can copy the color that is under the cursor into the clipboard. No objects need to be selected for this to work.

Once we have a color in our clipboard we can select an object to paste the color with Ctrl + V.

If the object that is under the cursor when copying is partially transparent all the Dropper option combinations we tested earlier will influence the result, so we have to pay attention to which options are active.