00001 // $Id: StarPalette.C,v 1.1 2000/05/09 20:04:04 kathy Exp $ 00002 // $Log: StarPalette.C,v $ 00003 // Revision 1.1 2000/05/09 20:04:04 kathy 00004 // no longer need to set up color palette 00005 // 00006 // Revision 1.3 2000/01/10 15:21:08 kathy 00007 // updated the *Palette macros for changes in ROOT (see email to software-l from Valery on 7jan00) 00008 // 00009 // Revision 1.2 1999/06/25 19:17:26 kathy 00010 // fix the Palette macros so that you can run StarPalette directly from TestStarPalette - thanks, Thoams & Gene! 00011 // 00012 // Revision 1.1 1999/06/24 20:42:07 kathy 00013 // Jon Gans' macro to setup star color palette 00014 // 00015 // 00016 //====================================================================== 00017 // owner: Jon Gans/Kathy Turner (took over 10jan00) 00018 // what it does: 00019 // Sets up STAR-specific color palette. 00020 // One should execute this at beginning of the root session 00021 // Then all the colors in order will be in order of spectrum & 00022 // darkest to lightest. 00023 // 00024 // 10jan00(KT) --> 00025 // This color palette is now implemented automatically 00026 // by ROOT, so one doesn't need to use this! However, I leave 00027 // it here as an example!! 00028 // 00029 // To show how this macro actually works, run TestStarPalette.C! 00030 // 00031 //======================================================================= 00032 00033 void StarPalette() 00034 { 00035 const float saturation = 1; 00036 const float lightness = 0.5; 00037 const float MaxHue = 280; 00038 const float MinHue = 0; 00039 const int MaxColors = 50; 00040 int palette[MaxColors]; 00041 int index; 00042 float hue, r, g, b, rv, gv, bv; 00043 TColor *color; 00044 unsigned int failures = 0; 00045 00046 for (int i=0 ; i<MaxColors ; i++) { 00047 index = palette[i] = MaxColors+1+i; 00048 color = new TColor(index, 0, 0, 0); 00049 hue = MaxHue-(i+1)*((MaxHue-MinHue)/MaxColors); 00050 color->HLStoRGB(hue, lightness, saturation, r, g, b); 00051 color->SetRGB(r, g, b); 00052 gVirtualX->GetRGB(index, rv, gv, bv); 00053 if (r != rv || g != gv || b != bv) { 00054 failures++; 00055 palette[i] = i ? palette[i-1] : 1; 00056 } 00057 } 00058 if (failures) 00059 printf("StarPalette(): couldn't allocate %d of %d colors\n", failures, MaxColors); 00060 gStyle->SetPalette(MaxColors, palette); 00061 } 00062 00063 00064 00065
1.5.9