Commit graph

6 commits

Author SHA1 Message Date
Jelle Raaijmakers
f391ccfe53 LibGfx+Everywhere: Change Gfx::Rect to be endpoint exclusive
Previously, calling `.right()` on a `Gfx::Rect` would return the last
column's coordinate still inside the rectangle, or `left + width - 1`.
This is called 'endpoint inclusive' and does not make a lot of sense for
`Gfx::Rect<float>` where a rectangle of width 5 at position (0, 0) would
return 4 as its right side. This same problem exists for `.bottom()`.

This changes `Gfx::Rect` to be endpoint exclusive, which gives us the
nice property that `width = right - left` and `height = bottom - top`.
It enables us to treat `Gfx::Rect<int>` and `Gfx::Rect<float>` exactly
the same.

All users of `Gfx::Rect` have been updated accordingly.
2023-05-23 12:35:42 +02:00
Tim Schumacher
82a152b696 LibGfx: Remove try_ prefix from bitmap creation functions
Those don't have any non-try counterpart, so we might as well just omit
it.
2023-01-26 20:24:37 +00:00
Sam Atkins
0bf4089af9 LibWeb: Convert border painting to new pixel units 2022-12-14 16:47:57 +00:00
MacDue
9a97adf121 LibWeb: Add option to allocate new bitmap for BorderRadiusCornerClipper
This will be needed for overflow: hidden, that clips things which may
themselves use the BorderRadiusCornerClipper.
2022-07-04 23:09:06 +02:00
MacDue
13c4c735b8 LibWeb: Add 'inside' clip mode to BorderRadiusCornerClipper
The default clip mode 'outside' clips everything outside the corner,
'inside' does the opposite :^)
2022-06-23 19:13:24 +01:00
MacDue
830632407f LibWeb: Add BorderRadiusCornerClipper
This is a helper class for clipping the corners off a element.

This works in a similar way to how (outline) borders are painted.

The steps are:
  1. A small bitmap that fits only the corners is allocated
  2. The corners are painted into the bitmap
  3. The existing pixels (where the corners will be painted)
     are copied using the (inverse) corner bitmap as a mask
     (done before the element is painted)
  4. The element is painted
  5. The areas outside the corner radii are restored

Like with the borders, this only requires allocation on the first
paint.
2022-06-16 10:28:07 +01:00