45603

iOS / GLES2: How to achieve Glow Effect

Question:

I have a compass style needle, free to spin.

I need it to glow when it approaches a certain orientation, say 55 degrees.

I want to have NeedleView subclass UIView, so I can manipulate (NeedleView*)needleView as if it was a UIView, just have a couple of extra methods - (void) feedAngle: (float) theta; - (void) feedGlow: (float) glow_01;

doing a bit of research, I have found that the common technique is to take a greyscale copy of the needle's image, blur it, save it as a GL texture, and then wrap it onto a quad that sits behind the actual needle's quad.

then I am a bit woolly....

I guess I set the RGBA on the corner points to be (r,g,b) of my desired glow colour, a=glowFactorForThisFrame

and then I set glBlendmode to something appropriate

and then I draw the textured quad for the blur

what I want is something where Alpha is 1 everywhere on the original needle, but it bleeds gradually to complete transparency as we move further away

...

for a start, I would like to find some code that takes care of blurring a greyscale bitmap, I would rather do this from code than in photo shop. (I realize this would take a lot of time on an actual device, so maybe I can calculate it the first time the app is run, save it to file, and subsequently just load from file)

secondly, I'm very sketchy on the precise details of what I have to do.

could someone help me in on either of these points?

Answer1:

If you use drawRect for your drawing your needle you could possible do something like this:

<a href="https://stackoverflow.com/questions/1229721/is-there-an-easy-way-or-library-available-to-let-text-glow/1230907#1230907" rel="nofollow">Is there an easy way or library available to let text glow?</a>

Answer2:

You could create the glow around the needle's image in Photoshop. Just replace the image in the app at runtime when glow is turned on.

Answer3:

I experimented with a lot of approaches here.

basically I neeed two images; one glowing and one not.

then I can draw them as CALayers on top of one another, and hijack CADisplayLink, setting

glowLayer.opacity = glowFac; dullLayer.opacity = (1 - glowFac);

I also played with fiddling around in GL shaders, passing the glow factor as a uniform, but this is a ton of code to do basically the same thing.

NB I needed to find a graphic artist to 'glow' the image

Recommend

  • Glassfish denies access to JSF page, returning 403 HTTP response code
  • Java Fullscreen Modal Dialogs
  • CKEditor on focus remove default value
  • Turn off autofocus for bootstrap-select / select2
  • Prevent timepicker addon from opening calendar
  • Laravel with different session lifetimes
  • ASP.NET Ajax
  • Can PyCharm set breakpoints on ipython notebook?
  • Associate ID with Class in CSS
  • How to vertically and horizontally center a div of unknown height
  • Selenium c#: WaitForCondition (how to find when ajax page is fully loaded)
  • .net security exception
  • formediting modals shows at wrong position
  • css calendar - td background diagonal split - two colors
  • Selectively hide background elements when overlayed with transparent div
  • Cut the background to expose the layer below
  • C#: Import/Export Settings into/from a File
  • netsh acl setting (need alternative method - registry settings?)
  • how to set variables in a php include file?
  • Salesforce Different WSDL files and when to use
  • Android application: how to use the camera and grab the image bytes?
  • How to view images from protected folder with php?
  • How does document.ready work with angular element directives?
  • Using a canvas object in a thread to do simple animations - Java
  • presentShareDialogWithParams posts to FB wall, but callback handler results say error
  • How can I set a binding to a Combox in a UserControl?
  • How can I enlarge video fullscreen without the affected interface project in as3?
  • AJAX Html Editor Extender upload image appearing blank
  • Time complexity of a program which involves multiple variables
  • Python urlparse: small issue
  • Checking free space on FTP server
  • FileReader+canvas image loading problem
  • Recording logins for password protected directories
  • In LanguageTool, how do you create a dictionary and use it for spell checking?
  • How to set the response of a form post action to a iframe source?
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • python draw pie shapes with colour filled
  • reshape alternating columns in less time and using less memory