ladybird/Libraries/LibWeb/CSS/EasingFunction.h
Callum Law 95e26819d9 LibWeb: Separate use time easing functions from EasingStyleValue
In the future there will be different methods of creating these use-time
easing functions (e.g. from `KeywordStyleValue`s)
2025-10-20 11:27:44 +01:00

60 lines
1.3 KiB
C++

/*
* Copyright (c) 2025, Callum Law <callumlaw1709@outlook.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/CSS/Enums.h>
#include <LibWeb/CSS/StyleValues/StyleValue.h>
namespace Web::CSS {
struct LinearEasingFunction {
struct ControlPoint {
Optional<double> input;
double output;
};
Vector<ControlPoint> control_points;
String stringified;
double evaluate_at(double input_progress, bool before_flag) const;
};
struct CubicBezierEasingFunction {
double x1;
double y1;
double x2;
double y2;
String stringified;
struct CachedSample {
double x;
double y;
double t;
};
mutable Vector<CachedSample> m_cached_x_samples {};
double evaluate_at(double input_progress, bool before_flag) const;
};
struct StepsEasingFunction {
long interval_count;
StepPosition position;
String stringified;
double evaluate_at(double input_progress, bool before_flag) const;
};
struct EasingFunction : public Variant<LinearEasingFunction, CubicBezierEasingFunction, StepsEasingFunction> {
using Variant::Variant;
static EasingFunction from_style_value(StyleValue const&);
double evaluate_at(double input_progress, bool before_flag) const;
String to_string() const;
};
}