hype / HYPE_Processing

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

Unexpected effect while using HColorPool #138

Open bryanmaina opened 7 years ago

bryanmaina commented 7 years ago

I can't get any svg from inkscape to work properly with HGridLayout and HColorPool at the same time. When I run the following code, the layout is just as expected. Things go wrong when I uncomment the following line // d.randomColors(colors);. The layout is messed up when I try to put random colors on each path of the svg.

import hype.*;
import hype.extended.colorist.HColorPool;
import hype.extended.layout.HGridLayout;

HDrawablePool pool;
HColorPool colors;

void setup(){
  size(600, 600);
  H.init(this).background(#220000);

  pool = new HDrawablePool(4);

  colors = new HColorPool(#FFFFFF, #F7F7F7, #ECECEC, #333333, #0095a8, #00616f, #FF3300, #FF6600).fillOnly();

  float scaling = 300.0/1000;
  println(scaling);

  pool.autoAddToStage()
    .add(new HShape("ex_1.svg").scale(scaling))
    .layout(new HGridLayout()
            .startX(150)
            .startY(150)
            .spacing(300,300)
            .cols(2)
            )
    .onCreate(new HCallback() {
        public void run(Object obj) {
          HShape d = (HShape) obj;
          d
            .enableStyle(false)
            .strokeJoin(ROUND)
            .strokeCap(ROUND)
            .stroke(#ffffff)
            .strokeWeight(1)
            .noFill()
            .anchorAt(H.CENTER)
            .rotation((int)random(4) * 90);
          //          d.randomColors(colors);
        }
      })
    .requestAll();

  H.drawStage();
}

void draw(){

}

I tried the examples and they all works as expected. I also made some svg files with illustrator and they all work well. But all those made with inkscape fails to preserve the layout while they are assigned a color.