Modify

Opened 7 years ago

Closed 7 years ago

#3687 closed Bug (Fixed)

_ColorConvertRGBtoHSL does not use right bases

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

Description

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 by Melba23, 7 years ago

Owner: set to Melba23
Status: newassigned

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

M23

comment:2 by Melba23, 7 years ago

A fairly simple fix.

We need to replace this single constant:

Global Const $__COLORCONSTANTS_HSLMAX = 240

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.

M23

comment:3 by Melba23, 7 years ago

Milestone: 3.3.15.1
Resolution: Fixed
Status: assignedclosed

Fixed by revision [12186] in version: 3.3.15.1

Modify Ticket

Action
as closed The owner will remain Melba23.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.