iOS / GLES2: How to achieve Glow Effect

前端 未结 3 755
旧时难觅i
旧时难觅i 2021-01-25 09:09

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 UI

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-25 09:37

    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

提交回复
热议问题