Gradient Object Simplified Format

Used by the following utility scripts:

Explicit format

Solid gradient

Defined as a JSON object:
{
    "name": name,
    "gradientForm": gradientForm,
    "interpolation": interpolation,
    "colors": colors,
    "transparency": transparency
}

name : string (or null in input)
gradientForm : string (required to be "customStops")
interpolation : number (0 to 4096)

colors : JSON array of color stops, each one being a JSON object:
{
    "location": location,
    "midpoint": midpoint,
    "type": type,
    "color": color
}

location : number (0 to 4096)
midpoint : number (percentage; 0% to 100%)
type : string (among "foregroundColor", "backgroundColor", "userStop")
color : [optional, only if type is "userStop"] JSON object (in Color Object Simplified Format)

transparency : [optional in input] JSON array of transparency stops, each one being a JSON object:
{
    "location": location,
    "midpoint": midpoint,
    "opacity": opacity
}

location : number (0 to 4096)
midpoint : number (percentage; 0% to 100%)
opacity : number (percentage; 0% to 100%)

Noise gradient

Defined as a JSON object:
{
    "name": name,
    "gradientForm": gradientForm,
    "randomSeed": randomSeed,
    "showTransparency": showTransparency,
    "vectorColor": vectorColor,
    "smoothness": smoothness,
    "colorSpace": colorSpace,
    "minimum": minimum,
    "maximum": maximum
}

name : string (or null in input)
gradientForm : string (required to be "colorNoise")
randomSeed : number
showTransparency : boolean
vectorColor : boolean
smoothness : number (0 to 4096)
colorSpace : string ("RGBColor" or "HSBColorEnum" or "labColor")
minimum : JSON array of four numbers, i.e., three color components (0 to 100) + transparency (0)
maximum : JSON array of four numbers, i.e., three color components (0 to 100) + transparency (100)

Minimal format

Solid gradient

Defined as a five-element JSON array:
[ name, gradientForm, interpolation, colors, transparency ]

name : string (or null in input)
gradientForm : string (required to be "customStops")
interpolation : number (0 to 4096)
colors : JSON array of color stops, each one being a JSON array of three or four elements:

type Value
"foregroundColor"
"backgroundColor"
[ location, midpoint, type ]
"userStop" [ location, midpoint, type, color ]

location : number (0 to 4096)
midpoint : number (percentage; 0% to 100%)
type : string (among "foregroundColor", "backgroundColor", "userStop")
color : [optional, only if type is "userStop"] JSON array (in Color Object Simplified Format)

transparency : [optional in input] JSON array of transparency stops, each one being a JSON array of three elements:

          Value
            [ location, midpoint, opacity ]

location : number (0 to 4096)
midpoint : number (percentage; 0% to 100%)
opacity : number (percentage; 0% to 100%)

Noise gradient

Defined as a nine-element JSON array:
[ name, gradientForm, randomSeed, showTransparency, vectorColor, smoothness, colorSpace, minimum, maximum ]

name : string (or null in input)
gradientForm : string (required to be "colorNoise")
randomSeed : number
showTransparency : boolean
vectorColor : boolean
smoothness : number (0 to 4096)
colorSpace : string ("RGBColor" or "HSBColorEnum" or "labColor")
minimum : JSON array of four numbers, i.e., three color components (0 to 100) + transparency (0)
maximum : JSON array of four numbers, i.e., three color components (0 to 100) + transparency (100)

Notes

  • The two different kinds of gradients (and their corresponding format) are automatically discriminated based on the value of the element gradientForm: either "customStops" or "colorNoise".
  • interpolation, location and smoothness have values between 0 and 4096 whereas they are expressed as percentages (0% to 100%) in the gradient editor dialog.

Examples

{
    "name": "Foreground to Background",
    "gradientForm": "customStops",
    "interpolation": 4096,
    "colors":
    [
        { "location": 0, "midpoint": 50, "type": "foregroundColor" },
        { "location": 4096, "midpoint": 50, "type": "backgroundColor" }
    ],
    "transparency":
    [
        { "location": 0, "midpoint": 50, "opacity": 100 },
        { "location": 4096, "midpoint": 50, "opacity": 100 }
    ]
}
[
    "Foreground to Background",
    "customStops",
    4096,
    [
        [ 0, 50, "foregroundColor" ],
        [ 4096, 50, "backgroundColor" ]
    ],
    [
        [ 0, 50, 100 ],
        [ 4096, 50, 100 ]
    ]
]

Foreground to Background Gradient Editor Dialog

{
    "name": "Blue, Red, Yellow",
    "gradientForm": "customStops",
    "interpolation": 4096,
    "colors":
    [
        {
            "location": 0, "midpoint": 50, "type": "userStop",
            "color": { "hue": 240, "saturation": 100, "brightness": 100 }
        },
        {
            "location": 2048, "midpoint": 50, "type": "userStop",
            "color": { "hue": 0, "saturation": 100, "brightness": 100 }
        },
        {
            "location": 4096, "midpoint": 50, "type": "userStop",
            "color": { "hue": 60, "saturation": 100, "brightness": 100 }
        }
    ],
    "transparency":
    [
        { "location": 0, "midpoint": 50, "opacity": 100 },
        { "location": 4096, "midpoint": 50, "opacity": 100 }
    ]
}
[
    "Blue, Red, Yellow",
    "customStops",
    4096,
    [
        [ 0, 50, "userStop", [ "HSBColorClass", [ 240, 100, 100 ] ] ],
        [ 2048, 50, "userStop", [ "HSBColorClass", [ 0, 100, 100 ] ] ],
        [ 4096, 50, "userStop", [ "HSBColorClass", [ 60, 100, 100 ] ] ]
    ],
    [
        [ 0, 50, 100 ],
        [ 4096, 50, 100 ]
    ]
]

Blue Red Yellow Gradient Editor Dialog

{
    "name": "Color Noise",
    "gradientForm": "colorNoise",
    "randomSeed": 345807450,
    "showTransparency": false,
    "vectorColor": true,
    "smoothness": 1024,
    "colorSpace": "RGBColor",
    "minimum": [ 0, 18, 25, 0 ],
    "maximum": [ 100, 60, 73, 100 ]
}
[
    "Color Noise",
    "colorNoise",
    345807450,
    false,
    true,
    1024,
    "RGBColor",
    [ 0, 18, 25, 0 ],
    [ 100, 60, 73, 100 ]
]

Color Noise Gradient Editor Dialog

Tags: , , , ,

Comments are closed.