From 53b70b45853320cd7f099948c59de3242ab9c73d Mon Sep 17 00:00:00 2001 From: Pepijn Krijnsen Date: Sun, 6 Feb 2022 08:29:37 +0000 Subject: [PATCH] Update documentation for gears.color.parse_color(col) method Lua comments now accurately describe the return values of this method. Added a more comprehensive example, too. Issue #3555 --- lib/gears/color.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/gears/color.lua b/lib/gears/color.lua index 873c513a2..2d906ae0f 100644 --- a/lib/gears/color.lua +++ b/lib/gears/color.lua @@ -59,11 +59,17 @@ local pattern_cache -- Max 4 chars per channel. -- -- @param col The color to parse --- @treturn table 4 values representing color in RGBA format (each of them in --- [0, 1] range) or nil if input is incorrect. +-- @treturn number between 0 and 1 for the 'red' value (1st channel) +-- @treturn number between 0 and 1 for the 'green' value (2nd channel) +-- @treturn number between 0 and 1 for the 'blue' value (3rd channel) +-- @treturn number between 0 and 1 for the 'opacity' value (4th channel) +-- if the incoming color code only has 3 values (only rgb, not opacity) the 4th +-- return value is 1. +-- @treturn nil if input is incorrect -- @staticfct gears.color.parse_color --- @usage -- This will return 0, 1, 0, 1 --- gears.color.parse_color("#00ff00ff") +-- @usage -- Both of the following will return 0, 0.4, 0.8, 1 +-- gears.color.parse_color("#0066ccff") +-- gears.color.parse_color("#0066cc") function color.parse_color(col) local rgb = {} if string.match(col, "^#%x+$") then