ladybird/Userland/Libraries/LibGUI/Painter.cpp
Matthew Olsson ff76a5b8d2 LibGfx: Add directional floating-point scaling to Painter
This allows the painter to be scaled separately in both directions, and
not just in integer intervals. This is crucial for proper SVG viewBox
support.

Most bitmap-related things verify the scale to be one as of now.
2021-05-02 22:48:06 +02:00

28 lines
634 B
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibGUI/Painter.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
#include <LibGfx/Bitmap.h>
namespace GUI {
Painter::Painter(Gfx::Bitmap& bitmap)
: Gfx::Painter(bitmap)
{
}
Painter::Painter(Widget& widget)
: Painter(*widget.window()->back_bitmap())
{
state().font = &widget.font();
auto origin_rect = widget.window_relative_rect();
translate(origin_rect.location());
state().clip_rect = origin_rect.intersected(m_target->rect());
m_clip_origin = state().clip_rect;
}
}