Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
shifting gradient colors ?
#1
Is there existing a plugin/script that can shift a gradient by x steps? Let's take a gradient with 256 colors and I want to shift the gradient colors by 2 steps. Then all colors move 2 steps to the right (or left) and colors 255 / 256 become colors 1 and 2.
Reply
#2
A GGR file being basically a text file, did you try to edit one and move the first two color lines to the bottom?
Reply
#3
Ofnuts, thanks for the reply. I've seen that the first line is a number that corresponds with the amount of lines in the gradient. The first line begin with 0.000000 and is also the end  value of the last line. I'll try it out.
Reply
#4
@Ofnuts, I've moved 2 lines from a gradient file from the bottom to the top (line 256 to line 2, line 255 to line 1) and saved the file on the same folder with a new name. Gimp could'n find the gradient. Then I changed also the name of the gradient in the file and gimp could'n find the gradient. Then I simply copy a gradient and saved it with a new name in the same folder and gimp did find this copy. I look further to find out why this happens.
I'll search out with the help of this tools how the gradient file is build : http://gimpchat.com/viewtopic.php?f=12&t...5&start=20
Reply
#5
Another technique: you can easily build simple gradients from palettes (this is actually faster than building the gradient from scratch). See Palette to gradient in the menu in the Palettes list. So if you can create your first gradient that way, to shift it you just have to edit the palette, move the first two colors to the end, and re-create a new gradient from that.

   

   
Reply
#6
I could not get moving an entry in the .ggr file working. Gimp not happy with that Wink

I thought there must be better way than generating a gradient from an image, and Ofnuts had something up his sleeve. Although editing a palette is easy.

Another way

RobA http://www.silent9.com/incoming/scripts/ Has a script gradient-from-image.scm (look for date 2009-04-09). Very quick.

Does what it says. Then use Layer -> Transform -> Offset to nudge the gradient image along. Repeat gradient-from-image.scm

example: https://i.imgur.com/m4pCu5C.mp4

Might work for you depending on requirements.
Reply
#7
Ofnuts and Rich, sorry for the late reaction and thanks for the solutions concerning this issue. I prefer the solution Rich suggested. I have problems with shifting colors in palettes. Every time I try to move a color, it move to its original position in the palette. I think I don't quite understand the workflow Ofnuts suggested.
Reply
#8
(10-29-2021, 08:20 AM)denzjos Wrote: ...snip....I think I don't quite understand the workflow Ofnuts suggested.

A Gimp palette file something.gpl is text, edit it with a suitable text editor.

A existing palette is right click Palette-to-Gradient which gives new gradient in the Gradient dock.

   

Edit the .gpl , this one moved bottom line to the top (remember to save/update it).
Refresh the palettes for the edit to take effect, Repeat Palette-to-Gradient

   
Reply
#9
Rich, thank you for the explanation. Now I got it. Ofnuts, thanks again for the tip (I could'nt find the right way because I was't on the right track... Blush )
Issue solved.
Reply
#10
I've made a LibreOffice Calc spreadsheet to easy multiple shift values in a gimp palette file. 
How to use it : 
- open a palette gpl file in a text editor
- select all the text
- copy the selection
- paste the selection in the A1 cell from the spreadsheet
- in most cases the A column contain a header with some numbers underneath, column B sometimes contain some text
Columns A and B are the original values and will not changed
Columns D and E are copies from column A and B and are used to work with
Column E is used for calculation, don't change it
Columns H and I contain the new shifted values
There is only one value one have to fill in to shift the values ; cell L1
If the shift value is greater than the length of the file then there is a warning in cell L2
After a shift value is filled in, the values in columns H and I are shifted straight away
To save the shifted values :
- select the values in column H an I (not the columns)
- File / Print (choose 'print to file' and 'print selected cells')
- save it as 'name_x.gpl' where x is a number if one make several shifted palette files
As an example, if the imported palette file has 256 lines with values, one can shift with value 50,100,150,200 and every time save the values with names : green01.gpl, green02.gpl.........green04.gpl.
You just have to load the original file once to do this.
To change the value in another palette, just erase column A and B and paste the new palette as described above.  

.7z   shift gimp palette rows.7z (Size: 30.24 KB / Downloads: 148)
   
Reply


Forum Jump: