ULX

Author Topic: color rotation?  (Read 1814 times)

0 Members and 1 Guest are viewing this topic.

Offline talmera

  • Newbie
  • *
  • Posts: 36
  • Karma: 4
    • Tectonic-Gaming
color rotation?
« on: July 02, 2014, 01:07:03 AM »
So I was wondering if anyone knows of a way to have an entity smoothly rotate through the colours of the rainbow? I was thinking of having a table of colours to cycle through but i was unsure of how to set it up to do so.
« Last Edit: July 03, 2014, 04:01:54 AM by talmera »
It's not a sin if it can't make me cry
He's not the devil unless there's fire in his eyes
It ain't the ghost if it don't speak in tongue
It's not a victory 'till the battles been won

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: color rotation?
« Reply #1 on: July 02, 2014, 08:32:04 AM »
The easiest way is to use HSV color values instead of traditional RGB. See G.HSVToColor. If you set up a tick/think/whatever function to set the color of the entity every frame, you'll only need to increment the Hue value based on time. You could do that by storing your own variable and incrementing it manually, or just use the current time:
Code: [Select]
HSVToColor( CurTime() % 360, 1, 1 ).. Or something like that.

EDIT: You probably want to use RealTime() instead of CurTime(), as it appears that CurTime() is synced to the server, where RealTime() is not. CurTime() therefore could get out of sync or have lag issues, RealTime() should remain smooth on the clients.
« Last Edit: July 02, 2014, 08:37:53 AM by Stickly Man! »
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline talmera

  • Newbie
  • *
  • Posts: 36
  • Karma: 4
    • Tectonic-Gaming
Re: color rotation?
« Reply #2 on: July 03, 2014, 04:03:10 AM »
ooooh thanks for the reply stickly hadn't thought of HSV that makes things way more simple :3
It's not a sin if it can't make me cry
He's not the devil unless there's fire in his eyes
It ain't the ghost if it don't speak in tongue
It's not a victory 'till the battles been won