3

I have this collection of six rhombuses in three different colors:

cube at 96% opacity

Right now each has an alpha channel of 96%. I want to see what the object looks like if I make it more transparent, so that it looks like this:

cube at 50% opacity

I can do this by selecting the objects one at a time and adjusting the alpha in the "fill and stroke" dialog for each object separately. This is tedious and error-prone, particularly since some of the objects are obscured behind others.

If I select all six objects at once, setting the alpha value for all six is a single operation in the “fill and stroke” panel. Unfortunately, this makes all six objects the exact same color, which I don't want:

now they are all 50% opaque but also all purple

How can I adjust the alpha value of the fill of multiple objects without changing their RGB/HSL values?

5
  • Welcome to GD.SE, MJD, Your question seems similar to this. Have you tried to change the opacity to the selection? Feb 24 at 7:56
  • Thanks for the suggestion. That looks like it works, but it doesn't change the alpha channel, and I am concerned that there is some subtle difference between opacity and alpha channel that will bite me later. Do you know?
    – MJD
    Feb 24 at 8:17
  • For example, one subtle difference is that it changes the opacity of the entire object, not just the fill color; the stroke becomes transparent also. If I turn the opacity to zero, the object vanishes entirely. Whereas if I set the alpha of the fill color to zero, the object's frame is still visible.
    – MJD
    Feb 24 at 8:18
  • Another is that if I change the opacity of a grouped object, and then I ungroup it, the opacity setting is lost because the object no longer exists.
    – MJD
    Feb 24 at 8:20
  • Note to self: inkscapetutorial.org/pages/extension.html seems to be a pithy explanation of how to write an Inkscape extension in Python.
    – MJD
    Feb 25 at 3:25

2 Answers 2

3

You can't do it the way you suggest because if you adjust the alpha component of the fill colour, you are basically adjusting the whole colour, and it will apply the same colour plus alpha to all the selected objects.

The easiest way to adjust them all together would be to use the opacity slider instead - but that will apply the opacity to the whole objects, including both fill and stroke. You don't need to group them though. You can apply opacity to a multiple selection so that it is applied to each object individually. Then grouping and ungrouping will make no difference.

Note: There is no real difference between alpha and opacity in an SVG. The alpha is applied via an opacity attribute, specifically a fill-opacity and/or a stroke-opacity. For the opacity slider an opacity attribute is also applied, but it doesn't specify the fill or stroke separately and applies to the object as a whole (both fill and stroke).

If using the opacity slider method is problematic, for example if you don't want the stroke to become transparent, there is a possible work around. However, it is a bit contrived, and may not be worth the effort. I'll let you decide.

  1. Create each shape and apply a fill colour to each with 100% alpha, set no stroke.

  2. Duplicate all, then set the fill of the duplicates to none, and set a stroke at 100% alpha.

Basically, at this stage you will now have the same design, however the strokes and fills will be separate objects rather than single objects with a fill and stroke. Of course this increases its complexity.

  1. Select and group each fill and stroke piece individually. Then select all and group all the objects. You can skip this step if you want, but doing this will help keep the objects in the correct order in the stack, so that fills overlay the strokes below them.

  2. Using the Edit Paths by Nodes tool, select one of the fill objects.

  3. Right click and choose Select same > Stroke color. This seems counter intuitive but it will select all the objects with no stroke (i.e. only the filled objects, leaving the stroked objects unselected).

  4. You can then adjust the opacity slider to apply transparency to the filled objects only, without affecting the separate stroke objects.

An example

enter image description here

1
  • Thanks for this detailed and thoughtful discussion.
    – MJD
    Feb 24 at 18:33
3

A programmer might be able to write something for you. When waiting for it you can strengthen your working method.

You said it's tedious and error prone to adjust the colors shape by shape, because some shapes are fully behind the others. That's not so harmful if you select items in the layers & objects panel.

In the next image I have 2 layers only to have clear visual separation between your cube faces and my auxiliary shapes. In Layer1 I have my six cube faces. They all have solid green fill and black stroke. I have renamed them.

In Layer2 I have 3 rectangles with the wanted partially transparent cube face fill colors.

enter image description here

In the next image I have selected simultaneously in the layers & objects panel the top and bottom faces and picked with the dropper the color of the transparent blue rectangle. Multiple selections need holding Ctrl and clicking.

enter image description here

After doing the same for pairs front-back (cyan) and left-right (magenta) I have this:

enter image description here

The rectangles for picking the colors are useful only if numerous items need the same color. In your case one probably could work directly in the fill & stroke panel without any errors. But, as said, make the selections in the layers & objects panel to see better what's selected.

1
  • 1
    Thanks. My next question was going to be: Is there an API I can use to automate the process? I am a programmer. I think the best solution may be for me to build my own tools.
    – MJD
    Feb 24 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.