mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:57:45 +00:00
LibWeb: Add initial implementation of CRC2D.globalAlpha
Works for fills and strokes (using colors, gradients, or patterns), along with images. fill_rect() has been updated to use fill_path(), which allows it to easily transform the rect, and already supports opacity. Co-authored-by: MacDue <macdue@dueutil.tech>
This commit is contained in:
parent
ff5d530aa3
commit
45f86466bb
8 changed files with 150 additions and 39 deletions
25
Userland/Libraries/LibWeb/HTML/Canvas/CanvasCompositing.h
Normal file
25
Userland/Libraries/LibWeb/HTML/Canvas/CanvasCompositing.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/HTML/ImageData.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/canvas.html#canvascompositing
|
||||
class CanvasCompositing {
|
||||
public:
|
||||
virtual ~CanvasCompositing() = default;
|
||||
|
||||
virtual float global_alpha() const = 0;
|
||||
virtual void set_global_alpha(float) = 0;
|
||||
|
||||
protected:
|
||||
CanvasCompositing() = default;
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
// https://html.spec.whatwg.org/multipage/canvas.html#canvascompositing
|
||||
interface mixin CanvasCompositing {
|
||||
// compositing
|
||||
attribute unrestricted double globalAlpha; // (default 1.0)
|
||||
// FIXME: attribute DOMString globalCompositeOperation; // (default "source-over")
|
||||
};
|
|
@ -78,6 +78,7 @@ public:
|
|||
float line_width { 1 };
|
||||
bool image_smoothing_enabled { true };
|
||||
Bindings::ImageSmoothingQuality image_smoothing_quality { Bindings::ImageSmoothingQuality::Low };
|
||||
float global_alpha = { 1 };
|
||||
Optional<CanvasClip> clip;
|
||||
};
|
||||
DrawingState& drawing_state() { return m_drawing_state; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue