@Test void testBundle() { final var context = new Context(); BundleLoader.loadSingle(context, CompositionBundle.class); assertThat(context.functions(), hasKey("composition")); assertThat(context.composition(), nullValue()); assertThat(context.variables(), allOf( not(hasKey("Width")), not(hasKey("Height")), not(hasKey("HalfWidth")), not(hasKey("HalfHeight")) )); context.functions().get("composition").execute(); assertThat(context.composition(), notNullValue()); assertThat(context.variables(), allOf( hasEntry("Width", NumberValue.of(1920)), hasEntry("Height", NumberValue.of(1080)), hasEntry("HalfWidth", NumberValue.of(960)), hasEntry("HalfHeight", NumberValue.of(540)) )); }
private static Function composition(Context context) { return args -> { final Composition composition; switch (args.length) { case 0: composition = new Composition(); break; case 1: double frameRate = args[0].asDouble(); composition = new Composition(frameRate); break; case 2: int width = args[0].asInt(); int height = args[1].asInt(); composition = new Composition(width, height); break; case 3: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); composition = new Composition(width, height, frameRate); break; case 4: default: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); final var background = PropertyType.PAINT.<Paint>getFromHFX().apply(args[3]); composition = new Composition(width, height, frameRate, background); break; } final var scene = composition.getScene(); context.composition(composition); context.variables().put("Width", NumberValue.of(scene.getVirtualWidth())); context.variables().put("Height", NumberValue.of(scene.getVirtualHeight())); context.variables().put("HalfWidth", NumberValue.of(scene.getVirtualWidth() / 2)); context.variables().put("HalfHeight", NumberValue.of(scene.getVirtualHeight() / 2)); return NumberValue.ZERO; }; }
CompositionBundle implements Bundle { private static Function composition(Context context) { return args -> { final Composition composition; switch (args.length) { case 0: composition = new Composition(); break; case 1: double frameRate = args[0].asDouble(); composition = new Composition(frameRate); break; case 2: int width = args[0].asInt(); int height = args[1].asInt(); composition = new Composition(width, height); break; case 3: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); composition = new Composition(width, height, frameRate); break; case 4: default: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); final var background = PropertyType.PAINT.<Paint>getFromHFX().apply(args[3]); composition = new Composition(width, height, frameRate, background); break; } final var scene = composition.getScene(); context.composition(composition); context.variables().put("Width", NumberValue.of(scene.getVirtualWidth())); context.variables().put("Height", NumberValue.of(scene.getVirtualHeight())); context.variables().put("HalfWidth", NumberValue.of(scene.getVirtualWidth() / 2)); context.variables().put("HalfHeight", NumberValue.of(scene.getVirtualHeight() / 2)); return NumberValue.ZERO; }; } }
CompositionBundle implements Bundle { private static Function composition(Context context) { return args -> { final Composition composition; switch (args.length) { case 0: composition = new Composition(); break; case 1: double frameRate = args[0].asDouble(); composition = new Composition(frameRate); break; case 2: int width = args[0].asInt(); int height = args[1].asInt(); composition = new Composition(width, height); break; case 3: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); composition = new Composition(width, height, frameRate); break; case 4: default: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); final var background = PropertyType.PAINT.<Paint>getFromHFX().apply(args[3]); composition = new Composition(width, height, frameRate, background); break; } final var scene = composition.getScene(); context.composition(composition); context.variables().put("Width", NumberValue.of(scene.getVirtualWidth())); context.variables().put("Height", NumberValue.of(scene.getVirtualHeight())); context.variables().put("HalfWidth", NumberValue.of(scene.getVirtualWidth() / 2)); context.variables().put("HalfHeight", NumberValue.of(scene.getVirtualHeight() / 2)); return NumberValue.ZERO; }; }  }
CompositionBundle implements Bundle { private static Function composition(Context context) { return args -> { final Composition composition; switch (args.length) { case 0: composition = new Composition(); break; case 1: double frameRate = args[0].asDouble(); composition = new Composition(frameRate); break; case 2: int width = args[0].asInt(); int height = args[1].asInt(); composition = new Composition(width, height); break; case 3: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); composition = new Composition(width, height, frameRate); break; case 4: default: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); final var background = PropertyType.PAINT.<Paint>getFromHFX().apply(args[3]); composition = new Composition(width, height, frameRate, background); break; } final var scene = composition.getScene(); context.composition(composition); context.variables().put("Width", NumberValue.of(scene.getVirtualWidth())); context.variables().put("Height", NumberValue.of(scene.getVirtualHeight())); context.variables().put("HalfWidth", NumberValue.of(scene.getVirtualWidth() / 2)); context.variables().put("HalfHeight", NumberValue.of(scene.getVirtualHeight() / 2)); return NumberValue.ZERO; }; }  @Override Map<String, FunctionInfo> functionsInfo(); }
CompositionBundle implements Bundle { private static Function composition(Context context) { return args -> { final Composition composition; switch (args.length) { case 0: composition = new Composition(); break; case 1: double frameRate = args[0].asDouble(); composition = new Composition(frameRate); break; case 2: int width = args[0].asInt(); int height = args[1].asInt(); composition = new Composition(width, height); break; case 3: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); composition = new Composition(width, height, frameRate); break; case 4: default: width = args[0].asInt(); height = args[1].asInt(); frameRate = args[2].asDouble(); final var background = PropertyType.PAINT.<Paint>getFromHFX().apply(args[3]); composition = new Composition(width, height, frameRate, background); break; } final var scene = composition.getScene(); context.composition(composition); context.variables().put("Width", NumberValue.of(scene.getVirtualWidth())); context.variables().put("Height", NumberValue.of(scene.getVirtualHeight())); context.variables().put("HalfWidth", NumberValue.of(scene.getVirtualWidth() / 2)); context.variables().put("HalfHeight", NumberValue.of(scene.getVirtualHeight() / 2)); return NumberValue.ZERO; }; }  @Override Map<String, FunctionInfo> functionsInfo();  }