Can you apply a filter effect to a display.newText() display object?

Hi all,

I am new to using filters and so far haven’t had any luck applying them to a display.newText() object. Is this possible to do?

My goal is to create a text shadow that is blurred using the filter.blurGaussian corona effect.

Here is some code:

 local newTextOptions = { text = self.textString, font = self.fontId, fontSize = self.fontSize, align = self.align, width = self.width, height = self.height, } self.shadowTextDisplayObject = display.newText(newTextOptions) self.shadowTextDisplayObject:setFillColor(0, 0, 0) self.shadowTextDisplayObject.fill.effect = "filter.blurGaussian" self.shadowTextDisplayObject.fill.effect.horizontal.blurSize = 100 self.shadowTextDisplayObject.fill.effect.vertical.blurSize = 100 self.view:insert(self.shadowTextDisplayObject)

However, this doesn’t seem to be working. Am I doing something wrong?

Thanks in advance.

Hi @spacewolf,

Text objects are technically masked objects, so you should convert the text object into a snapshot (or duplicate it as one) and then apply the gaussian blur to the snapshot object.

Take care,

Brent

Thanks Brent. How do I convert the text object into a snapshot object?

Well basically, you add it to the snapshot’s .group. This guide should help you figure it out:

http://docs.coronalabs.com/guide/graphics/snapshot.html

Brent

Hi @spacewolf,

Text objects are technically masked objects, so you should convert the text object into a snapshot (or duplicate it as one) and then apply the gaussian blur to the snapshot object.

Take care,

Brent

Thanks Brent. How do I convert the text object into a snapshot object?

Well basically, you add it to the snapshot’s .group. This guide should help you figure it out:

http://docs.coronalabs.com/guide/graphics/snapshot.html

Brent