garrysmod
garrysmod copied to clipboard
Math for Color class
new metaevents support __unm
, __add
, __sub
, __mul
, __div
, __lt
, __le
new methods: :Invert()
, :Copy()
, :Normalize()
, :GetNormalized()
Could you give some examples/documentation that makes these operations defined and sensible for rgb colours?
Could you give some examples/documentation that makes these operations defined and sensible for rgb colours?
arithmetic operators allows to write cleaner code, this is useful in complex code - eg for pseudo shaders (we dont have shaders api, so cope with rt & render.ReadPixel)
I actively use pseudo shaders in my projects, for example one of it implements bloom for some vgui elements
here are some examples how color math can be used:
https://gist.github.com/Be1zebub/66a16af468e2f2d7e2a9fc0dc9ee9311