mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:57:35 +00:00
LibGfx: Make checkerboard patterns static when panning
Previously checkerboard patterns were anchored to the top left of the bitmap they were being drawn into. This makes the transparency grid in PixelPaint static relative to the canvas when panning.
This commit is contained in:
parent
b0db56cd39
commit
392dac0818
1 changed files with 5 additions and 4 deletions
|
@ -197,19 +197,20 @@ void Painter::fill_rect_with_checkerboard(IntRect const& a_rect, IntSize cell_si
|
||||||
{
|
{
|
||||||
VERIFY(scale() == 1); // FIXME: Add scaling support.
|
VERIFY(scale() == 1); // FIXME: Add scaling support.
|
||||||
|
|
||||||
auto rect = a_rect.translated(translation()).intersected(clip_rect());
|
auto translated_rect = a_rect.translated(translation());
|
||||||
|
auto rect = translated_rect.intersected(clip_rect());
|
||||||
if (rect.is_empty())
|
if (rect.is_empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ARGB32* dst = m_target->scanline(rect.top()) + rect.left();
|
ARGB32* dst = m_target->scanline(rect.top()) + rect.left();
|
||||||
size_t const dst_skip = m_target->pitch() / sizeof(ARGB32);
|
size_t const dst_skip = m_target->pitch() / sizeof(ARGB32);
|
||||||
|
|
||||||
int first_cell_column = rect.x() / cell_size.width();
|
int first_cell_column = (rect.x() - translated_rect.x()) / cell_size.width();
|
||||||
int prologue_length = min(rect.width(), cell_size.width() - (rect.x() % cell_size.width()));
|
int prologue_length = min(rect.width(), cell_size.width() - ((rect.x() - translated_rect.x()) % cell_size.width()));
|
||||||
int number_of_aligned_strips = (rect.width() - prologue_length) / cell_size.width();
|
int number_of_aligned_strips = (rect.width() - prologue_length) / cell_size.width();
|
||||||
|
|
||||||
for (int i = 0; i < rect.height(); ++i) {
|
for (int i = 0; i < rect.height(); ++i) {
|
||||||
int y = rect.y() + i;
|
int y = rect.y() - translated_rect.y() + i;
|
||||||
int cell_row = y / cell_size.height();
|
int cell_row = y / cell_size.height();
|
||||||
bool odd_row = cell_row & 1;
|
bool odd_row = cell_row & 1;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue