Types/Sprite: Difference between revisions
m (→shift: added pixel) |
m (typo) |
||
(22 intermediate revisions by 4 users not shown) | |||
Line 11: | Line 11: | ||
Technically optional, but path to sprite cannot be empty. | Technically optional, but path to sprite cannot be empty. | ||
== Optional properties == | == Optional properties == | ||
Line 30: | Line 20: | ||
If this property is present, all other properties are ignored and the mandatory properties do not have to be defined. | If this property is present, all other properties are ignored and the mandatory properties do not have to be defined. | ||
Layers may not be an empty table. | |||
=== hr_version === | === hr_version === | ||
Line 36: | Line 28: | ||
If this property exists and high resolution sprites are turned on, its contents are used to load the sprite. | If this property exists and high resolution sprites are turned on, its contents are used to load the sprite. | ||
=== slice === | === slice or dice === | ||
'''Type''': [[Types/SpriteSizeType]] | '''Type''': [[Types/SpriteSizeType]] | ||
Line 43: | Line 35: | ||
Example: If this is 4, the sprite will be sliced into a 4×4 grid. | Example: If this is 4, the sprite will be sliced into a 4×4 grid. | ||
=== slice_x === | === slice_x or dice_x === | ||
'''Type''': [[Types/SpriteSizeType]] | '''Type''': [[Types/SpriteSizeType]] | ||
Same as <code>slice</code> above, but this specifies only how many slices there are on the x axis. | Same as <code>slice</code> or <code>dice</code> above, but this specifies only how many slices there are on the x axis. | ||
=== slice_y === | === slice_y or dice_y === | ||
'''Type''': [[Types/SpriteSizeType]] | '''Type''': [[Types/SpriteSizeType]] | ||
Same as <code>slice</code> above, but this specifies only how many slices there are on the y axis. | Same as <code>slice</code> or <code>dice</code> above, but this specifies only how many slices there are on the y axis. | ||
=== priority === | === priority === | ||
'''Type''': [[Types/ | '''Type''': [[Types/SpritePriority]] | ||
'''Default''': "medium" | '''Default''': "medium" | ||
=== flags === | === flags === | ||
'''Type''': [[Types/SpriteFlags]] | '''Type''': [[Types/SpriteFlags]] | ||
=== size === | |||
'''Type''': [[Types/SpriteSizeType]] or [[Types/table]] of [[Types/SpriteSizeType]] | |||
The width and height of the sprite. If this is an array, the first member of the array is the width and the second is the height. Otherwise the size is both width and height. | |||
Width and height may only be in the range of 0-8192. | |||
=== width === | |||
'''Type''': [[Types/SpriteSizeType]] | |||
Mandatory if <code>size</code> is not given. Width of the picture in pixels, from 0-8192. | |||
=== height === | |||
'''Type''': [[Types/SpriteSizeType]] | |||
Mandatory if <code>size</code> is not given. Height of the picture in pixels, from 0-8192. | |||
=== x === | === x === | ||
Line 82: | Line 83: | ||
Vertical position of the sprite in the source file in pixels. | Vertical position of the sprite in the source file in pixels. | ||
=== position === | |||
'''Type''': [[Types/table]] of [[Types/SpriteSizeType]] | |||
Loaded only when <code>x</code> and <code>y</code> are both 0. The first member of the array is x and the second is y. | |||
=== shift === | === shift === | ||
Line 88: | Line 94: | ||
'''Default''': {0, 0} | '''Default''': {0, 0} | ||
In tiles. util. | In tiles. util.by_pixel() can be used to divide the shift by 32 which is the usual pixel height/width of 1 tile in normal resolution. Note that 32 pixel tile height/width is not enforced anywhere - any other tile height or width is also possible. | ||
=== scale === | === scale === | ||
Line 102: | Line 108: | ||
'''Default''': false | '''Default''': false | ||
Only one of <code>draw_as_shadow</code>, <code>draw_as_glow</code> and <code>draw_as_light</code> can be true. <code>draw_as_shadow</code> takes precedence over <code>draw_as_glow</code> and <code>draw_as_light</code>. | |||
=== draw_as_glow === | |||
'''Type''': [[Types/bool]] | |||
'''Default''': false | |||
Only one of <code>draw_as_shadow</code>, <code>draw_as_glow</code> and <code>draw_as_light</code> can be true. <code>draw_as_glow</code> takes precedence over <code>draw_as_light</code>. | |||
Draws first as a normal sprite, and again as a light layer.<sup>[https://forums.factorio.com/91682]</sup> | |||
=== draw_as_light === | |||
'''Type''': [[Types/bool]] | |||
'''Default''': false | |||
Only one of <code>draw_as_shadow</code>, <code>draw_as_glow</code> and <code>draw_as_light</code> can be true. | |||
=== mipmap_count === | |||
'''Type''': [[Types/uint8]] | |||
'''Default''': 0 | |||
Only loaded if this is an icon (has flag "group=icon" or "group=gui"). | |||
=== apply_runtime_tint === | === apply_runtime_tint === | ||
Line 114: | Line 145: | ||
=== blend_mode === | === blend_mode === | ||
'''Type''': [[Types/ | '''Type''': [[Types/BlendMode]] | ||
'''Default''': "normal" | '''Default''': "normal" | ||
=== load_in_minimal_mode === | === load_in_minimal_mode === | ||
Line 138: | Line 162: | ||
Whether alpha should be premultiplied. | Whether alpha should be premultiplied. | ||
=== generate_sdf === | |||
'''Type''': [[Types/bool]] | |||
'''Default''': false | |||
This property is only used by sprites used in [[Prototype/UtilitySprites]] that have the "icon" flag.<br> | |||
If this is set to true, the game will generate an icon shadow (using signed distance fields) for the sprite. | |||
Example of the icon shadow in the character modifier icon used by the steel axe research.<br> | |||
[[File:Generate_sdf_example.png]] | |||
== Example == | == Example == | ||
picture = | <syntaxhighlight lang="lua">picture = | ||
{ | { | ||
filename = "__base__/graphics/entity/basic-accumulator/basic-accumulator.png", | filename = "__base__/graphics/entity/basic-accumulator/basic-accumulator.png", | ||
Line 147: | Line 182: | ||
height = 103, | height = 103, | ||
shift = {0.7, -0.2} | shift = {0.7, -0.2} | ||
} | }</syntaxhighlight> | ||
{{Prototype property type usage|{{FULLPAGENAME}}?Sprite]}} |
Latest revision as of 11:50, 11 June 2021
Basics
Specifies one picture that can be used in the game.
When there is more than one sprite or animation frame with the same source file and dimensions/position in the game, they all share the same memory.
Mandatory properties
filename
Type: Types/FileName
Default: ""
Technically optional, but path to sprite cannot be empty.
Optional properties
layers
Type: Types/table of Types/Sprite
If this property is present, all Sprite definitions have to be placed as entries in the array, and they will all be loaded from there. Each item (Sprite definition) in the array may also have the layers
property.
If this property is present, all other properties are ignored and the mandatory properties do not have to be defined.
Layers may not be an empty table.
hr_version
Type: Types/Sprite
If this property exists and high resolution sprites are turned on, its contents are used to load the sprite.
slice or dice
Type: Types/SpriteSizeType
Number of slices this is sliced into when using the "optimized atlas packing" option. If you are a modder, you can just ignore this property.
Example: If this is 4, the sprite will be sliced into a 4×4 grid.
slice_x or dice_x
Type: Types/SpriteSizeType
Same as slice
or dice
above, but this specifies only how many slices there are on the x axis.
slice_y or dice_y
Type: Types/SpriteSizeType
Same as slice
or dice
above, but this specifies only how many slices there are on the y axis.
priority
Type: Types/SpritePriority
Default: "medium"
flags
Type: Types/SpriteFlags
size
Type: Types/SpriteSizeType or Types/table of Types/SpriteSizeType
The width and height of the sprite. If this is an array, the first member of the array is the width and the second is the height. Otherwise the size is both width and height.
Width and height may only be in the range of 0-8192.
width
Type: Types/SpriteSizeType
Mandatory if size
is not given. Width of the picture in pixels, from 0-8192.
height
Type: Types/SpriteSizeType
Mandatory if size
is not given. Height of the picture in pixels, from 0-8192.
x
Type: Types/SpriteSizeType
Default: 0
Horizontal position of the sprite in the source file in pixels.
y
Type: Types/SpriteSizeType
Default: 0
Vertical position of the sprite in the source file in pixels.
position
Type: Types/table of Types/SpriteSizeType
Loaded only when x
and y
are both 0. The first member of the array is x and the second is y.
shift
Type: Types/vector
Default: {0, 0}
In tiles. util.by_pixel() can be used to divide the shift by 32 which is the usual pixel height/width of 1 tile in normal resolution. Note that 32 pixel tile height/width is not enforced anywhere - any other tile height or width is also possible.
scale
Type: Types/double
Default: 1
Values different than 1 specify the scale of the sprite on default zoom. Scale 2 means that the picture will be 2 times bigger on screen (and more pixelated).
draw_as_shadow
Type: Types/bool
Default: false
Only one of draw_as_shadow
, draw_as_glow
and draw_as_light
can be true. draw_as_shadow
takes precedence over draw_as_glow
and draw_as_light
.
draw_as_glow
Type: Types/bool
Default: false
Only one of draw_as_shadow
, draw_as_glow
and draw_as_light
can be true. draw_as_glow
takes precedence over draw_as_light
.
Draws first as a normal sprite, and again as a light layer.[1]
draw_as_light
Type: Types/bool
Default: false
Only one of draw_as_shadow
, draw_as_glow
and draw_as_light
can be true.
mipmap_count
Type: Types/uint8
Default: 0
Only loaded if this is an icon (has flag "group=icon" or "group=gui").
apply_runtime_tint
Type: Types/bool
Default: false
tint
Type: Types/Color
Default: {r=1, g=1, b=1, a=1} (white)
blend_mode
Type: Types/BlendMode
Default: "normal"
load_in_minimal_mode
Type: Types/bool
Default: false
Minimal mode is entered when mod loading fails. You are in it when you see the gray box after (part of) the loading screen that tells you a mod error (Example). If you are a modder, you can just ignore this property.
premul_alpha
Type: Types/bool
Default: true
Whether alpha should be premultiplied.
generate_sdf
Type: Types/bool
Default: false
This property is only used by sprites used in Prototype/UtilitySprites that have the "icon" flag.
If this is set to true, the game will generate an icon shadow (using signed distance fields) for the sprite.
Example of the icon shadow in the character modifier icon used by the steel axe research.
Example
picture =
{
filename = "__base__/graphics/entity/basic-accumulator/basic-accumulator.png",
priority = "extra-high",
width = 124,
height = 103,
shift = {0.7, -0.2}
}
Prototype properties that use this type
- Prototype/Accumulator : picture
- Prototype/Arrow : arrow_picture
- Prototype/Arrow : circle_picture
- Prototype/ArtilleryProjectile : chart_picture
- Prototype/ArtilleryProjectile : picture
- Prototype/ArtilleryProjectile : shadow
- Prototype/Beacon : base_picture
- Prototype/Beacon : radius_visualisation_picture
- Prototype/Container : picture
- Prototype/ElectricEnergyInterface : picture
- Prototype/ElectricPole : active_picture
- Prototype/ElectricPole : radius_visualisation_picture
- Prototype/Equipment : sprite
- Prototype/FluidTurret : out_of_ammo_alert_icon
- Prototype/HeatInterface : picture
- Prototype/Inserter : hand_base_picture
- Prototype/Inserter : hand_base_shadow
- Prototype/Inserter : hand_closed_picture
- Prototype/Inserter : hand_closed_shadow
- Prototype/Inserter : hand_open_picture
- Prototype/Inserter : hand_open_shadow
- Prototype/ItemRequestProxy : picture
- Prototype/Lamp : picture_off
- Prototype/Lamp : picture_on
- Prototype/LandMine : picture_safe
- Prototype/LandMine : picture_set
- Prototype/LandMine : picture_set_enemy
- Prototype/LinkedContainer : picture
- Prototype/Market : picture
- Prototype/MiningDrill : radius_visualisation_picture
- Prototype/OffshorePump : placeable_position_visualization
- Prototype/PipeToGround : pictures
- Prototype/PowerSwitch : led_off
- Prototype/PowerSwitch : led_on
- Prototype/ProgrammableSpeaker : sprite
- Prototype/Reactor : heat_lower_layer_picture
- Prototype/Reactor : lower_layer_picture
- Prototype/Reactor : picture
- Prototype/Reactor : working_light_picture
- Prototype/Roboport : base
- Prototype/Roboport : base_patch
- Prototype/RocketSilo : base_day_sprite
- Prototype/RocketSilo : base_front_sprite
- Prototype/RocketSilo : base_night_sprite
- Prototype/RocketSilo : door_back_sprite
- Prototype/RocketSilo : door_front_sprite
- Prototype/RocketSilo : hole_light_sprite
- Prototype/RocketSilo : hole_sprite
- Prototype/RocketSilo : red_lights_back_sprites
- Prototype/RocketSilo : red_lights_front_sprites... further results