2-Dimensional Gradient (2DG) produces a new layer containing a gradient that changes in two dimensions. People using non-English-language GIMP installations are encouraged to upgrade to this version.
9 sample gradients follow (collected into a single image):
It can generate gradients from corner colors, edge gradients and/or the existing image. Options may be manually set, randomly created or duplicated from an existing 2DG layer.
The layer options used are stored in the created layer name. The option duplication feature depends on this name.
Once installed and Script-Fu refreshed, 2DG can be found under Filters > Render > Pattern. It will be active if there is an active RGB image.
If you have a selection active when you run this script, the gradient area will be a rectangle sized to the selection. Non-rectangular selections will be supported through creation of an edit mask, but the gradient will be based on a rectangle.
Due to looping logic, the wider or taller the image, the longer it will take to render. So you might want to try gradients on a smaller image first, then reproduce the gradient on a larger image if you like the results. The "Current 2DG layer - all settings" option supports doing this action after trying other gradients or after closing and re-launching GIMP.
Choose whether to enter all of the options yourself, or to generate some of them randomly.
Current 2DG Layer: If you have an existing 2DG layer selected, you can also choose to duplicate some of the options from the existing 2DG layer. This is handy if you want to replicate a smaller test in a larger area.
If you choose Random - all options or Current 2DG layer - all options, there is no point in setting any of the other options manually as they will be ignored (except for the checkbox to allow image source as an edge method).
Corner colors (top left, top right, bottom left, bottom right):
Specify colors to occupy the 4 corner pixels of the rectangle. This option will only have an effect for a particular corner if at least one adjacent edge uses that corner to generate the edge contents and the fill method uses that edge to generate the fill contents.
Gradients (top, bottom, left, right):
Specify gradients to occupy the edges of the rectangle. This option will only have an effect for a particular edge if the edge method chosen for that edge uses the gradient to generate the edge contents and the fill method chosen uses that specific edge to generate the selection fill.
Choose between RGB, HSV (clockwise hue) or HSV counter-clockwise.
Specify how to create the edge contents, either using a gradient between corner colors, using a specific gradient or using the existing image contents. This option will only have an effect for a particular edge if the fill method chosen uses that edge to generate the fill contents.
- If choosing Top to bottom, the left and right edges will be ignored.
- If choosing Left to right, the top and bottom edges will be ignored.
- If choosing a diagonal method, all edges will be used.
Edge repeat rule:
For each edge, allows specifying 0 to 9 repeats. "S" is for sawtooth repeat (color A to color B, repeat A to B, repeat A to B, etc.) T is for triangle repeat (color A to color B, repeat B to A, repeat A to B, etc.). The rule is positional. Specify count and S or T for top, then a space, then count and S or T for bottom, then a space, count and S or T for left, then a space, and finally count and S or T for right. The repeat rule for a particular edge will only have an effect if a gradient or adjacent corners are used to generate that edge and that edge is used by the fill method to create the fill.
Allow image source as an edge method in randomly-generated layers:
If you check this, generating a random layer can use the image source to create one or more edges of this layer. The downside of allowing this is that the layers produced using the image rule are harder or impossible to duplicate.
- May randomly fail, leaving a temporary selection active. If this occurs, Select All, then Select None to clear the selection.
- May not do a good job of handling gradients involving transparency/alpha.
- May not detect that the Current 2DG layer option has been chosen to use on a layer that is either not a 2DG layer or is a 2DG layer but has had its layer name changed. At the moment, anything not filled in by this procedure will be taken from the manually-set options.
- May not repeat evenly; there may be a sliver on the right or bottom which is particularly noticeable when sawtooth repeat is used.
- Includes unused options in the self-documenting layer name, which may lead to unnecessary effort by someone duplicating settings manually from reading the layer name.
- Is not sufficiently commented in the code.
Version 1.2 Corrected gradient name logic so that the script no longer would fail from being used in a non-English installation of GIMP.
I gratefully acknowledge forum assistance from GIMP registry members Saul Goode and bootchk for helping me to understand particularly thorny (to me) aspects of TinyScheme. In addition, the 2DG code includes a number-to-hex conversion subroutine from Saul Goode which I also used as a model for a hex-to-number conversion subroutine. This assistance and code help me significantly in my quest to provide self-documenting layer names and using the self-documentation feature to allow retrieving settings from an existing, currently active, 2DG layer. I also appreciate forum assistance from Rob A, now known as ffaat.