Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: How can I do a limited/masked gradient fill in GIMP?

  1. #1
      Thurlor is offline
    Guild Journeyer Thurlor's Avatar
    Join Date
    Apr 2011
    Location
    Phillip Island, Victoria, Australia
    Posts
    126

    Question How can I do a limited/masked gradient fill in GIMP?

    Lately I've been messing around with GIMP, trying out new techniques as I come across them. Anyways, I'm probably just overlooking this feature, but is there a way in which I can do a 'shape based' gradient fill that plateus at a certain value and shape. Another way of wording it would be; can GIMP blend between 2 different coloured shapes (one atop the other) resulting in a gradient between the two?

    Here is an example of what I mean. Just a very simple image with one shape on top of another.

    How can I do a limited/masked gradient fill in GIMP?-test001l.bmp

    I've had a look at the 'interpolate' function of Inksacpe, but it requires each shape to have the same number of nodes and results in intermediate steps being smaller than the final image.

    Anyways, thanks in advance.
    Last edited by Thurlor; 05-07-2011 at 11:05 PM.

  2. #2
      Ghostman is offline
    Guild Adept Ghostman's Avatar
    Join Date
    Jun 2008
    Posts
    406

    Default

    I'm not entirely sure what you're trying to achieve. Is the black-colored area in your example image supposed to be where the gradient would be? So there'd be gradient going from the outer edge of the area to it's inner edge?

  3. #3
      Thurlor is offline
    Guild Journeyer Thurlor's Avatar
    Join Date
    Apr 2011
    Location
    Phillip Island, Victoria, Australia
    Posts
    126

    Default

    Quote Originally Posted by Ghostman View Post
    So there'd be gradient going from the outer edge of the area to it's inner edge?
    Yes, that's exactly what I want. I couldn't really show it with that image, but it's supposed to be a gradient going from black to white, with the surrounding area also black. I hope that makes sense.

  4. #4
      Ghostman is offline
    Guild Adept Ghostman's Avatar
    Join Date
    Jun 2008
    Posts
    406

    Default

    I don't think there's any easy way to do this in GIMP. There are ways (blurs, bevels) to create a black to white gradient to surround the inner area, but these would all result in the gradient being of equal thickness in all directions. That is, it would match the shape of the inner edge but not the outer one.

    Although perhaps you could create two gradient masks, one based on the inner edge and the other one on the outer edge, and combine them by setting blend mode to multiply.

  5. #5
      Ghostman is offline
    Guild Adept Ghostman's Avatar
    Join Date
    Jun 2008
    Posts
    406

    Default

    I toyed a bit with that example pic and came up with this method for creating something like the effect you're after. Unfortunately the shapes of the inner and outer edges of the gradient zone are not preserved 100% accurately, but you do get a fait approximation of them.

    First, you'll need to create two layers, one for working on the inner edge of the gradient, and another for working on the outer edge. Notice how I've inverted the black & white for these:
    How can I do a limited/masked gradient fill in GIMP?-outer-1.pngHow can I do a limited/masked gradient fill in GIMP?-inner-1.png

    Let's edit the layer that contains only the inner shape first. Select the WHITE area and apply a Gaussian Blur (I used 120 pixel width) on it:
    How can I do a limited/masked gradient fill in GIMP?-inner-2.png
    This will create a gradient that smoothly darkes around the inner edge, yet maintains it's shape. Note, however, that the gradient only goes from white to gray, NOT white to black.

    To fix this issue, make copies of the layer and set their blend modes to "multiply", then merge them. The result will be a single layer that contains a gradient from white to black, but without messing up the shape too much. You'll likely see a better quality result if instead of copying the same blurred layer, you create each layer manually and use a different Gaussian Blur width for each. Once you've merged the layers, invert the colors:
    How can I do a limited/masked gradient fill in GIMP?-inner-3.png

  6. #6
      Ghostman is offline
    Guild Adept Ghostman's Avatar
    Join Date
    Jun 2008
    Posts
    406

    Default

    As for the outer edge, just use the same kind of process, but without inverting colors at the end:
    How can I do a limited/masked gradient fill in GIMP?-outer-1.png
    How can I do a limited/masked gradient fill in GIMP?-outer-2.png
    How can I do a limited/masked gradient fill in GIMP?-outer-3.png

    Now you should have two gradient layers, one for the inner edge and one for the outer edge. Place them so that the INNER shape gradient is above the OUTER one. Set this topmost layer's blend mode to "multiply" and set it's opacity to 50%. This should result in the final gradient band, limited by the designated shapes of the inner and outer edges, though not quite perfectly:
    How can I do a limited/masked gradient fill in GIMP?-twolayers-multiply.png

    You can merge the inner and outer gradient layers to get a single layer containing this final gradient, which can then be used for a mask.

    I hope this advice was of any use to you

  7. #7
      Thurlor is offline
    Guild Journeyer Thurlor's Avatar
    Join Date
    Apr 2011
    Location
    Phillip Island, Victoria, Australia
    Posts
    126

    Default

    @Ghostman

    Thanks muchly for the detailed reply. It's definitely something I will have to try. I think I'm currently onto something using Wilbur as well, though I haven't had a chance to check it out properly yet.

    Anyways, the use for all of this will be to set gradients below and above 'sea level' with upper and lower contour guides, whilst maintain the original shape of the landform. I can't think of a better way to explain what I'm after. If I'm going about this completely wrong and there is some easier way to accomplish my goal, I can't see it..
    Last edited by Thurlor; 05-08-2011 at 07:57 PM.

  8. #8

  9. #9
      sambrookjm is offline
    Guild Apprentice
    Join Date
    Jan 2009
    Posts
    28

    Default Contour Lines?

    Would this GIMP script be useful? To use it, you need to have your shape as the only non-alpha portion of the GIMP image. This script converts the image to a square, does a rectangular-to-polar conversion, and does a linear gradient down each column along the non-transparent portions of the drawing before going back to rectangular coordinates. It can also do contours, if you so desire. The script will show up in the Filters/SambrookJM menu under GIMP.

    It's not perfect, but it could be a good starting point. It's not a fast script at all, so any ideas on how to speed things up would be greatly appreciated. I'd also like to know how you delete the selection-mask channel, since the ways I've tried haven't worked.

    Hope this helps out somewhat...
    Attached Thumbnails Attached Thumbnails How can I do a limited/masked gradient fill in GIMP?-ring1.png   How can I do a limited/masked gradient fill in GIMP?-ring2.png  
    Attached Files Attached Files
    I think I've had this Deja Vu before...

  10. #10
      Thurlor is offline
    Guild Journeyer Thurlor's Avatar
    Join Date
    Apr 2011
    Location
    Phillip Island, Victoria, Australia
    Posts
    126

    Default

    @sambrookjm: Thank you muchly for that. I'll be having a close look at it in the next few hours and I'll let you know how it works out.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •