mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
Fixed lag for multiple apertures RDK
This commit is contained in:
parent
7b444afd59
commit
bab507b9f6
@ -27,7 +27,7 @@
|
||||
var test_block = {
|
||||
type: "RDK",
|
||||
timing_post_trial: 0, //The Inter Trial Interval. You can either have no ITI, or have an ITI but change the display element to be the same color as the stimuli background to prevent flashing between trials
|
||||
number_of_dots: 200, //Total number of dots in the aperture
|
||||
number_of_dots: 200, //Total number of dots in each aperture
|
||||
RDK_type: 3, //The type of RDK used
|
||||
choices: ["a", "l"], //Choices available to be keyed in by participant
|
||||
trial_duration: 1000, //Duration of each trial in ms
|
||||
|
@ -844,7 +844,7 @@ jsPsych.plugins["RDK"] = (function() {
|
||||
function updateAndDraw(){
|
||||
|
||||
//Clear the canvas to draw new dots
|
||||
ctx.clearRect(0, 0, canvasWidth, canvasHeight)
|
||||
//ctx.clearRect(0, 0, canvasWidth, canvasHeight)
|
||||
|
||||
// Go through the array, update the dots, and draw them on the canvas
|
||||
for(currentApertureNumber = 0; currentApertureNumber < nApertures; currentApertureNumber++){
|
||||
@ -852,6 +852,9 @@ jsPsych.plugins["RDK"] = (function() {
|
||||
//Initialize the variables for each parameter
|
||||
initializeCurrentApertureParameters(currentApertureNumber);
|
||||
|
||||
//Clear the canvas by drawing over the current dots
|
||||
clearDots();
|
||||
|
||||
//Update the dots
|
||||
updateDots();
|
||||
|
||||
@ -859,6 +862,22 @@ jsPsych.plugins["RDK"] = (function() {
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
//Function that clears the dots on the canvas by drawing over it with the color of the baclground
|
||||
function clearDots(){
|
||||
|
||||
//Load in the current set of dot array for easy handling
|
||||
dotArray = dotArray2d[currentSetArray[currentApertureNumber]]; //Global variable, so the updateDots and draw functions also uses this array
|
||||
|
||||
//Loop through the dots one by one and draw them
|
||||
for (var i = 0; i < nDots; i++) {
|
||||
dot = dotArray[i];
|
||||
ctx.beginPath();
|
||||
ctx.arc(dot.x, dot.y, dotRadius+1, 0, Math.PI * 2);
|
||||
ctx.fillStyle = backgroundColor;
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
//Draw the dots on the canvas after they're updated
|
||||
function draw() {
|
||||
@ -925,7 +944,7 @@ jsPsych.plugins["RDK"] = (function() {
|
||||
}
|
||||
|
||||
//Load in the current set of dot array for easy handling
|
||||
dotArray = dotArray2d[currentSetArray[currentApertureNumber]]; //Global variable, so the draw function also uses this array
|
||||
//dotArray = dotArray2d[currentSetArray[currentApertureNumber]]; //Global variable, so the draw function also uses this array
|
||||
|
||||
//Loop through the dots one by one and update them accordingly
|
||||
for (var i = 0; i < nDots; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user