private computeCycle()

in src/WordCloud.ts [992:1034]


    private computeCycle(
        words: WordCloudDataPoint[],
        context: CanvasRenderingContext2D,
        surface: number[],
        borders: IPoint[],
        onPositionsComputed: (WordCloudDataView) => void,
        wordsForDraw: WordCloudDataPoint[] = [],
        index: number = 0): void {

        let ratio: number = this.getRatio(words.length);
        while (index < words.length && this.root !== undefined) {
            let word: WordCloudDataPoint = words[index];

            word.x = (this.specialViewport.width / ratio
                * (WordCloud.GET_FROM_CYCLED_SEQUENCE(WordCloud.PreparedRandoms, index) + WordCloud.AdditionalRandomValue)) >> WordCloud.PositionOffset;

            word.y = (this.specialViewport.height / ratio
                * (WordCloud.GET_FROM_CYCLED_SEQUENCE(WordCloud.PreparedRandoms, index + 1) + WordCloud.AdditionalRandomValue)) >> WordCloud.PositionOffset;

            if (!word.sprite) {
                this.generateSprites(context, words, index);
            }

            if (word.sprite && this.findPosition(surface, word, borders, index)) {
                wordsForDraw.push(word);

                borders = this.updateBorders(word, borders);
                word.x -= this.specialViewport.width >> WordCloud.PositionOffset;
                word.y -= this.specialViewport.height >> WordCloud.PositionOffset;

                if (wordsForDraw.length >= this.settings.general.maxNumberOfWords) {
                    index = words.length - 1;
                }
            }
            index++;
        }

        onPositionsComputed({
            data: wordsForDraw,
            leftBorder: borders && borders[0],
            rightBorder: borders && borders[1]
        });
    }