summaryrefslogtreecommitdiff
path: root/libraries/daguerre
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2024-07-29 21:26:17 -0400
committerBenji Dial <benji@benjidial.net>2024-07-29 21:26:17 -0400
commitc34b9191f258ddc15c5b45c000cd0266aed9dead (patch)
tree88e66004d1514d6f22b4366fc415b467784fee63 /libraries/daguerre
parente6c3a80b01ffb52079783cddd9be6d392d0f7039 (diff)
downloadhilbert-os-c34b9191f258ddc15c5b45c000cd0266aed9dead.tar.gz
window borders
Diffstat (limited to 'libraries/daguerre')
-rw-r--r--libraries/daguerre/include/daguerre/image.hpp7
-rw-r--r--libraries/daguerre/include/daguerre/impl/fixed-font.hpp1
-rw-r--r--libraries/daguerre/include/daguerre/impl/image.hpp20
3 files changed, 26 insertions, 2 deletions
diff --git a/libraries/daguerre/include/daguerre/image.hpp b/libraries/daguerre/include/daguerre/image.hpp
index a55f43b..3c9c902 100644
--- a/libraries/daguerre/include/daguerre/image.hpp
+++ b/libraries/daguerre/include/daguerre/image.hpp
@@ -110,6 +110,13 @@ namespace daguerre {
param_converter_t<color_t, font_color_t, param_t> *conversion =
&default_conversion);
+ //does not check bounds or wrap text
+ template <class font_color_t>
+ void render_text(
+ const fixed_font<font_color_t> &font, int x, int y, const char *text,
+ converter_t<color_t, font_color_t> *conversion =
+ &default_conversion);
+
};
template <class color_t>
diff --git a/libraries/daguerre/include/daguerre/impl/fixed-font.hpp b/libraries/daguerre/include/daguerre/impl/fixed-font.hpp
index 1a5f3d8..61a27fc 100644
--- a/libraries/daguerre/include/daguerre/impl/fixed-font.hpp
+++ b/libraries/daguerre/include/daguerre/impl/fixed-font.hpp
@@ -35,6 +35,7 @@ namespace daguerre {
glyphs[i] = std::move(other.glyphs[i]);
other.glyph_width = 0;
other.glyph_height = 0;
+ return *this;
}
template <class color_t>
diff --git a/libraries/daguerre/include/daguerre/impl/image.hpp b/libraries/daguerre/include/daguerre/impl/image.hpp
index 6cf2ca9..c91cc7d 100644
--- a/libraries/daguerre/include/daguerre/impl/image.hpp
+++ b/libraries/daguerre/include/daguerre/impl/image.hpp
@@ -107,7 +107,7 @@ namespace daguerre {
void image<color_t>::fill(
const color_t &color, int start_x, int start_y, int width, int height) {
for (int y = start_y; y < start_y + height; ++y)
- for (int x = 0; x < start_x + width; ++x)
+ for (int x = start_x; x < start_x + width; ++x)
buffer[y * buffer_pitch + x] = color;
}
@@ -170,7 +170,7 @@ namespace daguerre {
void image<color_t>::convert_from(
const image<other_color_t> &other, int to_x, int to_y,
converter_t<color_t, other_color_t> *conversion) {
- convert_from(other, to_x, to_y, 0, 0, other.width, other.y, conversion);
+ convert_from(other, to_x, to_y, 0, 0, other.width, other.height, conversion);
}
template <class color_t>
@@ -214,6 +214,22 @@ namespace daguerre {
}
template <class color_t>
+ template <class font_color_t>
+ void image<color_t>::render_text(
+ const fixed_font<font_color_t> &font, int x, int y, const char *text,
+ converter_t<color_t, font_color_t> *conversion) {
+
+ while (*text) {
+ int ch = *text;
+ if (ch >= 0 && ch < 128)
+ convert_from(font.glyphs[ch], x, y, conversion);
+ ++text;
+ x += font.glyph_width;
+ }
+
+ }
+
+ template <class color_t>
void swap(image<color_t> &a, image<color_t> &b) {
std::swap(a.delete_buffer_on_destruct, b.delete_buffer_on_destruct);
std::swap(a.width, b.width);