HYPE_Processing icon indicating copy to clipboard operation
HYPE_Processing copied to clipboard

Using HYPE libraries with java applications?

Open sheldon-white opened this issue 7 years ago • 1 comments

I'm currently writing Processing applications with java (rather than pde files within the processing app).
It doesn't seem like the HYPE libraries work as is-in this environment. Is this a use case that's supported in any way?

Here's an example, adapted from a working pde file:

import hype.*;
import hype.extended.behavior.HRotate;
import processing.core.PApplet;

public class HypeTest1 extends PApplet {

    public static void main(String args[]) {
        PApplet.main("HypeTest1");
    }


    @Override
    public void settings() {
        size(640,640);
    }

    public void setup() {
        H.init(this).background(0x202020);
        smooth();

        HDrawable r = new HRect(20).rounding(2).noStroke().anchorAt(H.CENTER);

        HDrawable d1 = H.add(new HRect(50).rounding(4)).noStroke().fill(0x00616f).anchorAt(H.CENTER).loc(width/5,height/2);
        d1.add(r.createCopy()).fill(0xFF3300).locAt(H.TOP_LEFT);
        d1.add(r.createCopy()).fill(0xFF3300).locAt(H.BOTTOM_RIGHT);

        HDrawable d2 = H.add(new HRect(50).rounding(4)).noStroke().fill(0x0095a8).anchorAt(H.CENTER).loc(width*2/5,height/2);
        d2.add(r.createCopy()).fill(0xFF6600).locAt(H.TOP_LEFT);
        d2.add(r.createCopy()).fill(0xFF6600).locAt(H.BOTTOM_RIGHT);

        HDrawable grp1 = H.add(new HGroup()).size(50).anchorAt(H.CENTER).loc(width*3/5,height/2);
        grp1.add(r.createCopy()).fill(0xFF9900).locAt(H.TOP_LEFT);
        grp1.add(r.createCopy()).fill(0xFF9900).locAt(H.BOTTOM_RIGHT);

        HDrawable grp2 = H.add(new HGroup()).size(50).anchorAt(H.CENTER).loc(width*4/5,height/2);
        grp2.add(r.createCopy()).fill(0xFFCC00).locAt(H.TOP_LEFT);
        grp2.add(r.createCopy()).fill(0xFFCC00).locAt(H.BOTTOM_RIGHT);

        /*
         * Setting rotatesChildren to true will
         * make the children of the drawable rotate
         * but not the drawable itself.
         *
         * Unlike stylesChildren() and transformsChildren(),
         * rotatesChildren is *not* set to true in HGroups
         * by default.
         */

        d2.rotatesChildren(true);
        grp2.rotatesChildren(true);

        new HRotate(d1, 1);
        new HRotate(d2, 1);
        new HRotate(grp1, 1);
        new HRotate(grp2, 1);
    }

    public void draw() {
        H.drawStage();
    }
}

sheldon-white avatar Oct 13 '18 19:10 sheldon-white

I've tried this both in plain processing (3.3.7) as well as in java with the same visual result. What exactly is not working for you?

mrd0ll4r avatar Oct 24 '18 14:10 mrd0ll4r