ROOT Version: 6.24/06
Hello together,
working with transparent colors I found an issue with the internal color array. Requesting multiple times the same non transparent color by rgb-float-values it results in the same color index. Doing this with a transparent color I always get a new color index. Please see example code:
#include <iostream>
#include "TColor.h"
int
main (int argc, char **argv)
{
  for (size_t i = 0; i < 10; ++i)
    {
      auto color = TColor::GetColor (0.0f, 0.0f, 0.0f);
      auto color_transparent = TColor::GetColorTransparent (color, 0.0f);
      auto free_color_idx = TColor::GetFreeColorIndex ();
      std::cout << "color=" << color << " color_transparent=" << color_transparent
                << " free_color_idx=" << free_color_idx << std::endl;
    }
  return 0;
}
I assume this behaviour results in use of == operator of the float-values in GetColorTransparent instead of a compare by a threshold (gColorThreshold).
Can you confirm this?
Bests,
             
            
              
            
           
          
            
              
                couet  
              
                  
                    September 2, 2022,  6:41am
                   
                  2 
               
             
            
              Welcome to the ROOT forum
Thanks for your report. I’ll check.
             
            
              
            
           
          
            
              
                couet  
              
                  
                    September 2, 2022,  6:44am
                   
                  3 
               
             
            
              It does not seem to behave as you said (with root master):
void mott()
{
  for (size_t i = 0; i < 10; ++i)
    {
      auto color = TColor::GetColor (0.0f, 0.0f, 0.0f);
      auto color_transparent = TColor::GetColorTransparent (color, 0.0f);
      auto free_color_idx    = TColor::GetFreeColorIndex ();
      std::cout << "color = " << color << " color_transparent = " << color_transparent
                << " free_color_idx = " << free_color_idx << std::endl;
    }
}
gives:
root [0] .x mott.C
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
root [1] 
Your ROOT version is old. I remember having fixed something like that.
             
            
              
            
           
          
            
            
              Hi, thank you.
I will check it - sorry that I haven’t checked it against the master version.
Bests,
             
            
              
            
           
          
            
            
              Just downloaded current version of ROOT and done the test again. Sadly I got another result.
   ------------------------------------------------------------------
  | Welcome to ROOT 6.26/06                        https://root.cern |
  | (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Sep 02 2022, 09:27:00                 |
  | From tag , 28 July 2022                                          |
  | With c++ (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1)                  |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
   ------------------------------------------------------------------
root [0] .x mott.C
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1180 free_color_idx = 1181
color = 1 color_transparent = 1181 free_color_idx = 1182
color = 1 color_transparent = 1182 free_color_idx = 1183
color = 1 color_transparent = 1183 free_color_idx = 1184
color = 1 color_transparent = 1184 free_color_idx = 1185
color = 1 color_transparent = 1185 free_color_idx = 1186
color = 1 color_transparent = 1186 free_color_idx = 1187
color = 1 color_transparent = 1187 free_color_idx = 1188
color = 1 color_transparent = 1188 free_color_idx = 1189
Do you have any idea?
Bests,
             
            
              
            
           
          
            
              
                couet  
              
                  
                    September 2, 2022, 12:38pm
                   
                  6 
               
             
            
              
 MichaelMott:
 
Do you have any idea?
 
 
I am using master. Ie: 6.27/01
             
            
              
            
           
          
            
            
              I’ve tried it with the same version like you, but I still get a different output.
   ------------------------------------------------------------------
  | Welcome to ROOT 6.27/01                        https://root.cern |
  | (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Jan 07 2022, 07:52:00                 |
  | From remotes/origin/master@v6-25-02-9-g6cb82dd30e                |
  | With c++ (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1)                  |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
   ------------------------------------------------------------------
root [0] .x mott.C
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1180 free_color_idx = 1181
color = 1 color_transparent = 1181 free_color_idx = 1182
color = 1 color_transparent = 1182 free_color_idx = 1183
color = 1 color_transparent = 1183 free_color_idx = 1184
color = 1 color_transparent = 1184 free_color_idx = 1185
color = 1 color_transparent = 1185 free_color_idx = 1186
color = 1 color_transparent = 1186 free_color_idx = 1187
color = 1 color_transparent = 1187 free_color_idx = 1188
color = 1 color_transparent = 1188 free_color_idx = 1189
root [1]
I don’t have a clue - do you have?
             
            
              
            
           
          
            
              
                couet  
              
                  
                    September 5, 2022, 11:23am
                   
                  8 
               
             
            
              That’s really weird. I tried again:
% root mott.C
   ------------------------------------------------------------------
  | Welcome to ROOT 6.27/01                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Sep 05 2022, 08:03:42                      |
  | From heads/master@v6-25-02-2126-g9b9027a245                      |
  | With Apple clang version 13.1.6 (clang-1316.0.21.2.5)            |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------
root [0] 
Processing mott.C...
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
root [1] 
I am on Mac, bu that should not take any difference. That’s only array management. It should not be machine dependent. Do you have a rootlogon.C ? can you start root wit root -n ?
             
            
              
            
           
          
            
            
              @couet  I tried your “mott”  on several Linux / x86_64 (gcc 11.2.0, 7.5.0, 4.8.5) systems with ROOT 6.26/06, 6.24/06, 6.22/08, 6.20/08, and 6.18/04, and I also always got different “free_color_idx” (I have no “rootlogon.C”).
             
            
              
            
           
          
            
            
              @couet  I found a rootlogon.C in tutorials directory.
If I start mott.C with root -n there is no difference. I got a new free_color_idx every color request.
             
            
              
            
           
          
            
              
                couet  
              
                  
                    September 5, 2022, 11:54am
                   
                  11 
               
             
            
              Ok, i will need to investigate on a Linux machine. Thanks for your feedback.
             
            
              
            
           
          
            
              
                couet  
              
                  
                    September 5, 2022,  2:00pm
                   
                  12 
               
             
            
              well…
$ uname -a
Linux root-ubuntu-2004-1 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
sftnight@root-ubuntu-2004-1:~/couet/build$ root mott.C
   ------------------------------------------------------------------
  | Welcome to ROOT 6.27/01                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Sep 05 2022, 12:32:28                 |
  | From heads/master@v6-25-02-2128-gb0aea2e155                      |
  | With c++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0                   |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------
root [0] 
Processing mott.C...
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
root [1] 
 
            
              
            
           
          
            
            
              Try ROOT 6.26/06 and 6.24/06 so that we have a comparison.
             
            
              
            
           
          
            
            
              Was this a true machine or a virtualized. May it depens on that?
Even on another server I got the same (counting color index) result.
             
            
              
            
           
          
            
              
                couet  
              
                  
                    September 7, 2022,  6:50am
                   
                  16 
               
             
            
              Ok I see the following on my IMac:
 
% root mott.C
   ------------------------------------------------------------------
  | Welcome to ROOT 6.27/01                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Sep 07 2022, 06:31:43                      |
  | From heads/master@v6-25-02-2141-g5c9164ec54                      |
  | With Apple clang version 13.1.6 (clang-1316.0.21.2.5)            |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------
root [0] 
Processing mott.C...
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
root [1] 
 
% root mott.C
   ------------------------------------------------------------------
  | Welcome to ROOT 6.26/07                        https://root.cern |
  | (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Sep 06 2022, 14:21:10                      |
  | From heads/v6-26-00-patches@v6-26-06-33-g2cef31413d              |
  | With Apple clang version 13.1.6 (clang-1316.0.21.2.5)            |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
   ------------------------------------------------------------------
root [0] 
Processing mott.C...
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1180 free_color_idx = 1181
color = 1 color_transparent = 1181 free_color_idx = 1182
color = 1 color_transparent = 1182 free_color_idx = 1183
color = 1 color_transparent = 1183 free_color_idx = 1184
color = 1 color_transparent = 1184 free_color_idx = 1185
color = 1 color_transparent = 1185 free_color_idx = 1186
color = 1 color_transparent = 1186 free_color_idx = 1187
color = 1 color_transparent = 1187 free_color_idx = 1188
color = 1 color_transparent = 1188 free_color_idx = 1189
root [1] 
So seems to have been fixed between these two versions.
             
            
              
            
           
          
            
            
              Is it possible to get the 6.27/01 as source code?
             
            
              
            
           
          
            
            
              For today, “6.27/01” is just the head of the “master ” branch (and “6.26/07” is the head of the “v6-26-00-patches ” branch).
             
            
              
            
           
          
            
              
                couet  
              
                  
                    September 7, 2022,  7:27am
                   
                  19 
               
             
            
              git clone https://github.com/root-project/root.git root
mkdir build
cd build
cmake ../root
make -j8
source bin/thisroot.sh
root --version
 
            
              
            
           
          
            
            
              Wham - after compiling 6.27/01 by my own it works. I don’t know why it not worked with the precompiled version.
   ------------------------------------------------------------------
  | Welcome to ROOT 6.27/01                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Sep 07 2022, 07:41:45                 |
  | From heads/master@v6-25-02-2141-g5c9164ec54                      |
  | With c++ (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1)                  |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------
root [0] .x mott.C
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
color = 1 color_transparent = 1179 free_color_idx = 1180
root [1]
 
            
              1 Like 
            
            
           
          
            
              
                couet  
              
                  
                    September 7, 2022,  9:39am
                   
                  21 
               
             
            
              
As @Wile_E_Coyote  said the master head might is a bt ahead even if the version number is the same.