Factorio Prototype DocsVersion 2.0.26

IconData :: struct Example code

One layer of an icon. Icon layering follows the following rules:

  • The rendering order of the individual icon layers follows the array order: Later added icon layers (higher index) are drawn on top of previously added icon layers (lower index).

  • By default the first icon layer will draw an outline (or shadow in GUI), other layers will draw it only if they have draw_background explicitly set to true. There are caveats to this though. See the doc.

  • When the final icon is displayed with transparency (e.g. a faded out alert), the icon layer overlap may look undesirable.

  • When the final icon is displayed with a shadow (e.g. an item on the ground or on a belt when item shadows are turned on), each icon layer will cast a shadow and the shadow is cast on the layer below it.

  • The final icon will always be resized and centered in GUI so that all its layers fit the target slot, but won't be resized when displayed on machines in alt-mode. For example: recipe first icon layer is size 128, scale 1, the icon group will be displayed at resolution /4 to fit the 32px GUI boxes, but will be displayed 4 times as large on buildings.

  • Shift values are based on expected_icon_size / 2.

The game automatically generates icon mipmaps for all icons. However, icons can have custom mipmaps defined. Custom mipmaps may help to achieve clearer icons at reduced size (e.g. when zooming out) than auto-generated mipmaps. If an icon file contains mipmaps then the game will automatically infer the icon's mipmap count. Icon files for custom mipmaps must contain half-size images with a geometric-ratio, for each mipmap level. Each next level is aligned to the upper-left corner, with no extra padding. Example sequence: 128x128@(0,0), 64x64@(128,0), 32x32@(192,0) is three mipmaps.

Properties

icon :: FileName

Path to the icon file.

Path to the icon file.

icon_size optional :: SpriteSizeType

The size of the square icon, in pixels. [...]

The size of the square icon, in pixels. [...]

tint optional :: Color

The tint to apply to the icon.

The tint to apply to the icon.

shift optional :: Vector

Used to offset the icon "layer" from the overall icon. [...]

Used to offset the icon "layer" from the overall icon. [...]

scale optional :: double

Defaults to (expected_icon_size / 2) / icon_size. [...]

Defaults to (expected_icon_size / 2) / icon_size. [...]

draw_background optional :: bool

Outline is drawn using signed distance field generated on load.One icon image, will have only one SDF generated. [...]

Outline is drawn using signed distance field generated on load.One icon image, will have only one SDF generated. [...]

Properties

icon :: FileName

Path to the icon file.

icon_size :: SpriteSizeType optional

Default: 64

The size of the square icon, in pixels. E.g. 32 for a 32px by 32px icon. Must be larger than 0.

tint :: Color optional

Default: {r=1, g=1, b=1, a=1}

The tint to apply to the icon.

shift :: Vector optional

Default: {0, 0}

Used to offset the icon "layer" from the overall icon. The shift is applied from the center (so negative shifts are left and up, respectively). Shift values are "in pixels" where the overall icon is assumed to be expected_icon_size / 2 pixels in width and height, meaning shift {0, expected_icon_size/2} will shift it by entire icon height down.

scale :: double optional

Defaults to (expected_icon_size / 2) / icon_size.

Specifies the scale of the icon on the GUI scale. A scale of 2 means that the icon will be two times bigger on screen (and thus more pixelated).

Expected icon sizes:

draw_background :: bool optional

Default: true for the first layer, false otherwise

Outline is drawn using signed distance field generated on load.One icon image, will have only one SDF generated. But if the image is used in multiple icon with different scales, outline width won't match the desired width in all the scales but the largest one.

Examples

-- one icon layer
{
  icon = "__base__/graphics/icons/fluid/heavy-oil.png",
  icon_size = 64,
  scale = 0.5,
  shift = {4, -8}
}
-- Layered icon, with size defined per layer
icons = {
  {
    icon = "__base__/graphics/icons/fluid/barreling/barrel-empty.png",
    icon_size = 32
  },
  {
    icon = "__base__/graphics/icons/fluid/barreling/barrel-empty-side-mask.png",
    icon_size = 32,
    tint = { a = 0.75, b = 0, g = 0, r = 0 }
  },
  {
    icon = "__base__/graphics/icons/fluid/barreling/barrel-empty-top-mask.png",
    icon_size = 32,
    tint = { a = 0.75, b = 0.5, g = 0.5, r = 0.5 }
  },
  {
    icon = "__base__/graphics/icons/fluid/crude-oil.png",
    icon_size = 32,
    scale = 0.5,
    shift = {7, 8}
  }
}

Prototypes

Types

Defines