psychopy.org | Reference | Downloads | Github

Image not being drawn/stuck behind overlapping polygon

URL of experiment: https://run.pavlovia.org/Hunter/learning/html/

Description of the problem:
if the participant gets the object correct in the routine ‘trial’ then the object appears with green around it in the ‘feedback’ routine. if not, then red.

I tried to do this by creating a polygon in the same size and place and then setting the line width and colour to be conditional in code. So far so good (and works fine in psychopy).

the problem is that online only the polygon is visible in the feedback routine.

i’ve tried a bunch of stuff relating to setAutoDraw based on @wakecarter 's recent discussions but nothing seems to be drawing the images (list of 20 from conditions file) - all of the setAutoDraw stuff i’m seeing seems to be relating to polygons.

Any ideas?
Cheers

Are you defining different polygons or changing them when hidden? If so, what code are you using for the colour and line changes?

the polygon in the feedback is a new polygon only for that routine aimed to be the exact same size and location as my images but that the outlines will poke out because they are much thicker.

In the begin experiment:

correct = false;
white = new util.Color([1, 1, 1]);
black = new util.Color([-1, -1, -1]);
LawnGreen = new util.Color([-0.0274509803921569, 0.976470588235294, -1]);
green = new util.Color([-1, 0, -1]);
red = new util.Color([1, -1, -1]);

and in the every frame

if ((correct === true)) {
    polygon_6.setLineColor(LawnGreen);
    } else {
        if ((correct === false)) {
            polygon_6.setLineColor(red);
            }
        }

so just to clarify (1) i want the image to be displayed on top of the polygon so that the outline of the polygon will show.

note: I tried just giving the images an outline but couldn’t get that going either.

cheers

Are you defining polygon_6 in a Begin Experiment code tab?

Does it work correctly if you move the image so it isn’t in the same location as the polygon?

I tried defining the image in a begin experiment code tab, and got pretty close (it would flicker for what appeared to be one frame).

I haven’t tried to define the polygon in a begin experiment code component because I figured it was already displaying and I wanted it to be at the back?

no the image does not appear when I change the polygon location (odd since the images work fine before I created polygon_6, I assumed it was just in the background)

cheers

I have experienced an image (or perhaps it was a polygon) which displayed correctly and then disappeared as soon as Each Frame code tried to edit it.

Define objects in Begin Experiment
Display them in the desired order using setAutoDraw

If you move something in the background you may need to setAutoDraw the foreground object again.

“Define objects in Begin Experiment”

  • define which object? the image and/or the polygon?

this leaves me the following questions:
(1) is it a problem that the image and polygon have been created using builder, do I need to delete them?
(2) when trying to define an image using code how do you set the time and duration the way the builder usually does?

I think that Builder components are effectively defined in Begin Experiment.

You can still use setAutoDraw false and true to rearrange the order of display. Try just setting AutoDraw to true for the image you’ve redrawn the polygon

ok so i’ve left the builder to define the objects (polygon_6 and obs2) and I tried the following code both in both the every frame and in the begin routine:

if ((correct === true)) {
    polygon_6.setLineColor(LawnGreen);
    } else {
        if ((correct === false)) {
            polygon_6.setLineColor(red);
            }
        }
    

obs2.setAutoDraw(true);
console.log(obs.setAutoDraw());

I agree the strategy you are suggesting makes sense, but the specifics of what I need to do aren’t getting across.

cheers,
Tom

I’m just learning to do this too. My next suggestion would be to set obs2.setAutoDraw(false); immediately followed by obs2.setAutoDraw(true); I.e. turn it off and on again. It might be that the true command gets ignored if the status is already true

clever guess - that fixed it. Also I put my code in the begin routine for anyone else encountering a similar problem.

cheers,
Tom

1 Like

Thanks. I’ll add that to my crib sheet.

I think I’ve suggested the trick before but not had confirmation of success

thanks - I hope you don’t mind i’ve shared your cribsheet around my department. I’ve been working closely with it recently, an excellent resource.

1 Like