Types/IconSpecification: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(link to Types/IconData#Notes so they aren't in different places)
 
(9 intermediate revisions by 4 users not shown)
Line 2: Line 2:
Specifies the icon of an entity/item/technology/recipe etc. The properties are specified directly in the prototype, not in another sub-property.
Specifies the icon of an entity/item/technology/recipe etc. The properties are specified directly in the prototype, not in another sub-property.


Either <code>icons</code> and optionally <code>icon_size</code>, or both <code>icon</code> and <code>icon_size</code> have to be specified.
Either <code>icons</code> and optionally <code>icon_size</code>, or both <code>icon</code> and <code>icon_size</code> have to be specified. If both <code>icons</code> and <code>icon</code> are defined, <code>icon</code> is ignored.
== Prototype properties: Option 1 ==
== Prototype properties: Option 1 ==
=== icons ===
=== icons ===
'''Type''': [[Types/table]] of [[Types/IconData]]
'''Type''': [[Types/table]] of [[Types/IconData]]


The rendering order of the individual icons follows the table (array) order: Later added icons (higher index) get drawn on top of previously added icons (lower index).  
Can't be an empty table. See [[Types/IconData#Notes]] for further notes on icon layering and its behaviour.


=== icon_size ===
=== icon_size ===
Line 13: Line 13:


Mandatory if <code>icon_size</code> is not specified inside all instances of [[Types/IconData]] inside <code>icons</code>. The size of the square icon, in pixels, e.g. 32 for a 32px by 32px icon.
Mandatory if <code>icon_size</code> is not specified inside all instances of [[Types/IconData]] inside <code>icons</code>. The size of the square icon, in pixels, e.g. 32 for a 32px by 32px icon.
=== icon_mipmaps ===
'''Type''': [[Types/uint8]]
'''Default''': 0
Icons of reduced size will be used at decreased scale. 0 or 1 mipmaps is a single image. The file must contain 1/2 size images with a geometric-ratio, for each mipmap level. Each next level is aligned to the upper-left corner. Example sequence: 128x128@(0,0), 64x64@(128,0), 32x32@(196,0) is 3 mipmaps.<br>See also [https://factorio.com/blog/post/fff-291 Factorio Friday Facts #291] about the visual effects of icon mipmaps.


== Prototype properties: Option 2 ==
== Prototype properties: Option 2 ==
Line 19: Line 26:


Path to the icon file.
Path to the icon file.
=== icon_size ===
=== icon_size ===
'''Type''': [[Types/SpriteSizeType]]
'''Type''': [[Types/SpriteSizeType]]


Mandatory. The size of the square icon, in pixels, e.g. 32 for a 32px by 32px icon.
Mandatory. The size of the square icon, in pixels, e.g. 32 for a 32px by 32px icon.
=== icon_mipmaps ===
'''Type''': [[Types/uint8]]
'''Default''': 0
Icons of reduced size will be used at decreased scale. 0 or 1 mipmaps is a single image. The file must contain 1/2 size images with a geometric-ratio, for each mipmap level. Each next level is aligned to the upper-left corner. Example sequence: 128x128@(0,0), 64x64@(128,0), 32x32@(196,0) is 3 mipmaps.<br>See also [https://factorio.com/blog/post/fff-291 Factorio Friday Facts #291] about the visual effects of icon mipmaps.
== Examples ==
Simple icon with size:
<syntaxhighlight lang="lua">
  icon = "__base__/graphics/icons/fluid/heavy-oil.png",
  icon_size = 32,
</syntaxhighlight>
Layered icon, size defined outside of layers:
<syntaxhighlight lang="lua">icon_size = 32,
icons = {
  {
    icon = "__base__/graphics/icons/fluid/barreling/empty-barrel.png"
  },
  {
    icon = "__base__/graphics/icons/fluid/barreling/barrel-side-mask.png",
    tint = { a = 0.75,  b = 0, g = 0, r = 0 }
  },
  {
    icon = "__base__/graphics/icons/fluid/barreling/barrel-hoop-top-mask.png",
    tint = { a = 0.75, b = 0.5, g = 0.5, r = 0.5 }
  }
}</syntaxhighlight>
Layered icon, size defined per layer:
<syntaxhighlight lang="lua">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 }
  }
}</syntaxhighlight>

Latest revision as of 10:29, 18 October 2022

Basics

Specifies the icon of an entity/item/technology/recipe etc. The properties are specified directly in the prototype, not in another sub-property.

Either icons and optionally icon_size, or both icon and icon_size have to be specified. If both icons and icon are defined, icon is ignored.

Prototype properties: Option 1

icons

Type: Types/table of Types/IconData

Can't be an empty table. See Types/IconData#Notes for further notes on icon layering and its behaviour.

icon_size

Type: Types/SpriteSizeType

Mandatory if icon_size is not specified inside all instances of Types/IconData inside icons. The size of the square icon, in pixels, e.g. 32 for a 32px by 32px icon.

icon_mipmaps

Type: Types/uint8

Default: 0

Icons of reduced size will be used at decreased scale. 0 or 1 mipmaps is a single image. The file must contain 1/2 size images with a geometric-ratio, for each mipmap level. Each next level is aligned to the upper-left corner. Example sequence: 128x128@(0,0), 64x64@(128,0), 32x32@(196,0) is 3 mipmaps.
See also Factorio Friday Facts #291 about the visual effects of icon mipmaps.

Prototype properties: Option 2

icon

Type: Types/FileName

Path to the icon file.

icon_size

Type: Types/SpriteSizeType

Mandatory. The size of the square icon, in pixels, e.g. 32 for a 32px by 32px icon.

icon_mipmaps

Type: Types/uint8

Default: 0

Icons of reduced size will be used at decreased scale. 0 or 1 mipmaps is a single image. The file must contain 1/2 size images with a geometric-ratio, for each mipmap level. Each next level is aligned to the upper-left corner. Example sequence: 128x128@(0,0), 64x64@(128,0), 32x32@(196,0) is 3 mipmaps.
See also Factorio Friday Facts #291 about the visual effects of icon mipmaps.

Examples

Simple icon with size:

  icon = "__base__/graphics/icons/fluid/heavy-oil.png",
  icon_size = 32,

Layered icon, size defined outside of layers:

icon_size = 32,
icons = {
  {
    icon = "__base__/graphics/icons/fluid/barreling/empty-barrel.png"
  },
  {
    icon = "__base__/graphics/icons/fluid/barreling/barrel-side-mask.png",
    tint = { a = 0.75,  b = 0, g = 0, r = 0 }
  },
  {
    icon = "__base__/graphics/icons/fluid/barreling/barrel-hoop-top-mask.png",
    tint = { a = 0.75, b = 0.5, g = 0.5, r = 0.5 }
  }
}

Layered icon, 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 }
  }
}