Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Can you apply a filter effect to a display.newText() display object?
Started by spacewolf Mar 24 2015 02:42 PM

3 replies to this topic
filter filters text display.newtext texts blur shadow filter.blurgaussian
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

spacewolf

[GLOBAL: userInfoPane.html]
spacewolf
  • Contributor

  • 298 posts
  • Enterprise

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.



[TOPIC: post.html]
#2

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

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



[TOPIC: post.html]
#3

spacewolf

[GLOBAL: userInfoPane.html]
spacewolf
  • Contributor

  • 298 posts
  • Enterprise

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



[TOPIC: post.html]
#4

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

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




[topic_controls]
[/topic_controls]