mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:18:11 +00:00
LibWeb: Add barebones CanvasGradient object
Also add the CanvasRenderingContext2D APIs to go along with it. Note that it can't be used for anything yet.
This commit is contained in:
parent
545ec334f0
commit
dc3bf32307
10 changed files with 130 additions and 0 deletions
40
Userland/Libraries/LibWeb/HTML/CanvasGradient.h
Normal file
40
Userland/Libraries/LibWeb/HTML/CanvasGradient.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <LibWeb/Bindings/Wrappable.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
class CanvasGradient final
|
||||
: public RefCounted<CanvasGradient>
|
||||
, public Bindings::Wrappable {
|
||||
public:
|
||||
using WrapperType = Bindings::CanvasGradientWrapper;
|
||||
|
||||
enum class Type {
|
||||
Linear,
|
||||
Radial,
|
||||
Conic,
|
||||
};
|
||||
|
||||
static NonnullRefPtr<CanvasGradient> create_radial(double x0, double y0, double r0, double x1, double y1, double r1);
|
||||
static NonnullRefPtr<CanvasGradient> create_linear(double x0, double y0, double x1, double y1);
|
||||
static NonnullRefPtr<CanvasGradient> create_conic(double start_angle, double x, double y);
|
||||
|
||||
void add_color_stop(double offset, String const& color);
|
||||
|
||||
~CanvasGradient();
|
||||
|
||||
private:
|
||||
explicit CanvasGradient(Type);
|
||||
|
||||
Type m_type {};
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue