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
    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.

    Click image for larger version. 

Name:	Test001l.bmp 
Views:	621 
Size:	768.1 KB 
ID:	35600

    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

    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
    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

    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

    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:
    Click image for larger version. 

Name:	outer-1.png 
Views:	410 
Size:	4.4 KB 
ID:	35616Click image for larger version. 

Name:	inner-1.png 
Views:	119 
Size:	4.5 KB 
ID:	35617

    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:
    Click image for larger version. 

Name:	inner-2.png 
Views:	276 
Size:	36.4 KB 
ID:	35618
    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:
    Click image for larger version. 

Name:	inner-3.png 
Views:	132 
Size:	55.4 KB 
ID:	35619

  6. #6

    Default

    As for the outer edge, just use the same kind of process, but without inverting colors at the end:
    Click image for larger version. 

Name:	outer-1.png 
Views:	108 
Size:	4.4 KB 
ID:	35620
    Click image for larger version. 

Name:	outer-2.png 
Views:	127 
Size:	31.8 KB 
ID:	35621
    Click image for larger version. 

Name:	outer-3.png 
Views:	181 
Size:	49.4 KB 
ID:	35622

    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:
    Click image for larger version. 

Name:	twolayers-multiply.png 
Views:	253 
Size:	51.2 KB 
ID:	35623

    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
    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

    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 Click image for larger version. 

Name:	Ring1.png 
Views:	161 
Size:	7.6 KB 
ID:	35926   Click image for larger version. 

Name:	Ring2.png 
Views:	118 
Size:	90.2 KB 
ID:	35927  
    Attached Files Attached Files
    I think I've had this Deja Vu before...

  10. #10
    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
  •