CodingTrain / CodingTrain/Suggestion-Box
while and loops with an array
- Dominant language
- No language data
- Stars
- 570
- Forks
- 85
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I am looking for having an array of objects to be manipulated upon the canvas. But this array contains 10000000 elements and is always incrementing. Then my goal is not to create this big array, but to create it step by step each time I am able to fill a canvas with it's elements. Then I will manipulate each visible element into the canvas.
I try the following code in order to put my array elements into the canvas. But I am not able to stop the function before the variable i is out of Tableautemp's range. When all the canvas is full, I want to create another canvas.
How can I do that ? I want to track the last item able to be put in the canvas.
```
function PositionObjets (Tableautemp) {
this.Tableautemp = Tableautemp;
fill(0);
stroke(250);
let x =xinit;
let y =yinit;
let spacing = 0;
let i = 0;
while (y+margeh<=htot) {
console.log(i);
while (x+this.Tableautemp[i].w+margew<=wtot) {
this.Tableautemp[i].x = x;
this.Tableautemp[i].y = y;
this.Tableautemp[i].Dessine(); // it draws a rectangle but it is just for test purpose that I is put at this place
x=x+this.Tableautemp[i].w+spacing;
if (i
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.