开发者

Exporting Gimp Gradient file

开发者 https://www.devze.com 2023-01-11 17:46 出处:网络
Does anyone know how the Gimp ggr gradient files are interpreted? Some of the included gradien开发者_Python百科ts are really nice and I want to reconstruct them. Are there any scripts that can export

Does anyone know how the Gimp ggr gradient files are interpreted? Some of the included gradien开发者_Python百科ts are really nice and I want to reconstruct them. Are there any scripts that can export these gradients to a file with color values or something?


The context menu in GIMP's gradient dialog has two export functions: "Save as POVRay" and "Save as CSS" - the later one might be useful for reuse.

The native GIMP gradient format is a pure-text format, which is self-explanatory to anyone opening the file - so reusing native GIMP files in your own projects would not be hard. It is interesting to note that GIMP gradients have some features that do not exist in other formats, so coding to interpret the files natively might make sense, as opposed as using some other gradient format. The features I can remember are: positioning the middle of the segment, the segment blending functions (that can be sinusoidal or spherical, besides linear) and the use of the dynamic "foreground" and "background" colors in the blend, instead of a fixed color.

Example of GIMP gradient file:

GIMP Gradient
Name: Mexican flag smooth
2
0.000000 0.250000 0.500000 0.000000 1.000000 0.000000 1.000000 1.000000 1.000000 1.000000 1.000000 0 0
0.500000 0.750000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 0.000000 0.000000 1.000000 0 0

So, this is a file with two segments, and for the first segment we have: starts at position 0, middle at 0.25, ending at 0.5, the left color being RGBA (0,1,0,1) (full opacity green), the right color is RGBA(1,1,1,1) (full opacity white). The other two numbers are one for the Blending function of the segment:

The blending function of the segment { GRADIENT-SEGMENT-LINEAR (0), GRADIENT-SEGMENT-CURVED (1), GRADIENT-SEGMENT-SINE (2), GRADIENT-SEGMENT-SPHERE-INCREASING (3), GRADIENT-SEGMENT-SPHERE-DECREASING (4) }

And the other for the coloring type:

The coloring type of the segment { GRADIENT-SEGMENT-RGB (0), GRADIENT-SEGMENT-HSV-CCW (1), GRADIENT-SEGMENT-HSV-CW (2) }

(I got the enum information from GIMP's procedure browser - at help->Procedure browser, looking at the description of the calls "gimp-gradient-segment-get-coloring-type" and "gimp-gradient-segment-get-blending-function")


Here's a Python script that reads them: ggr.py.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号