53 float at(
float t)
const {
54 if (
t <= 0.0f)
return 0.0f;
55 if (
t >= 1.0f)
return 1.0f;
70 const float step = 1.0f /
static_cast<float>(
steps_count);
71 const float v = std::floor(
t / step) * step + step;
72 return v > 1.0f ? 1.0f :
v;
75 const float step = 1.0f /
static_cast<float>(
steps_count);
76 return std::floor(
t / step) * step;
86 const float cx = 3.0f *
p1x;
87 const float bx = 3.0f * (
p2x -
p1x) - cx;
88 const float ax = 1.0f - cx - bx;
89 const float cy = 3.0f *
p1y;
90 const float by = 3.0f * (
p2y -
p1y) - cy;
91 const float ay = 1.0f - cy - by;
93 for (
int i = 0;
i < 6; ++
i) {
94 const float xu = ((ax *
u + bx) *
u + cx) *
u;
95 const float dxu = (3.0f * ax *
u + 2.0f * bx) *
u + cx;
96 if (dxu == 0.0f)
break;
97 const float du = (xu -
x) / dxu;
99 if (std::abs(du) < 1e-5f)
break;
101 return ((ay *
u + by) *
u + cy) *
u;
215 spec.duration_seconds = 0.0f;
216 spec.delay_seconds = 0.0f;
222 spec.duration_seconds *=
static_cast<float>(
scale);
238 const float total =
spec.delay_seconds +
spec.duration_seconds;
247 const float t =
spec.duration_seconds > 0.0f
248 ? local /
spec.duration_seconds
250 const float p =
spec.easing.at(
t);
259 std::string metric_name,
262 if (
p.is_set() && !opts.provenance.is_set()) {
263 opts.provenance = std::move(
p);
272 if (
t > 1.0f)
t = 1.0f;
277 static_cast<double>(current), opts);
289 std::vector<std::pair<std::string , std::string >>
properties;
305 if (
b.name ==
block.name) {
315 if (
b.name == name)
return &
b;
354 if (
s.empty())
return 0.0f;
356 float v = std::strtof(
s.c_str(), &
end);
357 if (
end ==
s.c_str() || !std::isfinite(
v))
return 0.0f;
358 std::string unit =
end;
359 while (!unit.empty() && std::isspace(
static_cast<unsigned char>(unit.front()))) unit.erase(0, 1);
360 while (!unit.empty() && std::isspace(
static_cast<unsigned char>(unit.back()))) unit.pop_back();
361 if (unit ==
"ms")
return v / 1000.0f;
362 if (unit ==
"s")
return v;
363 if (unit.empty())
return v;
368 if (token.empty())
return false;
370 float v = std::strtof(token.c_str(), &
end);
371 if (
end == token.c_str() || !std::isfinite(
v))
return false;
372 while (*
end !=
'\0') {
373 if (!std::isspace(
static_cast<unsigned char>(*
end)))
return false;
390 std::vector<TransitionSpec> out;
391 if (css.empty() || css ==
"none")
return out;
395 std::vector<std::string> entries;
400 if (
c ==
'(') ++depth;
401 else if (
c ==
')') --depth;
402 if (
c ==
',' && depth == 0) {
403 entries.push_back(acc);
409 if (!acc.empty()) entries.push_back(acc);
412 for (
const auto& entry : entries) {
415 std::vector<std::string> tokens;
419 for (
char c : entry) {
420 if (
c ==
'(') { ++depth; acc +=
c;
continue; }
421 if (
c ==
')') { --depth; acc +=
c;
continue; }
422 if (depth == 0 && std::isspace(
static_cast<unsigned char>(
c))) {
423 if (!acc.empty()) { tokens.push_back(acc); acc.clear(); }
428 if (!acc.empty()) tokens.push_back(acc);
431 if (tokens.empty())
continue;
434 bool saw_duration =
false;
435 for (
const auto& tok : tokens) {
437 const bool ends_ms = (tok.size() >= 2 && tok.substr(tok.size() - 2) ==
"ms");
438 const bool ends_s_only = (!ends_ms && tok.size() >= 2 && tok.back() ==
's'
439 && (std::isdigit(
static_cast<unsigned char>(tok[tok.size() - 2]))
440 || tok[tok.size() - 2] ==
'.'));
441 if (ends_ms || ends_s_only) {
447 if (tok ==
"linear" || tok ==
"ease" || tok ==
"ease-in"
448 || tok ==
"ease-out" || tok ==
"ease-in-out") {
453 if (tok.rfind(
"cubic-bezier(", 0) == 0 && tok.back() ==
')') {
454 std::string inner = tok.substr(13, tok.size() - 14);
455 std::vector<float> nums;
464 for (
char c : inner) {
465 if (
c ==
',') flush();
466 else if (!std::isspace(
static_cast<unsigned char>(
c))) acc +=
c;
469 if (nums.size() == 4) {
477 if (tok.rfind(
"steps(", 0) == 0 && tok.back() ==
')') {
478 std::string inner = tok.substr(6, tok.size() - 7);
479 size_t comma = inner.find(
',');
480 std::string n_str = comma == std::string::npos ? inner : inner.substr(0, comma);
482 long steps = std::strtol(n_str.c_str(), &
end, 10);
483 if (
end == n_str.c_str())
continue;
484 bool valid_steps =
true;
485 while (*
end !=
'\0') {
486 if (!std::isspace(
static_cast<unsigned char>(*
end))) {
492 if (!valid_steps)
continue;
495 if (comma != std::string::npos) {
496 std::string mode = inner.substr(comma + 1);
497 while (!mode.empty() && std::isspace(
static_cast<unsigned char>(mode.front()))) mode.erase(0, 1);
498 if (mode.rfind(
"jump-start", 0) == 0 || mode ==
"start") {
510 out.push_back(std::move(spec));
521 const std::string& css,
522 std::string source_file,
525 for (
auto&
s : specs) {
526 s.source_file = source_file;
527 s.source_line = source_line;
static MotionPolicy current()
Convenience: the effective policy right now.
Definition motion_preferences.hpp:45
static double current_duration_scale()
Convenience: the effective duration scale right now.
Definition motion_preferences.hpp:48
Agent-first motion observability: sample view geometry, scroll state, and arbitrary scalar values at ...
System-level reduced-motion preferences.
void publish_value(std::string view_name, std::string metric_name, double value, PublishOptions opts={})
Single-component publish.
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
std::vector< TransitionSpec > parse_transition_shorthand_with_provenance(const std::string &css, std::string source_file, int source_line)
Parse a transition shorthand AND stamp each emitted TransitionSpec with the source attribution (CSS f...
Definition css_animation.hpp:520
@ bottom
Definition border_style.hpp:31
@ right
Definition border_style.hpp:31
@ left
Definition border_style.hpp:31
@ top
Definition border_style.hpp:31
@ none
Definition appearance_defects.hpp:53
bool motion_policy_is_off()
Returns true when the current policy says "do not animate" — i.e.
Definition motion_preferences.hpp:133
AnimatableProperty animatable_property_from_css_name(const std::string &name)
Map CSS property name to AnimatableProperty enum.
Definition css_animation.hpp:325
bool parse_css_float_token(const std::string &token, float &out)
Definition css_animation.hpp:367
float parse_css_time_seconds(const std::string &s)
Parse a CSS time string (200ms / 0.3s / bare seconds) into seconds.
Definition css_animation.hpp:353
@ block
Filled glyph cell; the covered glyph is drawn in the bg color.
Definition caret.hpp:66
@ s
Definition input_events.hpp:41
@ c
Definition input_events.hpp:39
@ u
Definition input_events.hpp:41
@ p
Definition input_events.hpp:40
@ i
Definition input_events.hpp:40
@ b
Definition input_events.hpp:39
@ x
Definition input_events.hpp:41
@ v
Definition input_events.hpp:41
@ e
Definition input_events.hpp:39
@ t
Definition input_events.hpp:41
std::vector< TransitionSpec > parse_transition_shorthand(const std::string &css)
Parse a CSS transition shorthand into a list of TransitionSpecs.
Definition css_animation.hpp:389
@ end
Definition geometry.hpp:370
AnimatableProperty
Property whose values can be tweened.
Definition css_animation.hpp:118
@ scale
Definition css_animation.hpp:126
@ padding_bottom
Definition css_animation.hpp:135
@ translate_y
Definition css_animation.hpp:124
@ translate_x
Definition css_animation.hpp:123
@ background_color
Definition css_animation.hpp:120
@ margin_top
Definition css_animation.hpp:129
@ none
Definition css_animation.hpp:141
@ border_color
Definition css_animation.hpp:122
@ padding_right
Definition css_animation.hpp:134
@ color
Definition css_animation.hpp:121
@ bottom
Definition css_animation.hpp:139
@ right
Definition css_animation.hpp:138
@ left
Definition css_animation.hpp:140
@ rotate_deg
Definition css_animation.hpp:125
@ margin_right
Definition css_animation.hpp:130
@ opacity
Definition css_animation.hpp:119
@ top
Definition css_animation.hpp:137
@ height
Definition css_animation.hpp:128
@ padding_top
Definition css_animation.hpp:133
@ margin_bottom
Definition css_animation.hpp:131
@ width
Definition css_animation.hpp:127
@ padding_left
Definition css_animation.hpp:136
@ margin_left
Definition css_animation.hpp:132
@ Reduced
Animate, but scale duration by duration_scale.
Definition motion_preferences.hpp:30
One running animation.
Definition css_animation.hpp:189
bool motion_policy_applied_
Internal: have we applied the current MotionPolicy to this animation's effective duration yet?
Definition css_animation.hpp:205
void apply_motion_policy()
Apply the current MotionPolicy to spec.duration_seconds (and start_value under Off,...
Definition css_animation.hpp:210
float tick(float dt)
Advance by dt seconds.
Definition css_animation.hpp:235
TransitionSpec spec
Definition css_animation.hpp:191
void publish(std::string view_name, std::string metric_name, motion::PublishOptions opts={}) const
Publish the current eased value through the motion publish channel, stamping spec....
Definition css_animation.hpp:258
float start_value
Start + end values are property-typed; supported properties reduce to a float scalar after component ...
Definition css_animation.hpp:195
float elapsed_seconds
Definition css_animation.hpp:197
float end_value
Definition css_animation.hpp:196
bool active
Definition css_animation.hpp:198
CSS easing function — maps a normalized progress t ∈ [0,1] to an eased progress p ∈ [0,...
Definition css_animation.hpp:29
Kind kind
CSS spec — transition-timing-function defaults to ease, NOT linear.
Definition css_animation.hpp:45
static float cubic_bezier_y(float x, float p1x, float p1y, float p2x, float p2y)
Evaluate a CSS cubic-bezier(p1x, p1y, p2x, p2y) at progress x.
Definition css_animation.hpp:85
float p1y
Definition css_animation.hpp:49
int steps_count
Definition css_animation.hpp:50
float p1x
Cubic-bezier control points.
Definition css_animation.hpp:49
static CssEasing from_keyword(const std::string &s)
Parse a CSS easing keyword. Unrecognized → linear.
Definition css_animation.hpp:105
float at(float t) const
Evaluate the easing at progress t ∈ [0,1].
Definition css_animation.hpp:53
float p2y
Definition css_animation.hpp:49
float p2x
Definition css_animation.hpp:49
Kind
Definition css_animation.hpp:30
@ steps_end
Definition css_animation.hpp:38
@ ease_in
Definition css_animation.hpp:33
@ ease_out
Definition css_animation.hpp:34
@ steps_start
Definition css_animation.hpp:37
@ ease
Definition css_animation.hpp:32
@ linear
Definition css_animation.hpp:31
@ ease_in_out
Definition css_animation.hpp:35
@ cubic_bezier
Definition css_animation.hpp:36
One @keyframe stop.
Definition css_animation.hpp:284
std::vector< std::pair< std::string, std::string > > properties
Property → value snapshots.
Definition css_animation.hpp:289
float offset
Position along the timeline: 0.0 = from, 1.0 = to.
Definition css_animation.hpp:287
One @keyframes block: name + ordered stops.
Definition css_animation.hpp:293
std::string name
Definition css_animation.hpp:294
std::vector< CssKeyframe > stops
Definition css_animation.hpp:295
Application-wide registry for @keyframes blocks.
Definition css_animation.hpp:300
std::vector< CssKeyframesBlock > blocks
Definition css_animation.hpp:301
void define(CssKeyframesBlock block)
Definition css_animation.hpp:303
const CssKeyframesBlock * find(const std::string &name) const
Definition css_animation.hpp:313
One transition spec — one CSS property with its own duration / delay / easing.
Definition css_animation.hpp:147
CssEasing easing
Definition css_animation.hpp:154
std::string property_name
Original CSS property name.
Definition css_animation.hpp:151
int source_line
Definition css_animation.hpp:161
AnimatableProperty property
Definition css_animation.hpp:148
float duration_seconds
Definition css_animation.hpp:152
bool is_snap() const
CSS spec — duration <= 0 means "snap" (no tween).
Definition css_animation.hpp:165
motion::Provenance motion_provenance() const
Build a motion::Provenance envelope for this spec.
Definition css_animation.hpp:172
std::string source_file
Source attribution.
Definition css_animation.hpp:160
float delay_seconds
Definition css_animation.hpp:153
std::string source_kind
"tween" | "css-transition" | "animator-set" | "rAF" | "design-import" | "user" | "publish"
Definition motion.hpp:78
Definition motion.hpp:181