2022-02-03 20:08:27 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-02-05 15:16:35 +01:00
|
|
|
#include <LibGfx/Color.h>
|
2022-09-02 23:17:45 +02:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2022-02-03 20:08:27 +01:00
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
2022-09-02 23:17:45 +02:00
|
|
|
class CanvasGradient final : public Bindings::PlatformObject {
|
|
|
|
WEB_PLATFORM_OBJECT(CanvasGradient, Bindings::PlatformObject);
|
|
|
|
|
2022-02-03 20:08:27 +01:00
|
|
|
public:
|
|
|
|
enum class Type {
|
|
|
|
Linear,
|
|
|
|
Radial,
|
|
|
|
Conic,
|
|
|
|
};
|
|
|
|
|
2022-09-25 16:38:21 -06:00
|
|
|
static JS::NonnullGCPtr<CanvasGradient> create_radial(JS::Realm&, double x0, double y0, double r0, double x1, double y1, double r1);
|
|
|
|
static JS::NonnullGCPtr<CanvasGradient> create_linear(JS::Realm&, double x0, double y0, double x1, double y1);
|
|
|
|
static JS::NonnullGCPtr<CanvasGradient> create_conic(JS::Realm&, double start_angle, double x, double y);
|
2022-02-03 20:08:27 +01:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
WebIDL::ExceptionOr<void> add_color_stop(double offset, DeprecatedString const& color);
|
2022-02-03 20:08:27 +01:00
|
|
|
|
|
|
|
~CanvasGradient();
|
|
|
|
|
|
|
|
private:
|
2022-09-25 16:38:21 -06:00
|
|
|
CanvasGradient(JS::Realm&, Type);
|
2022-02-03 20:08:27 +01:00
|
|
|
|
2023-01-10 06:28:20 -05:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
|
|
|
2022-02-03 20:08:27 +01:00
|
|
|
Type m_type {};
|
2022-02-05 15:16:35 +01:00
|
|
|
|
|
|
|
struct ColorStop {
|
|
|
|
double offset { 0 };
|
|
|
|
Gfx::Color color;
|
|
|
|
};
|
|
|
|
|
|
|
|
Vector<ColorStop> m_color_stops;
|
2022-02-03 20:08:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|