Json Types

The colors used by visualizers are fully resource-packable and are defined using three types of data

Color Definition

A color definition defines a static color and the name/tooltip associated with it. They are objects with the following fields

  • color: A color object, the color of the definition
  • name: A text component, the descriptor of the color in the color key
  • sort: An integer, the sort number of the color in the color key for visualizer types that support automatic color key reordering. Optional, defaults to 100
  • tooltip: A text component, the descriptor of the color when hovering over the preview pane in tooltip mode. Optional, defaults to name

Example: tfc/tfcgenviewer/color/rock/rock/raw/limestone.json

{
  "color": {
    "r": 136,
    "g": 127,
    "b": 107
  },
  "name": {
    "translate": "color.tfc.rock.limestone"
  },
  "sort": 5
}

Color

A color is an object with three fields

  • r: The red value, in the range [0, 255]
  • g: The green value, in the range [0, 255]
  • b: The blue value, in the range [0, 255]

Color Gradient Definition

A color gradient definition defines a color gradient, its name, and its tooltips. They are objects with the following fields

  • gradient: A gradient
  • name: A text component, the descriptor of the gradient in the color key
  • tooltips: A list of text components, the descriptors of the gradient, from low to high, of the gradient when hovering over the preview pane in tooltip mode. Optional, defaults to name

Example: tfcgenviewer/tfcgenviewer/gradients/rainfall.json

{
  "gradient": {
    "type": "preset",
    "preset": "tfcgenviewer:rainfall"
  },
  "name": {
    "translate": "tfcgenviewer.gradient.rainfall"
  },
  "tooltips": [
    {
      "translate": "tfcgenviewer.gradient.rainfall.0"
    },
    {
      "translate": "tfcgenviewer.gradient.rainfall.1"
    },
    {
      "translate": "tfcgenviewer.gradient.rainfall.2"
    },
    {
      "translate": "tfcgenviewer.gradient.rainfall.3"
    },
    {
      "translate": "tfcgenviewer.gradient.rainfall.4"
    }
  ]
}

Gradient

A gradient converts a value in the range [0, 1] into a color, usually by interpolating between specified colors in the linear sRGB color space. It is an object with the following definition

  • type: One of "preset", "static", "from_to", or "list". There are different required fields depending on the type
    • preset: Has one additional field, preset, a string, the id of a registered gradient. By default, the available preset gradients are
      • tfcgenviewer:blue
      • tfcgenviewer:green
      • tfcgenviewer:volcanic
      • tfcgenviewer:uplift
      • tfcgenviewer:rainfall
      • tfcgenviewer:temperature
      • tfcgenviewer:grayscale
    • static: Has one additional field, color, a color. Creates a static gradient of just the single color
    • from_to: Has two additional fields, from and to, both are colors, the low and high ends of the gradient
    • list: Has one additional field, colors, a list of at least three colors. Creates a gradient interpolating between all the colors provided from low to high

Registry Linked Color Definition

A registry linked color definition associates one or more registry objects with a color definition. They are used in situations when it would be desirable to have multiple things described by the same color

They are objects with two fields

  • color: A color definition
  • keys: A list of strings, the ids of the registry elements to link to the color

Example: tfcgenviewer/tfcgenviewer/visualizable_feature_color/coral.json

{
  "color": {
    "color": {
      "r": 255,
      "g": 153,
      "b": 22
    },
    "name": {
      "translate": "tfcgenviewer.visualized_feature.coral"
    }
  },
  "keys": [
     "tfc:coral_claw",
     "tfc:coral_tree",
     "tfc:coral_mushroom"
   ]
}