5

Immutable Stroke Configuration


The image below shows a couple icons I am working on. I need to define bounding boxes for the icons to ensure there size is always the same. The problem is when I color the stroke for the group that the bounding box is in, the bounding box gets colored.

Image of "light-bulb on", and "light-bulb off" with black stroke. How to change stroke in inkscape

Is it possible to configure an objects stroke (specifically a basic shape's stroke) such that when it is part of a group, and that group has its stroke changed to any arbitrarily chosen color, the objects stroke will remain colorless & invisible?

LET ME REPHRASE THAT IN WAY THAT IS MORE CONCISE, & NOT AS CONVOLUTED.

To help I will implement a numeric list.
  1. Lets Say I have a square, for the sake of clarity I will dub the square as "The Square" and pre-style its text, as it I just printed it.

  2. "The Square" is part of a group. We will call this group "The Group".

  3. "The Square" is the biggest object in the group, all other objects in "The Group" are aligned inside of "The Square". In other words, "The Square" defines the boundaries for "The Group", this is known as a bounding box. "The Square" is a bounding box.

  4. Because "The Square" is a bounding box it needs to be invisible. This is not always the case with bounding boxes, but it is more often than not (in my experience) the case.

  5. Since "The Square" is not the only object in "The Group", I cannot change the stroke of the "The Group"'s objects & paths without coloring the "The Squares" stroke.

QUESTION:

Is there a way that I can define "The Square"'s stroke, such that that when the stroke "The Group" is altered to any arbitrarily choosen color, "The Square"'s stroke will remain the same?



3
  • 1
    So I figured out how to do it. It was actually quite simple, but Id rather select someone else answer than my own. I asked for a way to make sure an object in a group doesn't have its stroke colored with the group its in, has a color aplied to its stroke, and this is 100% possible, and very easy to do. I about slapped my self when I figured it out.
    – j D3V
    May 28 at 8:16
  • You could still add it as an answer though. It's perfectly fine to add your own answer here, and even choose your own answer as best if you want. Welcome to GDSE by the way. Keep contributing!
    – Billy Kerr
    May 28 at 8:48
  • 1
    Okay I did that.
    – j D3V
    May 29 at 2:10

3 Answers 3

5

Here's one possibility, however this doesn't lock anything or stop you from changing the stroke, just a way to organise a graphic with groups . . .

Start with all objects ungrouped, then:

  1. Select all objects except the square, and group those.

  2. Select the square and the group, and group both of those. Now you will have a group within a group.

  3. To change the stroke, double click the group to enter it. Select the inner group, and change the stroke.

  4. Double click outside the graphic to exit the group.

Also, note (in Inkscape 1.2) - you can see the hierarchy of groups in the new combined Layers and Objects panel, and select the inner group to target it, and apply the stroke that way.

An example

enter image description here

Note also that in the example above I renamed the groups to make them easier to find. I used Icon for the outer/main group, and Icon inner for the inside group.

1
  • Oh that its smart.
    – j D3V
    May 28 at 8:13
3

I didn't want to answer my own question, however, there is a solution that is I think most would agree would be the best solution for the question being asked.


Solution


Setting any arbitrarily selected objects stroke to 0 will keep the selected objects path from rendering. This is true even when the object is selected with several other objects &/or paths. It is also true when the object is part of a group that contains other objects &/or paths. The selected object's stroke will only ever be renderable if the size of the stroke changes to a positive value (not that there is any reason to set a stroke's numeric value to a number that is less than zero stroke < 0 == "Error").


Noted Exceptions


It should be noted that if a path's stroke is set to zero, and is combined with another path — using the combine or union tool — the stroke will change to the stroke of the path that was larger. This is an important detail to be aware of, because it will result in a rendered stroke around the object.


In the Context of Emitted SVG


While authoring this answer, I did think of an aspect to this solution that I am slightly concerned about. When SVG is emitted, will setting a strokes width to zero, but its color to a valid value produce a useless attribute in the code. In other words, will a there be a stroke added with a color assigned to it, and its width set to 0, even though the stroke doesn't render due to the stroke being set to zero? IDK the answer to this, but I think it is something that should be acknowledged by those who work with RAW SVG XML markup.

3

Make the box fully transparent. An example:

enter image description here

  1. The box and some shapes inside

  2. The opacity of the box is turned to zero with the slider in the Objects panel (or as well in the Fill&Stroke panel). All items are grouped after it.

  3. The stroke color of the group is changed to blue. Adjusting the opacity of the group affects only the still visible shapes, the box stays invisible.

The box still snaps and defines how high and wide the group is, when it's selected. If one exports the group as SVG, the box comes along and can be made visible and edited in other software, for ex. in Illustrator (tried).

To prevent all effects of the box turn it OFF in the Objects panel. The Box is still there and can be enabled (if needed) in Inkscape or other SVG editor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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