/* * Copyright (c) 2020-2022, Andreas Kling * Copyright (c) 2021-2022, Linus Groh * Copyright (c) 2022, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include namespace Web::HTML { // https://html.spec.whatwg.org/multipage/canvas.html#canvasfillstrokestyles template class CanvasFillStrokeStyles { public: ~CanvasFillStrokeStyles() = default; void set_fill_style(String style) { // FIXME: 2. If the given value is a CanvasPattern object that is marked as not origin-clean, then set this's origin-clean flag to false. my_drawing_state().fill_style = Gfx::Color::from_string(style).value_or(Color::Black); } String fill_style() const { return my_drawing_state().fill_style.to_string(); } void set_stroke_style(String style) { // FIXME: 2. If the given value is a CanvasPattern object that is marked as not origin-clean, then set this's origin-clean flag to false. my_drawing_state().stroke_style = Gfx::Color::from_string(style).value_or(Color::Black); } String stroke_style() const { return my_drawing_state().stroke_style.to_string(); } protected: CanvasFillStrokeStyles() = default; private: CanvasState::DrawingState& my_drawing_state() { return reinterpret_cast(*this).drawing_state(); } CanvasState::DrawingState const& my_drawing_state() const { return reinterpret_cast(*this).drawing_state(); } }; }