Skip to content

Commit

Permalink
tools/animgen: support more sophisticated preset parameters
Browse files Browse the repository at this point in the history
Support multiple choice parameters in additional to plain old numbers.

With this we are now able to change the direction of sliding, yippee!

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
  • Loading branch information
yshui committed Aug 5, 2024
1 parent 130066e commit 981bb77
Show file tree
Hide file tree
Showing 5 changed files with 1,023 additions and 368 deletions.
100 changes: 71 additions & 29 deletions data/animation_presets.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,13 @@ disappear = {
shadow-scale-y = "scale-y";
shadow-offset-x = "offset-x";
shadow-offset-y = "offset-y";
# This section defines placeholders used in this script
# Each entry is a tuple of two numbers. The first one is
# the id of the placeholder (e.g. 0 for placeholder0), the
# second number is the default value, if it is not specified
# by the user.
#
# Currently up to 10 placeholders are supported, if more is
# needed, tools/animgen.c needs to be updated to include more.
placeholders = {
scale = (1, 0.95);
duration = (0, 0.2);

# See comments in tools/animgen.c for syntax
*knobs = {
scale = 0.95;
duration = 0.2;
};
*placeholders = ((0, "duration"),(1, "scale"));
};

appear = {
Expand All @@ -54,70 +49,117 @@ appear = {
shadow-scale-y = "scale-y";
shadow-offset-x = "offset-x";
shadow-offset-y = "offset-y";
placeholders = {
scale = (1, 0.95);
duration = (0, 0.2);
*knobs = {
scale = 0.95;
duration = 0.2;
};
*placeholders = ((0, "duration"),(1, "scale"));
};

slide-out = {
offset-x = {
v-timing = {
curve = "cubic-bezier(0.21, 0.02, 0.76, 0.36)";
start = 0;
duration = "placeholder0";
end = "-window-width";
end = "window-width * placeholder1 + window-height * placeholder2";
};
offset-x = "v-timing * placeholder3";
offset-y = "v-timing * (1 - placeholder3)";
shadow-offset-x = "offset-x";
shadow-offset-y = "offset-y";
crop-x = "window-x";
crop-y = "window-y";
crop-width = "window-width";
crop-height = "window-height";
opacity = 1;
blur-opacity = "opacity";
shadow-opacity = "opacity";
placeholders = {
duration = (0, 0.2);
*knobs = {
duration = 0.2;
direction = (2, ["up", "down", "left", "right"]);
};
*placeholders = (
(0, "duration"),
(1, "direction", [0, 0, -1, 1]),
(2, "direction", [-1, 1, 0, 0]),
(3, "direction", [0, 0, 1, 1]),
);
};

slide-in = {
offset-x = {
v-timing = {
curve = "cubic-bezier(0.24, 0.64, 0.79, 0.98)";
start = "-window-width";
start = "window-width * placeholder1 + window-height * placeholder2";
duration = "placeholder0";
end = 0;
};
offset-x = "v-timing * placeholder3";
offset-y = "v-timing * (1 - placeholder3)";
shadow-offset-x = "offset-x";
shadow-offset-y = "offset-y";
crop-x = "window-x";
placeholders = {
duration = (0, 0.2);
crop-y = "window-y";
crop-width = "window-width";
crop-height = "window-height";
*knobs = {
duration = 0.2;
direction = (2, ["up", "down", "left", "right"]);
};
*placeholders = (
(0, "duration"),
(1, "direction", [0, 0, -1, 1]),
(2, "direction", [-1, 1, 0, 0]),
(3, "direction", [0, 0, 1, 1]),
);
};

fly-out = {
offset-y = {
v-timing = {
curve = "cubic-bezier(0.05, 0, 0.69, -0.05)";
duration = "placeholder0";
start = 0;
end = "- window-height - window-y";
end = "(window-height + window-y) * placeholder2 + (window-width + window-x) * placeholder1";
};
offset-x = "v-timing * placeholder3";
offset-y = "v-timing * (1 - placeholder3)";
shadow-offset-x = "offset-x";
shadow-offset-y = "offset-y";
opacity = 1;
shadow-opacity = 1;
blur-opacity = 1;
placeholders = {
duration = (0, 0.25);
*knobs = {
duration = 0.2;
direction = (0, ["up", "down", "left", "right"]);
};
*placeholders = (
(0, "duration"),
(1, "direction", [0, 0, -1, 1]),
(2, "direction", [-1, 1, 0, 0]),
(3, "direction", [0, 0, 1, 1]),
);
};
fly-in = {
offset-y = {
v-timing = {
curve = "cubic-bezier(0.17, 0.67, 0.68, 1.03)";
end = 0;
duration = "placeholder0";
start = "- window-height - window-y";
};
offset-x = "v-timing * placeholder3";
offset-y = "v-timing * (1 - placeholder3)";
shadow-offset-x = "offset-x";
shadow-offset-y = "offset-y";
opacity = 1;
shadow-opacity = 1;
blur-opacity = 1;
placeholders = {
duration = (0, 0.25);
*knobs = {
duration = 0.2;
direction = (0, ["up", "down", "left", "right"]);
};
*placeholders = (
(0, "duration"),
(1, "direction", [0, 0, -1, 1]),
(2, "direction", [-1, 1, 0, 0]),
(3, "direction", [0, 0, 1, 1]),
);
}
4 changes: 2 additions & 2 deletions src/transition/curve.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ curve_sample_cubic_bezier(const struct curve_cubic_bezier *curve, double progres
static char *curve_cubic_bezier_to_c(const struct curve_cubic_bezier *curve) {
char *buf = NULL;
casprintf(&buf,
"{.type = CURVE_CUBIC_BEZIER, .bezier = { .ax = %f, .bx = %f, "
".cx = %f, .ay = %f, .by = %f, .cy = %f }},",
"{.type = CURVE_CUBIC_BEZIER, .bezier = { .ax = %a, .bx = %a, "
".cx = %a, .ay = %a, .by = %a, .cy = %a }},",
curve->ax, curve->bx, curve->cx, curve->ay, curve->by, curve->cy);
return buf;
}
Expand Down
Loading

0 comments on commit 981bb77

Please sign in to comment.