Opened 6 years ago

Closed 5 years ago

#3687 closed Bug (Fixed)

_ColorConvertRGBtoHSL does not use right bases

Reported by: Nine Owned by: Melba23
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:


The formulas are good but the base to finalize the results is wrong. H is a degree so base should be 360, S and L are percentages, so base should be 100. But in the current UDF (color.au3) the base used is 240 !

Attachments (0)

Change History (3)

comment:1 Changed 6 years ago by Melba23

  • Owner set to Melba23
  • Status changed from new to assigned

Looking into it, but at first glance it seems you are correct.


comment:2 Changed 6 years ago by Melba23

A fairly simple fix.

We need to replace this single constant:


with these 2:

Global Const $__COLORCONSTANTS_HMAX = 360
Global Const $__COLORCONSTANTS_SLMAX = 100

and adjust the formulae in the 2 conversion functions to match:

; _ColorConvertHSLtoRGB
Local $nR, $nG, $nB
Local $nH = Number($aArray[0]) / $__COLORCONSTANTS_HMAX
Local $nS = Number($aArray[1]) / $__COLORCONSTANTS_SLMAX
Local $nL = Number($aArray[2]) / $__COLORCONSTANTS_SLMAX
; _ColorConvertRGBtoHSL
$aArray[0] = $nH * $__COLORCONSTANTS_HMAX
$aArray[1] = $nS * $__COLORCONSTANTS_SLMAX
$aArray[2] = $nL * $__COLORCONSTANTS_SLMAX

That gives me the correct values according to colour conversion websites.


comment:3 Changed 5 years ago by Melba23

  • Milestone set to
  • Resolution set to Fixed
  • Status changed from assigned to closed

Fixed by revision [12186] in version:

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The owner will remain Melba23.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.