We can split bitmaps with cropBitmap but there is no way to stitch bitmaps back together. For example if we want to stitch up some text from few bitmaps, we have to do logic to make sure all bitmaps are rendered at right offsets: it would be much easier to join up the bitmaps into one and render it at single point.
then maybe the type signature could be something like
stitchBitmap ∷ Bitmap -- ^ Original bitmap
→ Bitmap -- ^ bitmap to stitch
→ (Int, Int) -- ^ Point at which to stitch
→ Bitmap
could work. Everywhere that bitmaps don't overlay would simply be 0 opacity. Same if the point to stitch at is outside the original bitmap size. If we take the point to be the center of where the new bitmap would be spliced in, we could join two bitmaps by sides like this:
-- Stitch two bitmaps together side by side.
sideBySide ∷ Bitmap → Bitmap → Bitmap
sideBySide o n =
let (w, h) = bitmapSize n & both %~ (round . (/ (2 ∷ Double)) . fromIntegral)
(ow, _oh) = bitmapSize o
in stitchBitmap o n (w + ow, h)
which should result in new bitmap with size (w + ow * 2, max (h * 2) _oh).
Would such a function be possible? You can pick whatever implementation you want of course, the above is just an example.
We can split bitmaps with
cropBitmap
but there is no way to stitch bitmaps back together. For example if we want to stitch up some text from few bitmaps, we have to do logic to make sure all bitmaps are rendered at right offsets: it would be much easier to join up the bitmaps into one and render it at single point.Considering
then maybe the type signature could be something like
could work. Everywhere that bitmaps don't overlay would simply be 0 opacity. Same if the point to stitch at is outside the original bitmap size. If we take the point to be the center of where the new bitmap would be spliced in, we could join two bitmaps by sides like this:
which should result in new bitmap with size
(w + ow * 2, max (h * 2) _oh)
.Would such a function be possible? You can pick whatever implementation you want of course, the above is just an example.