1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 23:35:08 +00:00
serenity/Userland/Libraries/LibWeb/Painting/GradientPainting.h
MacDue 698717d102 LibWeb: Resolve double-position linear-gradient() color stops
These just resolve to an extra color stop.
Something like "red 10% 40%"  is just shorthand for "red 10%, red 40%".
2022-08-23 01:02:49 +02:00

35 lines
805 B
C++

/*
* Copyright (c) 2022, MacDue <macdue@dueutil.tech>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Span.h>
#include <AK/Vector.h>
#include <LibGfx/Color.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Painting/PaintContext.h>
namespace Web::Painting {
struct ColorStop {
Gfx::Color color;
float position = AK::NaN<float>;
Optional<float> transition_hint = {};
};
using ColorStopList = Vector<ColorStop, 4>;
struct LinearGradientData {
float gradient_angle;
ColorStopList color_stops;
Optional<float> repeat_length;
};
LinearGradientData resolve_linear_gradient_data(Layout::Node const&, Gfx::FloatSize const&, CSS::LinearGradientStyleValue const&);
void paint_linear_gradient(PaintContext&, Gfx::IntRect const&, LinearGradientData const&);
}