From acd562be5d3295d9f5e6741e36149ca0849c9b3d Mon Sep 17 00:00:00 2001 From: TechnicalSoup Date: Tue, 8 Feb 2022 16:13:48 +1100 Subject: [PATCH] Add method descriptions to Color Class Reference Add definitions and code examples for the html and html_is_valid methods --- doc/classes/Color.xml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index f3fcd90f511..4e73d4d9d8a 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -218,12 +218,45 @@ + Returns a new color from [code]rgba[/code], an HTML hexadecimal color string. [code]rgba[/code] is not case sensitive, and may be prefixed with a '#' character. + [code]rgba[/code] must be a valid three-digit or six-digit hexadecimal color string, and may contain an alpha channel value. If [code]rgba[/code] does not contain an alpha channel value, an alpha channel value of 1.0 is applied. + If [code]rgba[/code] is invalid a Color(0.0, 0.0, 0.0, 1.0) is returned. + [codeblocks] + [gdscript] + var green = Color.html("#00FF00FF") # set green to Color(0.0, 1.0, 0.0, 1.0) + var blue = Color.html("#0000FF") # set blue to Color(0.0, 0.0, 1.0, 1.0) + [/gdscript] + [csharp] + var green = Color.Html("#00FF00FF"); // set green to Color(0.0, 1.0, 0.0, 1.0) + var blue = Color.Html("#0000FF"); // set blue to Color(0.0, 0.0, 1.0, 1.0) + [/csharp] + [/codeblocks] + Returns [code]true[/code] if [code]color[/code] is a valid HTML hexadecimal color string. [code]color[/code] is not case sensitive, and may be prefixed with a '#' character. + For a string to be valid it must be three-digit or six-digit hexadecimal, and may contain an alpha channel value. + [codeblocks] + [gdscript] + var result = Color.html_is_valid("#55aaFF") # result is true + result = Color.html_is_valid("#55AAFF20") # result is true + result = Color.html_is_valid("55AAFF") # result is true + result = Color.html_is_valid("#F2C") # result is true + result = Color.html_is_valid("#AABBC) # result is false + result = Color.html_is_valid("#55aaFF5") # result is false + [/gdscript] + [csharp] + var result = Color.HtmlIsValid("#55AAFF"); // result is true + result = Color.HtmlIsValid("#55AAFF20"); // result is true + result = Color.HtmlIsValid("55AAFF); // result is true + result = Color.HtmlIsValid("#F2C"); // result is true + result = Color.HtmlIsValid("#AABBC"); // result is false + result = Color.HtmlIsValid("#55aaFF5"); // result is false + [/csharp] + [/codeblocks]