Sha256: 59beef61f0b44a6de112d88ed8e758fc4c4e072cf82711c1f0103c250d09ca7a

Contents?: true

Size: 1.44 KB

Versions: 9

Compression:

Stored size: 1.44 KB

Contents

package wordcram;

import java.util.Random;

import processing.core.PApplet;

public class Colorers {

    public static WordColorer twoHuesRandomSats(final PApplet host) {

        final float[] hues = new float[] { host.random(256), host.random(256) };

        return new HsbWordColorer(host) {
            @Override
            public int getColorFor(Word w) {

                float hue = hues[(int)host.random(hues.length)];
                float sat = host.random(256);
                float val = host.random(100, 256);

                return host.color(hue, sat, val);
            }
        };
    }

    public static WordColorer twoHuesRandomSatsOnWhite(final PApplet host) {

        final float[] hues = new float[] { host.random(256), host.random(256) };

        return new HsbWordColorer(host) {
            @Override
            public int getColorFor(Word w) {

                float hue = hues[(int)host.random(hues.length)];
                float sat = host.random(256);
                float val = host.random(156);

                return host.color(hue, sat, val);
            }
        };
    }

    public static WordColorer pickFrom(final int... colors) {
        final Random r = new Random();
        return (Word w) -> colors[r.nextInt(colors.length)];
    }

    // TODO add an overload that takes 1 int (greyscale), 2 ints (greyscale/alpha), etc
    public static WordColorer alwaysUse(final int color) {
        return (Word w) -> color;
    }
}

Version data entries

9 entries across 9 versions & 1 rubygems

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