add new DrawBitmap overload to Canvas

This commit is contained in:
scawful
2022-09-08 09:18:05 -05:00
parent 3cacfce411
commit cf2a10f0d9
2 changed files with 9 additions and 0 deletions

View File

@@ -78,6 +78,13 @@ void Canvas::DrawBitmap(const Bitmap &bitmap, int border_offset) {
canvas_p0_.y + (bitmap.GetHeight() * 2)));
}
void Canvas::DrawBitmap(const Bitmap &bitmap, int x_offset, int y_offset) {
draw_list_->AddImage((void *)bitmap.GetTexture(),
ImVec2(canvas_p0_.x + x_offset, canvas_p0_.y + y_offset),
ImVec2(canvas_p0_.x + x_offset + (bitmap.GetWidth()),
canvas_p0_.y + y_offset + (bitmap.GetHeight())));
}
void Canvas::DrawGrid(float grid_step) {
// Draw grid + all lines in the canvas
draw_list_->PushClipRect(canvas_p0_, canvas_p1_, true);

View File

@@ -22,6 +22,8 @@ class Canvas {
void DrawBackground(ImVec2 canvas_size = ImVec2(0, 0));
void DrawContextMenu();
void DrawBitmap(const Bitmap& bitmap, int border_offset = 0);
void DrawBitmap(const Bitmap& bitmap, int x_offset, int y_offset);
// void DrawLargeBitmap(const Bitmap& tl, const Bitmap& tr, const Bitmap& bl, const Bitmap& br);
void DrawGrid(float grid_step = 64.0f);
void DrawOverlay(); // last