Sha256: 0e7f4688b19bc0b92cb4555a72c1e507f5faa5d352291cd90a80acfc49249191

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

/**
 * The purpose of this utility is to allow ruby-processing users to use an alternative 
 * to processing.org color their sketches (to cope with ruby FixNumber vs java int)
 * Copyright (C) 2015-16 Martin Prout. This tool is free software; you can 
 * redistribute it and/or modify it under the terms of the GNU Lesser General 
 * Public License as published by the Free Software Foundation; either version
 * 2.1 of the License, or (at your option) any later version.
 * 
 * Obtain a copy of the license at http://www.gnu.org/licenses/lgpl-2.1.html
 */
package monkstone;

/**
 *
 * @author Martin Prout
 */
public class ColorUtil {

   /**
     * Returns hex long as a positive int unless greater than Integer.MAX_VALUE
     * else return the complement as a negative integer or something like that
     */
    static final int hexLong(long hexlong) {
        long SPLIT = Integer.MAX_VALUE + 1;
        if (hexlong < SPLIT) {
            return (int) hexlong;
        } else {
            return (int) (hexlong - SPLIT * 2L);
        }
    }

    /**
     *
     * @param hexstring
     * @return
     */
    static public int colorString(String hexstring) {
        return java.awt.Color.decode(hexstring).getRGB();
    }

    /**
     *
     * @param hex
     * @return
     */
    static public float colorLong(double hex) {
        return (float) hex;
    }
    
    /**
     *
     * @param hexlong
     * @return
     */
    static public int colorLong(long hexlong){
       return hexLong(hexlong);
    }

    /**
     *
     * @param hex
     * @return
     */
    static public float colorDouble(double hex){
       return (float)hex;
    }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
propane-0.5.0-java src/monkstone/ColorUtil.java
propane-0.4.0.pre-java src/monkstone/ColorUtil.java
propane-0.3.0.pre-java src/monkstone/ColorUtil.java