use of javafx.geometry.Rectangle2D in project FXGL by AlmasB.
the class ParticleMorphApp method initGame.
@Override
protected void initGame() {
pixelIndex = 0;
getGameScene().setBackgroundColor(Color.BLACK);
var texture = texture("robot_stand.png").subTexture(new Rectangle2D(50, 30, 200, 220));
pixels = ImagesKt.toPixels(texture.getImage()).stream().map(p -> {
var r = new Rectangle(1, 1, p.getColor());
r.setLayoutX(p.getX());
r.setLayoutY(p.getY());
r.setScaleX(3);
r.setScaleY(3);
return r;
}).collect(Collectors.toList());
pixels.forEach(p -> {
p.getProperties().put("vel", new Vec2());
p.getProperties().put("index", pixelIndex++);
addUINode(p, 250, 150);
});
var knight = texture("knight.png", 200, 220);
pixels2 = ImagesKt.toPixels(knight.getImage()).stream().map(p -> {
var r = new Rectangle(1, 1, p.getColor());
r.setLayoutX(p.getX());
r.setLayoutY(p.getY());
return r;
}).collect(Collectors.toList());
// pixels2.forEach(p -> {
// addUINode(p, 450, 150);
// });
System.out.println(pixels.size() + " " + pixels2.size());
}
Aggregations