2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2022-02-28 19:21:12 -07:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2018-10-12 12:49:45 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Size.h"
|
2019-06-21 18:58:45 +02:00
|
|
|
#include <AK/RefCounted.h>
|
2020-02-06 11:56:38 +01:00
|
|
|
#include <AK/RefPtr.h>
|
2022-02-28 19:21:12 -07:00
|
|
|
#include <AK/StringView.h>
|
2020-02-06 11:56:38 +01:00
|
|
|
|
|
|
|
|
namespace Gfx {
|
2018-10-12 12:49:45 +02:00
|
|
|
|
2022-02-28 19:21:12 -07:00
|
|
|
class CharacterBitmap {
|
2018-10-12 12:49:45 +02:00
|
|
|
public:
|
2022-02-28 19:21:12 -07:00
|
|
|
CharacterBitmap() = delete;
|
|
|
|
|
constexpr CharacterBitmap(StringView ascii_data, unsigned width, unsigned height)
|
|
|
|
|
: m_bits(ascii_data)
|
|
|
|
|
, m_size(width, height)
|
|
|
|
|
{
|
|
|
|
|
}
|
2018-10-12 12:49:45 +02:00
|
|
|
|
2022-02-28 19:21:12 -07:00
|
|
|
constexpr ~CharacterBitmap() = default;
|
2018-10-12 12:49:45 +02:00
|
|
|
|
2022-02-28 19:21:12 -07:00
|
|
|
constexpr bool bit_at(unsigned x, unsigned y) const { return m_bits[y * width() + x] == '#'; }
|
|
|
|
|
constexpr StringView bits() const { return m_bits; }
|
2018-10-12 12:49:45 +02:00
|
|
|
|
2022-02-28 19:21:12 -07:00
|
|
|
constexpr IntSize size() const { return m_size; }
|
|
|
|
|
constexpr unsigned width() const { return m_size.width(); }
|
|
|
|
|
constexpr unsigned height() const { return m_size.height(); }
|
2018-10-12 12:49:45 +02:00
|
|
|
|
2022-02-28 19:21:12 -07:00
|
|
|
private:
|
|
|
|
|
StringView m_bits {};
|
|
|
|
|
IntSize m_size {};
|
2018-10-12 12:49:45 +02:00
|
|
|
};
|
2020-02-06 11:56:38 +01:00
|
|
|
|
|
|
|
|
}
|