Inkscape.org
Beyond the Basics How to change the colour of an object with relation to another object's colour?
  1. #1
    tukykarmakar tukykarmakar @tukykarmakar

    Hi all,

    I want to make two or more objects related in such a way that the colour of one object changes depending on the colour of the other one.

    For example, in the attached screenshot, the squares on the right have the same colour as the ones on the left, but with 50% saturation and 75% lightness.

    If I'm working with HSL colouring, and I have an object with the hue value as 243, then I want another object to have the same hue value but different value for saturation or lightness or both.

    Thanks!

     

    Screenshot %Y %M %D %H %M %S
  2. #2
    Polygon Polygon @Polygon🌶

    Can´t you just use the Fill and Stroke Panel/Fill in HSL mode and adjust the values accordingly?

  3. #3
    Tyler Durden Tyler Durden @TylerDurden

    Fast and dirty: make clones of the parent objects and put a semi-transparent white objects in front.

     

    Diffuse
  4. #4
    tukykarmakar tukykarmakar @tukykarmakar

    @Polygon I want the colour of an object to change with relation to another object. Colouring them is not the problem. I have a lot of objects with different shades/saturation/lightness of a base colour, so I wanted a quick way of changing them by changing the base colour.

    @TylerDurden yeah, it works for that specific values of saturation and lightness. But it comes back to the same problem of colouring each of the front layer if I want to have different values for S and L.

  5. #5
    Tyler Durden Tyler Durden @TylerDurden
    tukykarmakar

    @TylerDurden yeah, it works for that specific values of saturation and lightness. But it comes back to the same problem of colouring each of the front layer if I want to have different values for S and L.

    Depending on the use, clones of a white rectangle could be the diffusers. See attached file in Inkscape.

     

    Diffuse2
  6. #6
    Paddy_CAD Paddy_CAD @Paddy_CAD

    [Extensions > Colour > XXXXX] provides a range of extensions for different colour adjustments. I recommend experimentation. Perhaps you'll find what you need here.

  7. #7
    tukykarmakar tukykarmakar @tukykarmakar

    Let me show an example of what I'm trying to do. The attached .svg file has the same clock in different colours, where each component of the clock has the same hue, just different values of saturation and lightness.

    Instead of making a copy and re-colour each component manually separately, I want to know if it's possible to have them change if I change the hue of a parent or root object. For instance, each clock has three boxes under them, where the first one is the base hue and the other two are contrasting hues for the second-hand of the clock. I hope this gives people an idea about how exactly I want the colours to change in relation of a base object.

    @TylerDurden while cloning the white rectangles work, how do I make them diffuse the underlying colour down to the lightness/saturation value I want?

    @Paddy_CAD I tried the extensions, they seem to be ranging from literally changing the colour with extra steps, to subtracting certain values from the colours. The latter one might be useful but they're not dynamic, i.e., they won't change if I change the hue of the base object.

    Clock Test
  8. #8
    Tyler Durden Tyler Durden @TylerDurden

    I'd try a control rectangle for each parent color.

     

     

    Diffuse3
  9. #9
    tukykarmakar tukykarmakar @tukykarmakar

    So are you suggesting to go with the trial-and-error method to find out the opacity of the white box that'll filter out the saturation/lightness that I want?

  10. #10
    Tyler Durden Tyler Durden @TylerDurden

    If it looks good, it is good. It is the appearance that matters, as I understand it.

    (I did say "fast and dirty"... no scripting required)

    Once the appearance is satisfactory, the value of transparency of the white rectangle is known from the numeric value and that number can be used.

  11. #11
    Paddy_CAD Paddy_CAD @Paddy_CAD
    *

    Create three layers in your drawing. The lowest layer should contain a single white rectangle, sized to the page borders. The middle layer should contain all your shapes. The top layer contains a red rectangle, again, same size as the page. In the Layers and Objects dialog, select the top layer and set the colour blend mode to [Lighten]. Now use the slider to adjust the layer opacity, adding more red to the shapes in the middle layer.

    You can add green and blue overlay layers too for a full RGB gamut, or use any other colour that meets your need.

    Edit: My screen capture didn't render in my browser. Here's a link to Imgur instead. Also conserves my upload quota.
    Inkscape colour tinting

    Edit 2: Experiment with the other colour blend modes too. Overlay, Hue, Saturation, etc. will combine the overlay in interesting ways.

Inkscape Inkscape.org Inkscape Forum Beyond the Basics How to change the colour of an object with relation to another object's colour?