BETTER COLOR3 - Enhanced colour manipulation module

I’m out of things to add to the module :sob:

If anyone has any ideas on what to add that isn’t in the module please tell me them!!

3 Likes

version 1.2

Perfoming the modulo % opperation between a color3 and another color3, Color3 or number would perform the standard modulo equation, where self’s RGB values have the modulo operation performed on them with the other RGB values, where new R = self.R % other.R. If other is a number, the same number would be performed on all RGB values.

Performing the floor // would work just as the modulo method but using the // arithmetic operation.

Performing the power ^ would work jsut as module method but using the ^ arithmetic operation.
(prior to this update, if the other input was less than 1, then it would power, if not then it would use the xor operation, now that’s been replaced by color:bxor())

new functions for color3 objects

:invert()
Returns a new color3, with the binary NOT operation performed on the RGB values.

:band(other: color3|Color3|number)
Returns a new color3, with the binary AND operation performed between self and other.

:bor(other: color3|Color3|number)
Returns a new color3, with the binary OR operation performed between self and other.

:bxor(other: color3|Color3|number)
Returns a new color3, with the binary XOR operation performed between self and other.

1 Like

I feel weird… Why is there no reply, only updates…

why is this thread so lonely…

is there something i am supposed to know and I don’t?

4 Likes

Making modules can be fun. But before you upload it as a public resource, ask these questions to yourself:

  • What more does this have than the thing I’m trying to improve?
  • Does this solve anything?
  • Why would people use it? Why not?
  • Does it handle multiple use cases, or just one?
  • Is it making things easier, or harder?

Let me elaborate:

Do you think anybody would use this? I have no idea what “chrominance” is…

This is so specific, I don’t think you need to add random functions like this. Instead, it would be good to generalize methods, making the programmer add a bit more code, but also allowing it to be used for many different things apart from just one thing.

2 Likes

This module makes Color3 easier by allowing arithmetic operations to be conducted on it, aswell as bitwise operations.

Also for specific functions, I really only made them because there wasn’t much else that I thought to add at that time, functions such as color3.tweenInterator() really only came because I learnt what iterator functions were whilst developing the module.

Also Red & Blue chrominance, alongside luminance, are explained in this video here, which is where I got the idea for the function from and is where I’d likely make more functions for calculations in the video:

It can also have multiple use cases, can be used to replace the default Color3 (although when setting values that only accept Color3’s, the color3 would have to be called)

Thanks for reply though! I’ll try make function names better and more useful! :cool:

2 Likes

version 1.2.2

A fix (and minor additions) to new functions in 1.2

The bitwise functions of :band(), :bor(), bxor() now take in a tuple instead of a singular output, color3’s, Color3’s and numbers are still only the valid types for this function.

New bitwise function :bnand(), like the other bitwise operations, takes in a tuple. The output is similar to the output of :band() but reversed.

REMOVED FUNCTIONS

color3:AverageLerp() depricated in favour of color3:Lerp()

RENAMED FUNCTIONS

color3.noise() renamed to: color3.fromNoise()
color3.random() renamed to color3.fromRandom()

YUV fix

Functions: color3:fromYUV() and color3:toYUV() have been corrected to a more accurate YUV calculation model source

Previously, outdated calculations were used for the YUV conversion, which didn’t align with each other, meaning that if a color3 is converted into a yuv and converted back, it would be far different than the original color3.

I’m considering adding metamethods for <, >, >= & <= metamethods, but since color3 has 3 values, I’ll hold a vote on what value should be used to compare the RGB values:

  • Luminance / Grayscale of the RGB
  • Sum of R, G & B
  • Average of R, G & B

0 voters

Nice module, will you consider adding this as a package to wally? that would be very useful

version 1.3

NOTE: boolean operators only work between color3 values, trying to use them between a color3 and a traditional Color3 value will result in an error.

NEW METAMETHODS

As promised, the methods <, >, ==, >= & <= have been added.

Function renames

color3:band()color3:Conjunction()
color3:bor()color3:Disjunction()
color3:inverse()color3:negate()
color3:bxor()color3:E_Disjunction()
color3:bnand()color3:N_Conjunction

color3:Lerp()color3:LerpRGB()

Removed functions

color3:SineLerp() and color3:QuadLerp() have been replaced by color3:LerpRGB(), where as a third input, the Lerp function takes in a string. Either "linear", "quad" or "sine"
color3:tweenIterator() has been removed, not yet replaced with a new method but I’m considering using the __iter() metamethod for a replacement.

Other changes

Lerp is now calculated without switching to traditional Color3 to do the :Lerp() operation.

Soon convertions via HUV will be done directly with the color3 module, instead of its current method of switching to the traditional Color3 value to perform Color3:ToHUV() or Color3:FromHUV()

New update will be soon, just don’t know what to add.

If any of you got ideas on what the module is missing, or what the module can do better, then please make a comment here!

I have no idea why this resource is so dead. There are tons of useful color3 operations that most libraries have on other engines, such as color * color.

But there’s one thing…

I would use this module to work with EditableImages, but they work with pure RGBA values, so as a developer myself, I don’t really see myself using this.

You could maybe try to integrate this to support raw RGBA numbers, but I honestly don’t think it would be worth it since, well, numbers have math.

3 Likes

I have an old project that can run kernel effects on a canvas with RGB (no A) values, I may revisit that project and make a module for it using BETTER COLOR3 and my existing code.

Here’s that project:

oh wow, these are awesome! These would work great with EditableImage and CanvasDraw projects. Very cool!

Thought I’d make a poll on what you guys think of the module

How are the functions in the module?

if you think the module lacks functions, please tell me which functions they are so that I can add them!

  • The module has all neccesary functions that I need
  • The module lacks some functions but most are included
  • The module lacks has too many insignificant functions
  • The module lacks a few minor functions

0 voters

Have you used the module?

  • I use the module for my projects currently
  • I don’t use the module, but have tested it
  • I don’t use the module, but I may when i need to
  • I never used the module and don’t intend to

0 voters

Are the metamethods assigned approperitely?

  • The metamethods make sence for their uses
  • Some metamethods are a bit confusing but most are OK
  • I have no opinion

0 voters

I guess this would be for the lazy ones (kinda like me), but perhaps a function to return RGB values, rather their intensity (0 - 255).

Nevermind, disregard this. I was not using the module properly.

perhaps demonstrations of its usage! like a custom shader or something

RGBA update

color3 objects now carry an A (alpha) value, representing transparency. 255 means fully visible and 0 means fully transparent.

Bytepack conversions now convert into this new format:

New functions:

color3:fromRGBA()
Takes in R, G, B and A values and turns them into a color3 object

color3:AlphaComposite()
Takes a tuple of color3 objects, and combines them using their transparency.

Renamed functions:

color3:fromNoise() → color3:fromPerlinNoise()

All bitwise functions were renamed to:
:bitAND, :bitXNOR, :bitOR, :bitNAND, :bitXOR

FIxed bytepack conversion issues and added:

color3object:RROT()
color3object:LROT()
color3object:RSHIFT()
color3object:LSHIFT()

These are based off the bit32 library