I'm trying to create a lua function that will cycle the color of a memrec through a rainbow gradient, and I'm certain I'm close to success here, but I feel like my math is off or something.. it continues flashing to incorrect colors randomly but otherwise works as it should.
If somebody could help I'd greatly appreciate it. Attached is my demo table, comments included for every script. Table's lua script needs to run to function. There's a commented-out debug print where the color is generated in the main lua.
The color is determined by combining three out-of-phase sinewaves and combining them as RGB.
Rainbow Memrec Coloring
-
- Table Makers
- Posts: 690
- Joined: Mon Jul 06, 2020 3:19 am
- Reputation: 1260
Re: Rainbow Memrec Coloring
I suspect it's an issue with your biasing. When it suddenly flashes to another color you can assume that the value wrapped around to 257 or -1.
Here's what I came up with that seems to work ok:
Here's what I came up with that seems to work ok:
- Attachments
-
- colorChanger.CT
- (6.55 KiB) Downloaded 200 times
Last edited by aSwedishMagyar on Tue Aug 10, 2021 1:18 am, edited 1 time in total.
Re: Rainbow Memrec Coloring
Yours works perfectly, thanks a million for the help!
I'll have to see what I can change in mine, or simply adapt yours a bit.. using it as a way to highlight things for a tutorial script lol.
Is there a particular reason you're using n×pi/4 as phases versus their closest counterparts? I couldn't notice much of a difference, but I'd like to know what you think on it.
I'll have to see what I can change in mine, or simply adapt yours a bit.. using it as a way to highlight things for a tutorial script lol.
Is there a particular reason you're using n×pi/4 as phases versus their closest counterparts? I couldn't notice much of a difference, but I'd like to know what you think on it.
-
- Table Makers
- Posts: 690
- Joined: Mon Jul 06, 2020 3:19 am
- Reputation: 1260
Re: Rainbow Memrec Coloring
It's mostly just because that's how I think of phase offsets with radians..EpicBirdi wrote: ↑Tue Aug 10, 2021 1:16 amYours works perfectly, thanks a million for the help!
I'll have to see what I can change in mine, or simply adapt yours a bit.. using it as a way to highlight things for a tutorial script lol.
Is there a particular reason you're using n×pi/4 as phases versus their closest counterparts? I couldn't notice much of a difference, but I'd like to know what you think on it.
I modified that script to also have a background function so you can really see the difference since I can't really tell with the small text on the records.
Oh and the transition will be less choppy if you change the update timer:
Code: Select all
local upTimer = getUpdateTimer()
upTimer.SetInterval(1)
Who is online
Users browsing this forum: No registered users