Generating multiple polygons

Description of the problem:
I try to make an online experiment where I want to use multiple polygons displayed for a very short time (0.5-1 s). I made a whole experiment in python but unfortunately it Pavlovia can’t use this code while I wrote some new functions. I suppose the main problem is with visual.ElementArrayStim. Before it, I generate positions and sizes of each polygon and code is fine but when I try to generate an object for each polygon:

for (var i = 0; i < dot_size_base.length; i++){
    polygon = new visual.Polygon ({
        win: psychoJS.window, name: 'polygon', units : 'pix', 
        edges: 2000, size:[dot_size_base[i][0], dot_size_base[i][0]],
        ori: 0.0, pos: [dots1[i][0], dots1[i][1]],
        lineWidth: 1.0, lineColor: new util.Color('yellow'),
        fillColor: new util.Color('yellow'),
        opacity: undefined, depth: 0, interpolate: true,
    });
    kropkiComponents.push(polygon);
}
for (var i = 0; i < dot_size2_base.length; i++){
    polygon = new visual.Polygon ({
        win: psychoJS.window, name: 'polygon', units : 'pix', 
        edges: 2000, size:[dot_size2_base[i][0], dot_size2_base[i][0]],
        ori: 0.0, pos: [dots2[i][0], dots2[i][1]],
        lineWidth: 1.0, lineColor: new util.Color('blue'),
        fillColor: new util.Color('blue'),
        opacity: undefined, depth: 0, interpolate: true,
    });
    kropkiComponents.push(polygon);
}


for (const thisComponent of kropkiComponents)
  if ('status' in thisComponent)
    thisComponent.status = PsychoJS.Status.NOT_STARTED;
return Scheduler.Event.NEXT;

}
}

and, furthermore I have:

function kropkiRoutineEachFrame(snapshot) {
return function () {
//------Loop for each frame of Routine ‘kropki’-------
// get current time
t = kropkiClock.getTime();
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
// update/draw components on each frame

for (var i = 0; i < kropkiComponents.length; i++){
    // *polygon* updates
    if (t >= 0.0 && kropkiComponents[i].status === PsychoJS.Status.NOT_STARTED) {
      // keep track of start time/frame for later
      kropkiComponents[i].tStart = t;  // (not accounting for frame time here)
      kropkiComponents[i].frameNStart = frameN;  // exact frame index
      
      kropkiComponents[i].setAutoDraw(true);
    }

    frameRemains = 0.0 + 1.0 - psychoJS.window.monitorFramePeriod * 0.75;  // most of one frame period left
    if (kropkiComponents[i].status === PsychoJS.Status.STARTED && t >= frameRemains) {
      kropkiComponents[i].setAutoDraw(false);
    }

}



// check for quit (typically the Esc key)
if (psychoJS.experiment.experimentEnded || psychoJS.eventManager.getKeys({keyList:['escape']}).length > 0) {
  return quitPsychoJS('The [Escape] key was pressed. Goodbye!', false);
}

// check if the Routine should terminate
if (!continueRoutine) {  // a component has requested a forced-end of Routine
  return Scheduler.Event.NEXT;
}

continueRoutine = false;  // reverts to True if at least one component still running
for (const thisComponent of kropkiComponents)
  if ('status' in thisComponent && thisComponent.status !== PsychoJS.Status.FINISHED) {
    continueRoutine = true;
    break;
  }

// refresh the screen if continuing
if (continueRoutine && routineTimer.getTime() > 0) {
  return Scheduler.Event.FLIP_REPEAT;
} else {
  return Scheduler.Event.NEXT;
}

};
}

As far as I understand this code the problem is pushing polygon objects into kropkiComponents and furthermore into kropkiRoutineEachFrame function. Does anyone know how I can do it without being worried about pavlovia js platform recognition?