Bug Issue: Effects on Image Instances not stacking


Pages: 1

Luyren

  • Master Stencyler
  • *
June 22, 2022, 08:11:52 pm
Tested on Windows, b11028, happening on Desktop target.

When applying an effect through the "apply effect [] to [instance]" block, only the first effect is applied. Any subsequent effect does not reflect on the image instance.

Through a discussion on Discord, we figured out there was an inconsistency in the setFilterForImage function in Script.hx. The original problematic line is 2810:
Code: [Select]
img.img.filters = img.filters.concat([filter]);

If I switch both to "img.img", or just to "img." (applying the same to the clearFiltersForImage function right below) allows for stacking effects. When I switched to "img.img.", there was a caveat: the new stack of effects is only applied when you make a change to the image that instance is from. Using the "draw image onto image" or "set pixel" blocks both enabled the update. When I switched everything to just "img.", this issue disappeared.

This is what I changed the lines in Script.hx to, and everything worked as expected with these as far as I could tell:
Code: [Select]
public static function setFilterForImage(img:BitmapWrapper, filter:BitmapFilter)
{
if(img != null)
{
img.filters = img.filters.concat([filter]);
}
}

public static function clearFiltersForImage(img:BitmapWrapper)
{
if(img != null)
{
img.filters = [];
}
}

I don't know if  if there are any other ramifications.

Related Discord discussion: https://discord.com/channels/209323692205932544/227870283749523459/989172953876951110
The linked message is a reply to the my first message that spawned the discussion.

Sample Game: all code is in the "Test Actor" events tab.  Test on a desktop target.
- Press up to apply a tint effect at 20%, only one will appear. Pressing up more than once won't change the image instance any further without the changes on Script.hx.
- Press down to set a pixel in the image. All the previously stacked effects will appear at once, in case the caveat I mentioned happens after the change.
- Press enter to remove all effects.


New attachment added by Luyren - June 22, 2022, 08:12:18 pm


Issue updated by Luyren - June 23, 2022, 07:29:46 pm
  • Status changed from New to Resolved


Justin

  • Master Stencyler
  • *
June 29, 2022, 10:41:39 pm
The fix here is included in 4.1.0-beta3/b11034. Thanks for the contribution, Luyren!


Pages: 1

Details

  • Reported
    June 22, 2022, 08:11:52 pm
  • Updated
    June 29, 2022, 10:41:39 pm

  • View Status
    Public
  • Type
    Bug
  • Status
    Resolved
  • Priority
    Normal
  • Version
    3.5.0 beta 1
  • Fixed in
    (none)
  • Assigned to
    (none)
  • Category
    Design Mode Blocks

Tags


Attachments

* Stacking Image Effects.stencyl (172.27 kB - downloaded 252 times.)