# Changing ShapeWidget Colors

**URL:** https://discourse.vtk.org/t/changing-shapewidget-colors/6850
**Category:** Web
**Created:** [October 13, 2021, 1:12am UTC](https://discourse.vtk.org/t/changing-shapewidget-colors/6850 "2021-10-13T01:12:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![seattlewayne](https://discourse.vtk.org/user_avatar/discourse.vtk.org/seattlewayne/32/3958_2.png) [@seattlewayne](https://discourse.vtk.org/u/seattlewayne)
#### Post date: [October 13, 2021, 1:12am UTC](https://discourse.vtk.org/t/changing-shapewidget-colors/6850/1 "2021-10-13T01:12:07Z")

</div>

I continue to play with the [ShapeWidget Example](https://kitware.github.io/vtk-js/examples/ShapeWidget.html) and have come up with an issue that I have not been able to solve.

How do you change the color of the RectangleWidget? I was able to change the color of the EllipseWidget with calls to setColor() on its nested states. That method resulted in changing the color of the resize handles, but not the lines for the RectangleWidget. Is there a better way to do this?

Thanks.

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [October 14, 2021, 2:46pm UTC](https://discourse.vtk.org/t/changing-shapewidget-colors/6850/2 "2021-10-14T14:46:20Z")

</div>

I suspect the circle color may be accessible from the viewWidget instance. @finetjul

---

<div class="post-metadata">

### Author: ![seattlewayne](https://discourse.vtk.org/user_avatar/discourse.vtk.org/seattlewayne/32/3958_2.png) [@seattlewayne](https://discourse.vtk.org/u/seattlewayne)
#### Post date: [October 19, 2021, 5:53am UTC](https://discourse.vtk.org/t/changing-shapewidget-colors/6850/3 "2021-10-19T05:53:47Z")

</div>

Hi @finetjul. Any suggestion for how to change the color of a RectangleWidget or have I stumbled upon a bug? Thanks.

---

<div class="post-metadata">

### Author: ![gaston-perret](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gaston-perret/32/3488_2.png) [@gaston-perret](https://discourse.vtk.org/u/gaston-perret)
#### Post date: [October 20, 2021, 6:18pm UTC](https://discourse.vtk.org/t/changing-shapewidget-colors/6850/4 "2021-10-20T18:18:31Z")

</div>

I think I am having the same issue with the paintWidget  
I try to change the color with  
paintWidget.setColor() but does not seem to work

---

<div class="post-metadata">

### Author: ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)
#### Post date: [October 22, 2021, 10:13am UTC](https://discourse.vtk.org/t/changing-shapewidget-colors/6850/5 "2021-10-22T10:13:43Z")

</div>

Indeed,

Color is currently hard coded:

> <https://github.com/Kitware/vtk-js/blob/master/Sources/Widgets/Representations/RectangleContextRepresentation/index.js#L27>

You might want to do the same as what as been done with the spline widget:

> <https://github.com/Kitware/vtk-js/blob/master/Sources/Widgets/Widgets3D/SplineWidget/index.js#L24>

> <https://github.com/Kitware/vtk-js/blob/master/Sources/Widgets/Representations/SplineContextRepresentation/index.js#L125>
