Comments (5)
I completely agree with you. The fact that it is not possible at all to create a color with RGB values of (1, 1, 1) on a 0-255 scale is a huge oversight.
I will add explicit constructors to use when you are sure of the format of the numbers.
from ellyb.
Pretty sure Github still doesn't let people PR against wiki pages, but here's a slightly messy diff with the newly added constructors for the docs if you get a chance.
diff --git a/Color.md b/Color.md
index 43929b2..7cdab0d 100644
--- a/Color.md
+++ b/Color.md
@@ -1,6 +1,8 @@
The Color model provides methods to handle colors and colored text.
-## Color(red, green, blue, [alpha]) or Color(colorCode) or Color(colorTable)
+# Constructor
+
+## Color(red, green, blue[, alpha]) or Color(colorCode) or Color(colorTable)
Constructor. Used to create a new Color.
@@ -10,7 +12,41 @@ local yellow = Ellyb.Color(255, 255, 0);
local grey = Ellyb.Color("#CCC");
local purple = Ellyb.Color({ r = 1, g = 0, b = 1});
```
-
+
+**Note:** The `Color(red, green, blue[, alpha])` signature accepts values in either a floating point range and a byte value range. The byte value range is deprecated; see `Color:CreateFromRGBAsBytes()`.
+
+# Static Methods
+
+## CreateFromRGBA(red, green, blue[, alpha])
+
+Constructs a new `Color` instance with the given RGBA values treated as floating point values in the range 0-1.
+
+```lua
+local mahogany = Ellyb.Color:CreateFromRGBA(0.75, 0.25, 0);
+```
+
+## CreateFromRGBAAsBytes(red, green, blue[, alpha])
+
+Constructs a new `Color` instance with the given RGBA values treated as byte values in the range 0-255.
+
+Unlike the class constructor, this static method is capable of constructing a `Color` correctly when the input values are all equal to 1.
+
+```lua
+local malachite = Ellyb.Color:CreateFromRGBAAsBytes(11, 218, 81);
+```
+
+## CreateFromHexa(colorCode)
+
+Constructs a new `Color` instance with the given RGBA hexadecimal color code in the form `#RGB`, `#RRGGBB`, or `#RRGGBBAA`.
+
+Any prefixing `#` or present `|c` UI escape sequence will be stripped automatically (see `ColorManager.hexaToNumber`).
+
+```lua
+local azure = Ellyb.Color:CreateFromHexa("#0080ff");
+```
+
+# Instance Methods
+
## __tostring()
Get a text representation of the Color: the hexadecimal code of the Color, colored using [UI escape sequences].
from ellyb.
Thanks :D It is updated, I just fixed the usage of :
instead of .
. Since they are static methods they do not use the :
notation that passes self
:)
from ellyb.
I should have proofread it some more, but the deprecation notice should point to Color.CreateFromRGBAAsBytes
(had the colon and was missing the A in RGBA).
from ellyb.
Fixed :)
from ellyb.
Related Issues (20)
- Shared user settings
- Animations module
- Animated warning alert frame
- Transitionators optimisation
- Serialization module
- Mixin to show a tooltip when cursor is over truncated text
- Search input mixin
- Purple in ColorManager is pink
- [8.0] Deferred XML Node object named ... already exists HOT 2
- Class system is fundamentally borked in latest versions
- Dropdowns HOT 2
- Bug: Trying to resolve a Promise that has already been resolved
- Editbox with edits history
- Unit:IsMountable() error on Classic client
- Integrated Twitter-based bug reporting tool
- Date/time module
- Reverse lookup for localization
- Secure library via metatables? HOT 1
- Textures manager HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ellyb.