# How to set polygon colorspace (rgb and hsv) online

**URL:** https://discourse.psychopy.org/t/how-to-set-polygon-colorspace-rgb-and-hsv-online/10976
**Category:** Online experiments
**Created:** [February 13, 2020, 12:40pm UTC](https://discourse.psychopy.org/t/how-to-set-polygon-colorspace-rgb-and-hsv-online/10976 "2020-02-13T12:40:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Xiaotong](https://avatars.discourse-cdn.com/v4/letter/x/59ef9b/32.png) [@Xiaotong](https://discourse.psychopy.org/u/Xiaotong)
#### Post date: [February 13, 2020, 12:40pm UTC](https://discourse.psychopy.org/t/how-to-set-polygon-colorspace-rgb-and-hsv-online/10976/1 "2020-02-13T12:40:20Z")

</div>

**URL of experiment** : [xiaotong yin / slider\_online\_test · GitLab](https://gitlab.pavlovia.org/xiaotong/slider_online_test)

**Description of the problem** : Using a slider to change the color of polygons/images works fine offline, but when I tried to run it online, the slider couldn’t change the color anymore. I had a look at the python code and the Javascript and found that the colorspace setting of the polygon was lost in javascript (though not sure whether or not this is the key reason). Does anyone know how to set polygon colorspace online? Thank you very much!  
This is my setting in builder:  
 ![builder](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/0/9/0930da1c543e4402f4faa879bfad55b4515cff6a.png)

---

<div class="post-metadata">

### Author: ![Omidrezaa](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/omidrezaa/32/6105_2.png) [@Omidrezaa](https://discourse.psychopy.org/u/Omidrezaa)
#### Post date: [February 13, 2020, 11:35pm UTC](https://discourse.psychopy.org/t/how-to-set-polygon-colorspace-rgb-and-hsv-online/10976/2 "2020-02-13T23:35:07Z")

</div>

Add this code at the begin routine tab to see if it works:

```auto
polygonColor = new util.Color([1, 0, 1], util.Color.COLOR_SPACE.HSV);
myPolygon.color = polygonColor;

```

Change variable names according to your experiment.

---

<div class="post-metadata">

### Author: ![Xiaotong](https://avatars.discourse-cdn.com/v4/letter/x/59ef9b/32.png) [@Xiaotong](https://discourse.psychopy.org/u/Xiaotong)
#### Post date: [February 14, 2020, 10:21am UTC](https://discourse.psychopy.org/t/how-to-set-polygon-colorspace-rgb-and-hsv-online/10976/3 "2020-02-14T10:21:26Z")

</div>

Hello @Omidrezaa, thank you very much for your reply! I tried the code you suggested but the color of the polygon is pink which is supposed to be white. Then I tried [180, 1, 1] and got this error:

the color components should all belong to [-1, 1]

Then I tried to change hsv values (hue or saturation or value, one at a time, all within [-1, 1]), but the color is always pink. Do you have any thoughts on this?

I’m sorry I have an additional question: is it possible to change the color of an image in each frame online at the present? Many thanks!
