2022-08-12 15:46:31 +01:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2020-2022, Andreas Kling <andreas@ladybird.org>
|
2022-08-12 15:46:31 +01:00
|
|
|
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
|
|
|
|
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
2023-01-18 20:10:00 +01:00
|
|
|
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
|
2022-08-12 15:46:31 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-09-02 22:57:38 +02:00
|
|
|
#include <LibWeb/Forward.h>
|
2022-08-12 15:46:31 +01:00
|
|
|
#include <LibWeb/HTML/Canvas/CanvasState.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/canvas.html#canvasfillstrokestyles
|
|
|
|
|
template<typename IncludingClass>
|
|
|
|
|
class CanvasFillStrokeStyles {
|
|
|
|
|
public:
|
|
|
|
|
~CanvasFillStrokeStyles() = default;
|
2024-11-15 04:01:23 +13:00
|
|
|
using FillOrStrokeStyleVariant = Variant<String, GC::Root<CanvasGradient>, GC::Root<CanvasPattern>>;
|
2022-08-12 15:46:31 +01:00
|
|
|
|
2025-10-24 13:53:02 +13:00
|
|
|
void set_fill_style(FillOrStrokeStyleVariant style);
|
|
|
|
|
FillOrStrokeStyleVariant fill_style() const;
|
2023-11-18 21:08:25 +11:00
|
|
|
|
2025-10-24 13:53:02 +13:00
|
|
|
void set_stroke_style(FillOrStrokeStyleVariant style);
|
|
|
|
|
FillOrStrokeStyleVariant stroke_style() const;
|
2025-07-19 11:31:07 +12:00
|
|
|
|
2025-10-24 13:53:02 +13:00
|
|
|
WebIDL::ExceptionOr<GC::Ref<CanvasGradient>> create_radial_gradient(double x0, double y0, double r0, double x1, double y1, double r1);
|
|
|
|
|
GC::Ref<CanvasGradient> create_linear_gradient(double x0, double y0, double x1, double y1);
|
|
|
|
|
GC::Ref<CanvasGradient> create_conic_gradient(double start_angle, double x, double y);
|
|
|
|
|
WebIDL::ExceptionOr<GC::Ptr<CanvasPattern>> create_pattern(CanvasImageSource const& image, StringView repetition);
|
2023-02-02 20:47:46 +00:00
|
|
|
|
2022-08-12 15:46:31 +01:00
|
|
|
protected:
|
|
|
|
|
CanvasFillStrokeStyles() = default;
|
|
|
|
|
|
|
|
|
|
private:
|
2025-10-24 13:53:02 +13:00
|
|
|
Variant<HTMLCanvasElement*, OffscreenCanvas*> my_canvas_element();
|
|
|
|
|
CanvasState::DrawingState& my_drawing_state();
|
|
|
|
|
CanvasState::DrawingState const& my_drawing_state() const;
|
2022-08-12 15:46:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|