Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for professional graphic designers and non-designers trying to do their own graphic design. It's 100% free, no registration required.

How can I create a slice-like area within a shape in Photoshop and apply a gradient to it. Here is an example - the black area:

enter image description here

I've tried to create one light grey shape and one black shape on a layer below and then subtracting a rectangular area from the top layer. However if I then apply a gradient to the black shape it starts at A and goes to C (in the background). I'd like the gradient to start at A and finish at B.

share|improve this question
    
It kind of depends what you want to do with the black area. If it is just a black area, you might just want go to the blending options of the grey box shape and add a gradient where the top is black and the bottom is grey. –  Joonas May 9 '12 at 7:16
    
Thanks for reply. I'd like to learn how to do it with shapes and/or paths - that way I could wireframe a layout and then work on the details including gradients. –  user4485 May 9 '12 at 7:29
add comment

1 Answer

up vote 0 down vote accepted

Here’s how I’d build an element like that:

Clipping group

The Main shape with solid fill layer contains the main shape, including all the layer styles. The Gradient layer above is a rectangle with a gradient fill, and a clipping mask with the layer below. That means the fills of the layers are combined before being masked with the Main shape with solid fill's shape.

Note that Main shape with solid fill is a solid colour layer — that's important, because if you use a colour overlay layer style, gradient overlay layer style or pattern overlay layer style, they're rendered on top of everything in the clipping group. In this case I've included pattern overlay layer style that's providing some subtle noise.

The end result is that you can extend the Main shape with solid fill layer without having to worry about the gradient ever moving. It's a great way to work if you need to guarantee that a gradient ends at a certain point for iOS resizableImageWithCapInsets or Android 9-patch images.

Image shown is Photoshop CS6, but CS5 and prior versions work the same.

share|improve this answer
    
Thanks, works like a charm. +1 for an elegant solution. –  user4485 May 9 '12 at 10:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.