Sha256: 22cafaaf0d4ecec92a956b8e61ca5abdbbe46659b043e1b4b52d40044c78e8d3

Contents?: true

Size: 714 Bytes

Versions: 9

Compression:

Stored size: 714 Bytes

Contents

package wordcram;

import processing.core.*;

public class SwirlWordPlacer implements WordPlacer {

    @Override
    public PVector place(Word word, int wordIndex, int wordsCount,
            int wordImageWidth, int wordImageHeight, int fieldWidth,
            int fieldHeight) {

        float normalizedIndex = (float) wordIndex / wordsCount;

        float theta = normalizedIndex * 6 * PConstants.TWO_PI;
        float radius = normalizedIndex * fieldWidth / 2f;

        float centerX = fieldWidth * 0.5f;
        float centerY = fieldHeight * 0.5f;

        float x = PApplet.cos(theta) * radius;
        float y = PApplet.sin(theta) * radius;

        return new PVector(centerX + x, centerY + y);
    }
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby_wordcram-2.1.1 src/wordcram/SwirlWordPlacer.java
ruby_wordcram-2.1.0 src/wordcram/SwirlWordPlacer.java
ruby_wordcram-2.0.6 src/wordcram/SwirlWordPlacer.java
ruby_wordcram-2.0.5 src/wordcram/SwirlWordPlacer.java
ruby_wordcram-2.0.4 src/wordcram/SwirlWordPlacer.java
ruby_wordcram-2.0.3 src/wordcram/SwirlWordPlacer.java
ruby_wordcram-2.0.2 src/wordcram/SwirlWordPlacer.java
ruby_wordcram-2.0.1 src/wordcram/SwirlWordPlacer.java
ruby_wordcram-2.0.0 src/wordcram/SwirlWordPlacer.java