How to create a radial gradient programmatically

Max Finch

  • *
  • Posts: 2186
So I'm working on a small project and I've come across a little challenge, I need to create a radial gradient background in my scene with a radius that adjusts in size.


Has anyone tried this? I figured I might translate an AS3 article to Openfl but there might be an easier way?

Justin

  • *
  • Posts: 4312
Going with the AS3 article is probably the easiest way. Generally Openfl is very close to AS3.

You can look at the code we use to draw gradient backgrounds in Stencyl and compare it to the AS3 article. Assuming they use the same method, the code should be pretty similar.

Stencyl/plaf/haxe/lib/stencyl/1,00/com/stencyl/models/background/GradientBackground.hx

For Live Support: Join our discord server and ping me @justin.
I'm most often available between 8am and midnight Japan time. (GMT+9)