| Reference | Downloads | Github

Polygon (rectangle) Code Component

URL of experiment:

Description of the problem: Hello everyone, I’m going to try to make this post as detailed as possible so that it can (hopefully) be answered easily. When I run my .psyexp file from PsychoPy it runs exactly as coded but when I upload it to Pavlovia there are some things getting lost in translation. One of these things is a conditional polygon that is supposed to appear when a picture is presented. The rectangle that borders an image is supposed to appear either solid/striped, blue/yellow, depending upon certain conditions as succinctly explained in PsychoPy below:

‘trialsPractice’ Properties Begin Experiment tab

‘trialsPractice’ Properties Begine Routine tab

The problem is that these definitions which are clearly evident in my .py file (lines 238-252) are missing from my html file:

This is resulting in a ReferenceError: solidColor is not defined, that Developer view in my browser points to line 1111, in my 12_APRT_20180907.js file. I am using PsychoPy v2020.1.3. Can anyone please explain how to fix this and what may fix this? Any help would be GREATLY appreciated!!

How have you specified the colour for JS? I had issues with colours and this post really helped me:

Where is the JavaScript equivalent to your custom Python code? You show the code components with “Auto -> JS” selected, yet the JavaScript panes are empty.

My apologies…I’m still new to this.


You should specify the colours as variables in a Begin Experiment code block as per the earlier link to my post. The method is also in my crib sheet.

Best wishes


I appreciate your response and the crib sheet, which surely looks like it will help out! I do still have a question as some of the colors I’m using are not on the crib sheet. I understand that the values for the colors are in RGB space from -1 to 1, however all the documentation I keep finding are on a scale of 0 to 255. Do you have a resource that explains colors (-1 to 1) in the way that we are using them?

UPDATE I wanted to edit my question to explain how I found the answer to my own question in case anyone else might need to know the answer for their own purposes. In Builder view in PsychoPy, you can click on text object, under the component sidebar (in a new experiment, because you’re not going to save this) and in the field labelled ‘Color’ right-click and that will bring up a window where you can select the color you want. Once you press okay it will show you the RGB triplet ([0,0,0]) in -1 to 1 format that you need! Good Luck everyone!

Equally you can divide a 0-255 value by 127.5 and then subtract 1.

1 Like