1
0
mirror of https://github.com/aNNiMON/HotaruFX.git synced 2024-09-19 14:14:21 +03:00

Add scaleX/Y/Z and layoutX/Y properties

This commit is contained in:
Victor 2017-09-01 18:32:28 +03:00
parent 7831e11cf9
commit 09f5deb561
2 changed files with 51 additions and 3 deletions

View File

@ -16,6 +16,8 @@ public abstract class ObjectNode {
private PropertyTimelineHolder<Node> clip;
private PropertyTimelineHolder<Number> rotate;
private PropertyTimelineHolder<Number> translateX, translateY, translateZ;
private PropertyTimelineHolder<Number> scaleX, scaleY, scaleZ;
private PropertyTimelineHolder<Number> layoutX, layoutY;
@Getter @Setter
private boolean isUsedAsClip;
@ -26,6 +28,11 @@ public abstract class ObjectNode {
translateX = PropertyTimelineHolder.empty();
translateY = PropertyTimelineHolder.empty();
translateZ = PropertyTimelineHolder.empty();
scaleX = PropertyTimelineHolder.empty();
scaleY = PropertyTimelineHolder.empty();
scaleZ = PropertyTimelineHolder.empty();
layoutX = PropertyTimelineHolder.empty();
layoutY = PropertyTimelineHolder.empty();
isUsedAsClip = false;
}
@ -53,12 +60,37 @@ public abstract class ObjectNode {
return translateZ.setIfEmptyThenGet(node::translateZProperty);
}
public PropertyTimeline<Number> scaleXProperty() {
return scaleX.setIfEmptyThenGet(node::scaleXProperty);
}
public PropertyTimeline<Number> scaleYProperty() {
return scaleY.setIfEmptyThenGet(node::scaleYProperty);
}
public PropertyTimeline<Number> scaleZProperty() {
return scaleZ.setIfEmptyThenGet(node::scaleZProperty);
}
public PropertyTimeline<Number> layoutXProperty() {
return layoutX.setIfEmptyThenGet(node::layoutXProperty);
}
public PropertyTimeline<Number> layoutYProperty() {
return layoutY.setIfEmptyThenGet(node::layoutYProperty);
}
public void buildTimeline(TimeLine timeline) {
clip.applyIfPresent(timeline);
rotate.applyIfPresent(timeline);
translateX.applyIfPresent(timeline);
translateY.applyIfPresent(timeline);
translateZ.applyIfPresent(timeline);
scaleX.applyIfPresent(timeline);
scaleY.applyIfPresent(timeline);
scaleZ.applyIfPresent(timeline);
layoutX.applyIfPresent(timeline);
layoutY.applyIfPresent(timeline);
}
public final PropertyBindings propertyBindings() {
@ -71,7 +103,12 @@ public abstract class ObjectNode {
.add("rotate", NUMBER, this::rotateProperty)
.add("translateX", NUMBER, this::translateXProperty)
.add("translateY", NUMBER, this::translateYProperty)
.add("translateZ", NUMBER, this::translateZProperty);
.add("translateZ", NUMBER, this::translateZProperty)
.add("scaleX", NUMBER, this::scaleXProperty)
.add("scaleY", NUMBER, this::scaleYProperty)
.add("scaleZ", NUMBER, this::scaleZProperty)
.add("layoutX", NUMBER, this::layoutXProperty)
.add("layoutY", NUMBER, this::layoutYProperty);
}
public abstract <R, T> R accept(NodeVisitor<R, T> visitor, T input);

View File

@ -34,7 +34,9 @@ CLIP = circle({
radius: 78
})
CLIP@cx
.add(60, 173)
.add(60, -400)
.add(100, 173)
C = text({
x: -240,
@ -45,5 +47,14 @@ C = text({
font: 100,
clip: CLIP
})
C@layoutX
.add(100, 0)
.add(120, -300)
C@scaleX
.add(100, 1)
.add(120, 1.8)
C@scaleY
.add(100, 1)
.add(120, 1.8)
render(C, CLIP)
render(B, A, C, CLIP)