Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When called for an image component, setColor does not update image color. #29

Open
dvbridges opened this issue Feb 9, 2019 · 5 comments
Assignees

Comments

@dvbridges
Copy link
Contributor

dvbridges commented Feb 9, 2019

In PsychoPy, you can change the color of your image component on every repeat or every frame using the Color parameter in the Builder image component. However, the code that is used for the JavaScript is not working - where "image" is the name of the image component:

image.setColor(new util.Color('red'))

Example of current PsychoJS behaviour
https://pavlovia.org/run/dvbridges/imagefade/html/

@peircej
Copy link
Member

peircej commented Feb 11, 2019

The implementation in psychopy is essentially to multiply the image pixel color by the RGB of the designated color. We now do this with a shader but it used to be using textures combined with glColor

@wakecarter
Copy link

Have you checked that this isn't related to writing 'red' instead of new util.Color([1, -1, -1]); ?

@dvbridges
Copy link
Contributor Author

Yes it fails both ways. For named colors, you can use any of those listed as a named color in PsychoJS

Color.NAMED_COLORS = {

@peircej peircej added this to to do in Release 2020.2 Jul 23, 2020
@peircej peircej assigned tpronk and unassigned tpronk Jul 23, 2020
@e-leib
Copy link

e-leib commented Aug 17, 2020

Hello, I am wondering whether this has been resolved. I'm having the same issue but for a text component. I built my experiment in Builder, and it works fine in psychopy but does not work when I run it on Pavlovia in psychojs. The behavior I am aiming to achieve is that on each trial when a participant presses the 'f' key, a text component on the screen will turn blue, indicating that it was the selected option, and then green if it is the correct answer or red if incorrect. And the same if the 'j' key is pressed for a different text component.

I know my logic that I added through a code component is correct because it works when I run it in builder. When I run it on Pavlovia though, it changes the colors correctly for the first trial only, and then after it is stuck on the behavior from the first trial. I know my logic in js is working too because the behavior of the "correct"/"incorrect" text feedback is correct, and it uses the same logic. Plus, I printed the color and where I was in the if/else conditionals to the consol and could see that the logic was properly handling the key input and changing the colors accordingly.

It seems that the call to text.setColor(new util.Color(color)) is not updating the color of the text, given that text is the text component and color is the color I want to change it to.

I am using Psychopy 2020.2.2 on Windows 10.

@laszlotalas
Copy link

Hi, I'm wondering if this has been resolved or anyone found a way around it. I'm trying to recolour an empty white image by setting a new colour. Works brilliantly locally, fails online. Unfortunately using a Polygon is not an option as I need a mask on the image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Release 2020.2
  
to do
Development

No branches or pull requests

7 participants