CardPainter.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Array.h>
  8. #include <LibCards/Card.h>
  9. #include <LibGfx/Bitmap.h>
  10. #include <LibGfx/Color.h>
  11. namespace Cards {
  12. class CardPainter {
  13. public:
  14. static CardPainter& the();
  15. NonnullRefPtr<Gfx::Bitmap> card_front(Suit, Rank);
  16. NonnullRefPtr<Gfx::Bitmap> card_back();
  17. NonnullRefPtr<Gfx::Bitmap> card_front_inverted(Suit, Rank);
  18. NonnullRefPtr<Gfx::Bitmap> card_back_inverted();
  19. NonnullRefPtr<Gfx::Bitmap> card_front_highlighted(Suit, Rank);
  20. void set_background_image_path(DeprecatedString path);
  21. void set_background_color(Color);
  22. private:
  23. CardPainter();
  24. NonnullRefPtr<Gfx::Bitmap> create_card_bitmap();
  25. void paint_card_front(Gfx::Bitmap&, Suit, Rank);
  26. void paint_card_back(Gfx::Bitmap&);
  27. void paint_inverted_card(Gfx::Bitmap& bitmap, Gfx::Bitmap const& source_to_invert);
  28. void paint_highlighted_card(Gfx::Bitmap& bitmap, Gfx::Bitmap const& source_to_highlight);
  29. Array<Array<RefPtr<Gfx::Bitmap>, to_underlying(Rank::__Count)>, to_underlying(Suit::__Count)> m_cards;
  30. Array<Array<RefPtr<Gfx::Bitmap>, to_underlying(Rank::__Count)>, to_underlying(Suit::__Count)> m_cards_inverted;
  31. Array<Array<RefPtr<Gfx::Bitmap>, to_underlying(Rank::__Count)>, to_underlying(Suit::__Count)> m_cards_highlighted;
  32. RefPtr<Gfx::Bitmap> m_card_back;
  33. RefPtr<Gfx::Bitmap> m_card_back_inverted;
  34. DeprecatedString m_background_image_path;
  35. Color m_background_color;
  36. };
  37. }