Package toxi.color

Examples of toxi.color.ReadonlyTColor


     * toxi.color.ColorTheoryStrategy#createListFromcolor(toxi.color.TColor)
     */
    public static final String NAME = "leftSplitComplementary";

    public ColorList createListFromColor(ReadonlyTColor src) {
        ReadonlyTColor left = src.getComplement().rotateRYB(-30).lighten(0.1f);
        ColorList colors = ColorTheoryRegistry.COMPLEMENTARY
                .createListFromColor(src);
        for (int i = 3; i < 6; i++) {
            TColor c = colors.get(i);
            c.setHue(left.hue());
        }
        return colors;
    }
View Full Code Here


     * toxi.color.ColorTheoryStrategy#createListFromcolor(toxi.color.TColor)
     */
    public static final String NAME = "rightSplitComplementary";

    public ColorList createListFromColor(ReadonlyTColor src) {
        ReadonlyTColor left = src.getComplement().rotateRYB(30).lighten(0.1f);
        ColorList colors = ColorTheoryRegistry.COMPLEMENTARY
                .createListFromColor(src);
        for (int i = 3; i < 6; i++) {
            TColor c = colors.get(i);
            c.setHue(left.hue());
        }
        return colors;
    }
View Full Code Here

import toxi.math.MathUtils;

public class ColorTest extends TestCase {

    public void testCMYK() {
        ReadonlyTColor c = TColor.newHex("00ffff");
        assertEquals(1f, c.cyan());
        assertEquals(0f, c.magenta());
        assertEquals(0f, c.yellow());
        assertEquals(0f, c.black());
        assertEquals(0f, TColor.WHITE.black());
        assertEquals(1f, TColor.BLACK.black());
        assertEquals(1f, TColor.YELLOW.yellow());
        assertEquals(0f, TColor.YELLOW.cyan());
        assertEquals(1f, TColor.MAGENTA.magenta());
        // rgb conversion
        assertEquals(0f, TColor.GREEN.magenta());
        assertEquals(1f, TColor.GREEN.cyan());
        assertEquals(1f, TColor.GREEN.yellow());
        assertEquals(1f, TColor.RED.magenta());
        assertEquals(1f, TColor.RED.yellow());
        assertEquals(0f, TColor.RED.cyan());
        c = TColor.RED.getDarkened(0.25f);
        assertEquals(0.75f, c.magenta());
        assertEquals(0.25f, c.black());
    }
View Full Code Here

    @Override
    public void compileFace(AttributedFace f, ItemIndex<?> index, float[] buf,
            int offset) {
        int[] vn = f.attribs.get(IndexedTriangleMesh.ATTR_VCOLORS);
        ReadonlyTColor c = (ReadonlyTColor) index.forID(vn[0]);
        c.toRGBAArray(buf, offset);
        c = (ReadonlyTColor) index.forID(vn[1]);
        c.toRGBAArray(buf, offset + 4);
        c = (ReadonlyTColor) index.forID(vn[2]);
        c.toRGBAArray(buf, offset + 8);
    }
View Full Code Here

        assertEquals(0.75f, c.magenta());
        assertEquals(0.25f, c.black());
    }

    public void testColor() {
        ReadonlyTColor c = TColor.newHex("00ffff");
        assertEquals(0.5, c.hue(), 0.001);
        assertEquals(1.0, c.brightness(), 0.001);
        TColor d = TColor.newCMYK(1.0f, 0, 0, 0);
        float delta = c.distanceToHSV(d);
        assertEquals(0.0f, delta);
    }
View Full Code Here

            list.add(TColor.newHSV(MathUtils.random(1f), MathUtils.random(1f),
                    MathUtils.random(1f)));
        }
        AccessCriteria criteria = AccessCriteria.RED;
        ColorList sorted = list.sortByCriteria(criteria, false);
        ReadonlyTColor prev = null;
        for (ReadonlyTColor c : sorted) {
            System.out.println(c);
            if (prev != null) {
                assertTrue(prev.getComponentValue(criteria) <= c
                        .getComponentValue(criteria));
            }
            prev = c;
        }
        System.out.println("cluster sort...");
View Full Code Here

    }

    public void testHues() {
        assertTrue(Hue.GREEN.isPrimary());
        assertFalse(Hue.LIME.isPrimary());
        ReadonlyTColor hue = TColor.newHSV(Hue.CYAN, 0.5f, 0.2f);
        assertFalse(hue.isPrimary());
        String hueName = "pink";
        Hue h = Hue.getForName(hueName);
        assertEquals(hueName, h.getName());
        h = Hue.getClosest(100 / 360.0f, false);
        assertEquals("lime", h.getName());
View Full Code Here

        h = Hue.getClosest(100 / 360.0f, true);
        assertEquals("green", h.getName());
    }

    public void testNamedColors() {
        ReadonlyTColor c = NamedColor.getForName("cyan");
        assertEquals(NamedColor.CYAN, c);
    }
View Full Code Here

TOP

Related Classes of toxi.color.ReadonlyTColor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.