Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The "look" of gradients
#1
Out of curiosity, I made a graph to see the effect of the "blending function" in a gradient, and how it behaves if the midpoint is changed.

   

The "50" gradients have the default midpoint position, and the "75" one have the midpoint dragged to 75% of the range.

To replicate, adapt and run this code in the Python console, and copy/paste the result to a CSV that you feed to your favorite spreadsheet application.

Code:
def valueAt(layer,x,y):
    _,rgb=pdb.gimp_drawable_get_pixel(layer,x,y)
    return sum(rgb[:3])/3.

def dumpLayer(layer):
    y=layer.height/2
    pts=['%.1f' % valueAt(layer,x,y) for x in range(layer.width)]
    print '"%s",%s' % (layer.name, ','.join(pts))

def dumpImage(image):
    for layer in [l for l in image.layers if l.visible]:
        dumpLayer(layer)
        

image=gimp.image_list()[0]
dumpImage(image)

Source XCF also attached.

Edit: some code updates (works with alpha channel, and dumps only visible layers)


Attached Files
.xcf   Gradients.xcf (Size: 384.53 KB / Downloads: 316)
Reply
#2
(12-18-2022, 10:09 AM)Ofnuts Wrote: Out of curiosity, I made a graph to see the effect of the "blending function" in a gradient, and how it behaves if the midpoint is changed.



The "50" gradients have the default midpoint position, and the "75" one have the midpoint dragged to 75% of the range.
Thanks Ofnuts....quite useful.
So then what you are doing is changing the values  (pointed to by the red arrows)  on the sample line of this guide sheet that I made to help me sort out the ggr file structure?


Attached Files Thumbnail(s)
   


Reply
#3
(12-18-2022, 09:16 PM)rickk Wrote:
(12-18-2022, 10:09 AM)Ofnuts Wrote: Out of curiosity, I made a graph to see the effect of the "blending function" in a gradient, and how it behaves if the midpoint is changed.



The "50" gradients have the default midpoint position, and the "75" one have the midpoint dragged to 75% of the range.
Thanks Ofnuts....quite useful.
So then what you are doing is changing the values  (pointed to by the red arrows)  on the sample line of this guide sheet that I made to help me sort out the ggr file structure?

Exactly. In practice I want to do a specific non-linear gradient, and I was wondering if I could make it more accurate by playing with the curve types and/or the  mid-points (answer: curve type: no, but midpoint: perhaps).

Curved is interesting: the doc describes it as "Gradient varies more quickly on ends of the range than on its middle." but this is wrong, Curved is better that this: you use the midpoint to set where the middle value of the gradient will be, and it creates a smooth curve that goes through the three points.

Otherwise, looking  at the curves moving the midpoint is in general a bad idea since if entails a sharp bend in the function that translates into a abrupt color change in the generated gradient. It is only useful with Linear (if you have several segments) or Curved (if you have only one).

Unless all of this can be smoothed by pdb.gimp_gradient_segment_range_blend_colors(name, start_segment, end_segment), but I have yet to figure that one out.
Reply
#4
I recall a user coming here and lamenting how (in his experience) the color transition (range?) transpired too abruptly.

IMO. the gradient editor is remarkably robust, once the user gets cozy with that right-click menu. Which unfortunately does not give up it's secrets easily. For a user seeking a "two-click" solution, I believe they will be frustrated in most instances.

Takes some getting used to, with trial and error. And for most folks just wanting to bang out a meme, requiring more effort than they are willing to invest.
Have you considered spreading your color over multiple segments?

Instead of:
0 0.5 1

Maybe spread it over
0 0.25 0.5
0.5 0.75 1

Something like that just to get more control points...then play with the math to get the range spread to your satisfaction?


Reply
#5
(12-19-2022, 01:00 AM)rickk Wrote: I recall a user coming here and lamenting how (in his experience) the color transition (range?) transpired too abruptly.

IMO. the gradient editor is remarkably robust, once the user gets cozy with that right-click menu. Which unfortunately does not give up it's secrets easily.  For a user seeking a "two-click" solution, I believe they will be frustrated in most instances.

Takes some getting used to, with trial and error.  And for most folks just wanting to bang out  a meme, requiring more effort than they are willing to invest.
Have you considered spreading your color over multiple segments?

Instead of:
0 0.5 1

Maybe spread it over
0 0.25 0.5
0.5 0.75 1

Something like that just to get more control points...then play with the math to get the range spread to your satisfaction?

I currently generate the gradient with a script... 80 control points or so, it's just a variable :-) Just wondering if I can get something smoother with fewer control points. "Perfection isn't when there is nothing left to add, but when there is nothing left to remove."
Reply


Forum Jump: