URL of experiment: here is the gitlab project
Description of the problem:
Hi everyone,
I am quite new to javascript, and I’m trying to run an experiment where the user can draw bars on a blank graph using their mouse. I found another question on here that referred to drawing with the mouse, and I tried to make my code similar, but I am not sure why it is not working.
I have been having trouble getting the actual shapes to show up. I know that the mouse is working because I have been debugging and can clearly see that the mouse position is accurate.
I think it may have something to do with this block of code:
if (t >= 6.0 && blank_graph.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
blank_graph.tStart = t; // (not accounting for frame time here)
blank_graph.frameNStart = frameN; // exact frame index
blank_graph.setAutoDraw(true);
let buttons = mouse.getPressed();
let left_button = buttons[0];
if (left_button) {
mouse_position = mouse.getPos();
x_index = int((pos[0]+0.275)/0.01358)
bar_objs[x_index].setAutoDraw(false);
bar_objs[x_index].setHeight(pos[1]);
bar_objs[x_index].setAutoDraw(true);
bars[x_index] = pos[1];
}
}
where bar_objs is an array of rect objects.
Please let me know if there is anything obvious. I really appreciate the help.