Gradient from black to transparent. How to make a gradient in Photoshop

Transparency, shadows and gradients

Transparency

The ability to make images and colors transparent is one of the most fundamental building blocks in CSS3. There are two ways to set transparency. The first is to use the function rgba(), which takes four parameters. The first three parameters set the values ​​(from 0 to 255) of the red, green and blue components of the color. The last parameter specifies the transparency value, or alpha, which can range from 0 (fully transparent) to 1 (fully opaque).

The following rule sets the background to a bright green color with 50 percent transparency:

Aside ( background: rgba(170,240,0,0.5); )

Browsers that don't support the rgba() function will simply ignore this rule and the background will retain its default transparency - full transparency.

Therefore the second approach is better. Here we first set a solid fallback color and then replace it with a semi-transparent color:

Aside ( background: rgb(170,240,0); background: rgba(170,240,0,0.5); )

Thus, browsers that do not support the rgba() function will still color the element's background, but only with a completely opaque color.

To achieve a better match between the backup color and the primary color, you should use a backup color that most closely reproduces the translucent effect. For example, if a translucent color is applied to a white background, then that color will appear even lighter due to the translucent white background. When choosing a fallback color, this effect should be taken into account.

The CSS3 specification also defines a style property opacity(opacity), which works exactly the same as the alpha value. The opacity value can also be set in the range from 0 to 1, allowing you to make any element semi-transparent:

Aside ( background: rgb(170,240,0); opacity: 0.5; )

The figure below shows two examples of translucency, one implemented using the rgba() function and the other using the opacity property:

Opacity property It is preferable to use rgba() instead of the function in the following cases:

    when you need to make several colors translucent. The opacity property allows you to make the color of the background, text and border of an element semi-transparent;

    when you need to make something translucent without even knowing its color, for example because the color might be set by another stylesheet or code JavaScript scripts;

    when to do it translucent image;

    when to use a transition, i.e. An animation effect that causes an element to fade in or out.

Shadows

The CSS3 specification defines two new types of shadows: box shadows And text shadows. Block shadows are usually more useful and have more high level support, while text shadows don't work in any of the Internet versions Explorer. A block shadow can be used to create a rectangular shadow behind any block of an element

(but don't forget about the frame so it continues to look like a block). Shadows can even follow the outlines of blocks with rounded corners:

The shadows in question are created through properties box-shadow And text-shadow. The following is an example of creating a basic block shadow:

Aside ( box-shadow: 8px 8px 10px gray; )

The first two values ​​of the box-shadow property set the horizontal and vertical offsets of the shadow from original object. Positive values ​​move the shadow down and to the right, negative values ​​move the shadow up and to the left. The next value determines the size of the blur (blur, in in this example 10 pixels), which increases the blurriness of the shadow. Last value determines the color of the shadow. If there is any content underneath the block, consider using the rgba() function to make the shadow semi-transparent.

For more fine tuning You can add two values ​​to the box-shadow property. To set the width (spread) of a shadow - a subproperty that expands the shadow, thickening its solid part between blurred edges, adding a value between the blur and color values:

Aside ( box-shadow: 8px 8px 10px 5px gray; )

And to create a shadow that reflects not outward, but into the element, the value is added at the end of the list of values inset. Best effect achieved when the shadow is placed directly on top of the element, without horizontal or vertical offset:

Aside ( box-shadow: 0px 0px 20px lime inset; )

The text-shadow property requires a similar set of values, but in a different order. The color is specified first, followed by the horizontal and vertical offsets, and then the blur:

H1 ( text-shadow: gray 10px 10px 7px; )

Gradients

Gradients are transitions of colors that can create wide range effects, from subtle shadows under the menu bar to psychedelically colored buttons.

Many web pages simulate gradients background images. But CSS3 technology allows the web developer to define the required gradient that will be rendered by the browser. The advantage of this approach is that it reduces the number of image files that need to be processed and provides the ability to create gradients that resize seamlessly to fill any space.

There are no special properties in CSS for creating gradients. Instead, the gradient function is used to set the background property. But be sure to set this property to a solid color first to create a fallback fill for browsers that don't support gradients (including Internet Explorer, which supports gradients only starting from IE 10).

There are four gradient functions, all of which require browser developer prefixes. In this section we will look at examples of gradients for Chrome browser(for which the prefix -webkit- is used). For support Firefox browsers and Opera needs to add exactly the same gradient values, but with the prefixes -moz- and -o-.

Let's look at the function first linear-gradient(). The following is one of its simplest forms, coloring the block white at the top, which fades to blue at the bottom:

Aside ( background: -webkit-linear-gradient(top, white, blue); )

Replacing the top value with left gives a linear horizontal gradient. And by specifying the corner of the block to start the gradient, we get a diagonal transition:

Aside ( background: -webkit-linear-gradient(top left, white, blue); )

You can create a multicolor gradient by providing a list of colors. For example, the following rule creates a three-color horizontal gradient:

Aside ( background: -webkit-linear-gradient(left, red, orange, yellow); )

Finally, instead of distributing the gradient colors evenly, you can specify the start position of each color by gradient stops, stretching or compressing the stripes or shifting them in one direction or another.

Creating a gradient from colored to transparent

To create gradients in Photoshop, use the Gradient Tool. In Photoshop, you have the ability to create different types of gradients " Linear gradient", "Radial gradient", "Angle gradient", "Reflected gradient", "Diamond gradient" (to select the gradient you need, use the corresponding buttons in the options bar, icons with an example of the gradient type). Most often, it is “Linear gradient” that is used; the fill area is uniformly painted with the colors included in the gradient, linearly in the direction you choose.

The gradient can include all the possible colors you use, including using a transparent gradient area instead of a color. To create a gradient from your chosen color to transparent, select the Gradient Tool. In the Options Bar, click on the gradient that is currently selected.

In the "Gradient Editor" dialog box that opens, create new gradient, in the “Name” field

Enter a name for your gradient and click on the “New” button. In the “Gradient Type” field, select “Solid”, and in “Smoothness” set it to 100%. Below “Smoothness” you will see the future gradient with color selection sliders at the top and bottom.

The upper sliders are responsible for the percentage of transparency of a particular color, the lower ones for the color of the gradient. Having selected colors in the lower sliders, you can adjust the percentage of their opacity by changing the “Opacity” and “Location” parameters in the corresponding upper sliders.

Click on the upper left slider and in its parameters in the “Stops” field, set 0% for “Opacity” and 0% for “Location”.

Go to the bottom left slider (also just by clicking on it). In these “Stops” parameters you also adjust “Location”, setting it to 0%, and select a color in the “Color” item, transparent color must match white color.

Now move to the right side of the sliders. In the parameters of the lower right slider, select the color you need, in the “Location” item set it to 100%.

In the parameters of the upper right slider, set “Opacity” and “Location” to 100%.

The gradient is ready and you can apply it. Click with the Gradient Tool on the part of the image where you want to start your gradient and drag the mouse cursor to the point where you want to continue it. If you are not working on a selected area, the gradient will be applied to the entire area of ​​the image.

To create gradients in Photoshop, use the Gradient Tool. In Photoshop you have the opportunity to create different types of gradients: “Linear gradient”, “Radial gradient”, “Angle gradient”, “Reflected gradient”, “Diamond gradient” (to select the gradient you need, use the corresponding buttons in the options bar, icons with a sample gradient view). Most often, it is “Linear gradient” that is used; the fill area is uniformly painted with the colors included in the gradient, linearly in the direction you choose.

The gradient can include all the possible colors you use, including using a transparent gradient area instead of a color. To create a gradient from your chosen color to transparent, select the Gradient Tool. In the Options Bar, click on the gradient that is currently selected.

In the “Gradient Editor” dialog box that opens, create a new gradient in the “Name” field

Enter a name for your gradient and click on the “New” button. In the “Gradient Type” field, select “Solid”, and in “Smoothness” set it to 100%. Below “Smoothness” you will see the future gradient with color selection sliders at the top and bottom.

The upper sliders are responsible for the percentage of transparency of a particular color, the lower ones for the color of the gradient. Having selected colors in the lower sliders, you can adjust the percentage of their opacity by changing the “Opacity” and “Location” parameters in the corresponding upper sliders.

Click on the upper left slider and in its parameters in the “Stops” field, set 0% for “Opacity” and 0% for “Location”.

Go to the bottom left slider (also just by clicking on it). In these “Stops” parameters, you also adjust “Location”, setting it to 0%, and select a color in the “Color” item; the transparent color should correspond to white.

Now move to the right side of the sliders. In the parameters of the lower right slider, select the color you need, in the “Location” item set it to 100%.

In the parameters of the upper right slider, set “Opacity” and “Location” to 100%.

The gradient is ready and you can apply it. Click with the Gradient Tool on the part of the image where you want to start your gradient and drag the mouse cursor to the point where you want to continue it. If you are not working on a selected area, the gradient will be applied to the entire area of ​​the image.

The Gradient tool allows you to draw several types of gradients. Also, using gradients in transparency mode, it is possible to achieve the effect of “fading” or “merging” two images into one.

All gradient types can be selected in the gradient section of:

Below are examples of how each type of gradient affects an image. On the left are the images after processing the gradient in Color mode with two opaque colors (and an alpha value of 255). On the right are images after processing with a gradient in Transparency mode:

Circular gradient in color and transparent modes

Creating a Gradient
To draw a gradient, simply click and hold the mouse button and move the cursor across the canvas, just as if you were drawing a line. The gradient will expand according to how you move the mouse.

After you release the mouse button, the gradient can be adjusted using its control points or “nodes” in the form of small circles. Click right click mouse over this “node” will change the primary and secondary colors of the gradient. If you move one of the "nodes" while holding down both mouse buttons, you can move the entire gradient area.

Color mode
The default Color mode affects everything color channels and alpha channel. When using a gradient in this mode, the primary color will gradually fade into the secondary color. If you use the right mouse button instead of the left mouse button, the primary and secondary colors change places. In the examples above, the gradient used the default primary and secondary colors (primary - black, secondary - white).

Transparency mode
The transparent gradient mode can be used to gradually fade out part of an image. This mode can also be useful for “blending” two images. To enable this mode, move the corresponding control element to the desired position:

This type of gradient only affects the alpha channel of the current layer. The gradient will smoothly change the alpha value of the primary color before inverting the alpha value of the secondary color. When using the right mouse button, the gradient will smoothly change its alpha value from the inverse of the secondary color's alpha value to the primary color's alpha value. Simply put, you can consider transparent gradient, as a smooth transition from full opacity (with an alpha value of 255) to full transparency (with an alpha value of 0).

To create a "fade" or "blend" between two images, place them on different layers, and then apply a gradient to the top layer using Transparency mode.

As an example, we use two images that were given in the description. Smooth transition You can easily create one image into another by “stretching” a transparent gradient from the left to the right edge of the image:

(on the left) in “one bundle” with the “Filling” bucket and is included in common with it shortcut key G. He also fills the drawing with “paint,” but not with a solid color, but with shimmers of different colors and shades with specified transitions from sharp boundaries to smooth, barely noticeable “flows” of one color into another or dense coloring into a transparent layer.

Tool settings panel

For a bucket, in the “Edit” menu there is a “Fill” command, where you can configure its parameters, indicating what color (or pattern) to fill, how to deal with transparent areas, etc. And the gradient in Photoshop colors everything indiscriminately, however, adhering to the boundaries of the selected area, if one is specified, but no other “conditions” are set for it.

The effect parameters, as in all other tools, are set in the settings panel at the top. Left-clicking on the small triangle next to the thumbnail on the left (or right-clicking on the picture) opens a palette with a preset set of standard color transitions.

This window contains own menu, which unfolds by clicking on the gear (or small arrow next to it) in the right top corner. Here you can select several more “standard” sets, moving through them with the “Replace Gradients” command, and set the size of the thumbnails, and by default, the gradient in Photoshop makes a smooth linear transition from the first color to the second.

IN standard sets There are also options for transitions to transparency, but in order for them to work, you need to check the “Transparency” checkbox, otherwise the picture will be evenly filled with one selected color.

In addition to the color options for the gradient, in the settings panel you can select its shape (linear, radial, cone-shaped, mirror and diamond-shaped).

Everything is clear with the choice of blending mode and opacity; checking the “Invert” box will create the opposite effect. We've sorted out transparency, and the Dithering function, which intentionally makes the image noisy, makes the color transition more natural.

Unlike the “bucket” fill, to draw a gradient, you need to turn on the tool and select the type of color transition, draw a line in the drawing, thereby indicating the starting and ending points of the effect. After this, the program will fill the document with colors with the selected tints and in the specified direction.

If you draw a line while pressing Shift key, the transition can be made strictly vertically, horizontally or at an angle of 45 degrees.

Chief editor of gradient fills

The collection of ready-made effects is presented in ten groups of options, each of which offers from 4 to 16 color solutions, so the choice is quite decent. But those for whom this is not enough need not worry, since we can create a gradient in Photoshop ourselves.

We opened a window with sets of preset color transitions by clicking on the small arrow next to the effect thumbnail. And if you click on the thumbnail itself, the “Editor...” will open, where, using the appropriate settings, we can create our own variations of color tints without any restrictions.

Photoshop offers two gradient fill modes: Continuous and Noise. By default, the “Continuous” mode is set, because in most cases, when wondering how to make a gradient in Photoshop, users have in mind the usual type of effect with smooth and gradual color transitions.

Building a continuous color transition

Colors are controlled by sliders (aka control points, aka markers) at the bottom of the gradient scale, and the top sliders control opacity. A control point is added by clicking on the corresponding border of the effect selection panel.

Clicking on a color/opacity control point activates the color/opacity selection boxes, scale positions (%) and the Delete button. In this case, on both sides of the new marker, the editor places middle points (diamonds) of color/opacity, which “silently” occupy the middle position between adjacent marker control points, but they can also be moved. At the midpoints of a color, the gradient in Photoshop displays equal mixtures of the initial and final colors, but the midpoints of opacity hardly need any comments.

Colors are selectable double click by reference point or by color sample in the " section Checkpoints". If the cursor is inside the gradient selection panel, it turns into an eyedropper, which you can use to select a color on the scale or directly on the image.

The "Smoothness" slider controls the smoothness of the transition between multi-colored and multi-colored stripes.

"Noisy" color transition

The Noise gradient, unlike the continuous mode effect, is a random distribution of colors within a specified range of colors. Depending on the smoothness (roughness) it may look like a "normal" effect with smooth transitions(smoothness/roughness up to 30-40%) or as a variegated, thin-banded spectrum (smoothness/roughness up to 90-100%).

In addition to adjusting the smoothness, when creating a transition you can:

  • choose color model(RGB, HSB, LAB);
  • limit colors (for overly saturated colors);
  • enable transparency (for random colors);
  • select "Other option" (an effect is created with arbitrary color transitions, but in accordance with the specified settings).

Save the created color transition

If you plan to further use the gradient, Photoshop has thought out everything about it.

For a new effect to be included in one of the preset (or custom) sets standard options, before approving the editor’s work (Ok), you need to come up with a name for it and enter it in the “Name” text field, and then click the “New” button.

You can "Save" the gradient on your disk as a file with the GRD extension ( Adobe Photoshop Gradient), which by default will end up in the Gradients folder in the Presets directory of your version of Adobe Photoshop. From there, new effects are extracted and loaded into the editor.

Gradient fill as a style

You can create (overlay) a gradient on a drawing (or blank canvas) in Photoshop from the layers panel by clicking on the corresponding button at the bottom and selecting the “Gradient Overlay” style.

In essence and settings, this function is no different from the color blend fill tool. True, here in the “Gradient Overlay” dialog box you do not need to draw a line manually, and the angle is set either by a radial arrow slider or by entering a numerical value.

"Painless" gradient on a service layer

Even at the very beginning, it was necessary to make a reservation that it is better to create this effect on a separate new layer, so as not to inadvertently spoil the drawing itself. But for this, in addition to regular layers, Photoshop provides service, or adjustment, layers, the list of which opens with a round black and white button at the bottom of the layers panel.

Among them there is also a “Gradient” layer, which is similar to the effect window in layer styles, where you can select a ready-made one or build your own color transition, specify a style, select an angle, scale, make an inversion, apply dithering and align to the layer.

How to use a gradient in Photoshop

You can write poems about the irresistibility of such coloring, but if you say it simply and briefly, then it’s beautiful. This is why it is so popular in design art and as a background pattern, but this effect can also be used to overlay a tonal transition on a drawing, use it as an alpha channel when creating a depth map, in combination with a layer mask, etc.