hype / HYPE_Processing

HYPE for Processing
BSD 3-Clause "New" or "Revised" License
928 stars 149 forks source link

Using HYPE libraries with java applications? #159

Open sheldon-white opened 6 years ago

sheldon-white commented 6 years ago

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();
    }
}
mrd0ll4r commented 6 years ago

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?