Commit graph

12 commits

Author SHA1 Message Date
Shannon Booth
123b5c9d34 LibDraw: Add draw_ellipse_intersecting function
This functon will draw an ellipse which is intersecting the corners of
the rect given. It is a very naive implementation, taking 200 samples of
points around the ellipse, and drawing straight lines between each of
these points.

The ellipses look good enough to me though!
2019-12-27 00:52:17 +01:00
Andreas Kling
f04394b9f3 LibDraw: Painter::draw_pixel() with thickness>1 was doubly translating
Callers of draw_pixel() are not expecting it to apply translation since
they will have already done that themselves.

This was causing draw_line() with thickness>1 to have an offset applied
in case the painter was already translated.
2019-11-29 22:31:45 +01:00
Andreas Kling
478cfae7c8 LibDraw: Support dotted lines in Painter::draw_line()
Painter::draw_line() now has an optional "bool dotted" parameter that
causes it to only render every other pixel.

Note that this only works with horizontal and vertical lines at the
moment and we'll assert if called with dotted=true for a diagonal line.
2019-11-27 20:52:11 +01:00
Andreas Kling
c645d9fe4a LibDraw: Add Painter::clear_rect() for filling a rect without blending
Sometimes you want to fill a rect with a specific color without alpha
blending it with whatever's already there.
2019-11-25 11:34:55 +01:00
Andreas Kling
89c0b158da LibDraw: Add support for colors with alpha in Painter::fill_rect()
This code is naive, but it works and looks okay. :^)
2019-11-16 19:26:17 +01:00
Andreas Kling
0d8aaaaa44 LibDraw: Store emojis in a HashMap<u32, RefPtr<GraphicsBitmap>>
Get rid of the dedicated Emoji class to make it easier to store a null
value signifying a failed lookup.

This allows us to remember failed lookups, making subsequent failures
for the same codepoint much faster. :^)
2019-10-19 18:36:45 +02:00
Andreas Kling
96f10c8de2 LibDraw: Rename Painter::blit_tiled() => draw_tiled_bitmap()
Also change the API to take a destination rect instead of a source rect
since internally it was basically creating a destination rect from the
source rect anyway. It was a little confusing.
2019-10-19 11:05:21 +02:00
Andreas Kling
a791b86afa LibDraw: Add TextAlignment::TopRight
Also tidy up the alignment code to use switch statements.
2019-09-06 19:23:54 +02:00
Sergey Bugaev
84bc6a92a7 LibDraw: Add emoji drawing support to Painter
From here on, all strings displayed to the user are expected to
be encoded as UTF-8. The next few commits will deal with a few
existing places where this requirement is currently violated.

https://github.com/SerenityOS/serenity/issues/490
2019-09-05 16:37:39 +02:00
Andreas Kling
d31ddf9aaa Painter: Fix off-by-one in bounding rects for right-aligned text
Another instance of "Rect::right() is the last pixel *inside* the rect,
not the first pixel outside the rect" messing me up.
2019-08-09 19:51:14 +02:00
Andreas Kling
b2aea6b4ff Painter: Scaling RGBA32 bitmaps treated the source as alpha-less RGB32
Found by PVS-Studio.
2019-08-01 11:05:52 +02:00
Andreas Kling
1c0669f010 LibDraw: Introduce (formerly known as SharedGraphics.)
Instead of LibGUI and WindowServer building their own copies of the drawing
and graphics code, let's it in a separate LibDraw library.

This avoids building the code twice, and will encourage better separation
of concerns. :^)
2019-07-18 10:18:16 +02:00
Renamed from SharedGraphics/Painter.cpp (Browse further)