# TColor -\> Color\_t

**URL:** <https://root-forum.cern.ch/t/tcolor-color-t/3862>\
**Category:** ROOT\
**Created:** [September 19, 2006, 10:47am UTC](https://root-forum.cern.ch/t/tcolor-color-t/3862 "2006-09-19T10:47:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wiso](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wiso/32/11120_2.png) [@wiso](https://root-forum.cern.ch/u/wiso)\
**Post date:** [September 19, 2006, 10:47am UTC](https://root-forum.cern.ch/t/tcolor-color-t/3862/1 "2006-09-19T10:47:17Z")

</div>

I have a TColor initialized with its RGB components. I want to draw a TBox with this color, but TBox::SetFillColor need a Color\_t

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 19, 2006, 12:09pm UTC](https://root-forum.cern.ch/t/tcolor-color-t/3862/2 "2006-09-19T12:09:58Z")

</div>

You can use:

col-\>GetNumber()

it returns the color index of the TColor “col”.

---

<div class="post-metadata">

**Author:** ![wiso](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wiso/32/11120_2.png) [@wiso](https://root-forum.cern.ch/u/wiso)\
**Post date:** [September 19, 2006, 2:44pm UTC](https://root-forum.cern.ch/t/tcolor-color-t/3862/3 "2006-09-19T14:44:52Z")

</div>

[quote=“couet”]You can use:

col-\>GetNumber()

it returns the color index of the TColor “col”.[/quote]

```auto
TColor Color;
Color.SetRGB(1.,0,0) //it's red
b = new TBox(0.2,0.2,0.8,0.3)
b->SetFillColor(Color.GetNumber()) //Color.GetNumber() is -1 !!!
b->Draw()
```

and the box is gray

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 20, 2006, 9:39am UTC](https://root-forum.cern.ch/t/tcolor-color-t/3862/4 "2006-09-20T09:39:21Z")

</div>

try:

```auto
root [2] TColor *c=gROOT->GetColor(20);
root [3] c->SetRGB(1.,0,0);
root [4] b = new TBox(0.2,0.2,0.8,0.3);
root [5] b->SetFillColor(20)
root [6] b->Draw()
```
