Hi all,
I'm trying to generalize a method so that I can apply a predefined filter across multiple display objects.
Based on applying an effect like this:
displayObject.fill.effect = "filter.colorPolynomial" displayObject.fill.effect.coefficients = { 0, 0, 1, 0, --red coefficients 0, 0, 1, 0, --green coefficients 0, 1, 0, 0, --blue coefficients 0, 0, 0, 1 --alpha coefficients }
I tried the following:
--Applies the given effect to the view and overviews displayViewImageFilter = function (thisEffect) --Apply to back image viewBackImage.fill.effect = thisEffect --Apply to all overviews for i, overviewImage in pairs(overviews) do overviewImage.fill.effect = thisEffect end end
But I can't figure out how to build the thisEffect parameter so that it can be passed into the method. Trying code below will return "Attempt to index thisEffect (a string value)":
local thisEffect = "filter.colorPolynomial" thisEffect.coefficients = { 0, 0, 1, 0, --red coefficients 0, 0, 1, 0, --green coefficients 0, 1, 0, 0, --blue coefficients 0, 0, 0, 1 --alpha coefficients } displayViewImageFilter(thisEffect)
I assume there's something going on behind the scenes when you set displayObject.fill.effect to a String. Is what I'm trying to do even possible?
Cheers.