Skip to content

Commit

Permalink
RESET_COLOR and RESET_ALPHA fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Drulikar committed Sep 25, 2023
1 parent fd0bcfb commit 6021245
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,19 @@ world
if(layer_image.alpha == 0)
continue

var/apply_color = TRUE
var/apply_alpha = TRUE

if(layer_image == copy) // 'layer_image' is an /image based on the object being flattened.
curblend = BLEND_OVERLAY
add = icon(layer_image.icon, layer_image.icon_state, base_icon_dir)
else // 'I' is an appearance object.
add = getFlatIcon(image(layer_image), curdir, curicon, curstate, curblend, FALSE, no_anim)
var/image/layer_as_image = image(layer_image)
if(layer_as_image.appearance_flags & RESET_COLOR)
apply_color = FALSE
if(layer_as_image.appearance_flags & RESET_ALPHA)
apply_alpha = FALSE
add = getFlatIcon(layer_as_image, curdir, curicon, curstate, curblend, FALSE, no_anim)
if(!add)
continue

Expand Down Expand Up @@ -468,17 +476,17 @@ world
flatY1 = addY1
flatY2 = addY2

// Blend the overlay into the flattened icon
flat.Blend(add, blendMode2iconMode(curblend), layer_image.pixel_x + 2 - flatX1, layer_image.pixel_y + 2 - flatY1)
if(apply_color && appearance.color)
if(islist(appearance.color))
add.MapColors(arglist(appearance.color))
else
add.Blend(appearance.color, ICON_MULTIPLY)

if(appearance.color)
if(islist(appearance.color))
flat.MapColors(arglist(appearance.color))
else
flat.Blend(appearance.color, ICON_MULTIPLY)
if(apply_alpha && appearance.alpha < 255)
add.Blend(rgb(255, 255, 255, appearance.alpha), ICON_MULTIPLY)

if(appearance.alpha < 255)
flat.Blend(rgb(255, 255, 255, appearance.alpha), ICON_MULTIPLY)
// Blend the overlay into the flattened icon
flat.Blend(add, blendMode2iconMode(curblend), layer_image.pixel_x + 2 - flatX1, layer_image.pixel_y + 2 - flatY1)

if(no_anim)
//Clean up repeated frames
Expand Down

0 comments on commit 6021245

Please sign in to comment.