Skip to content

Update Drawing.cpp #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion GUI/Graphics/Drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,38 @@ void FilledRoundedRectangle(const int& x, const int& y, const int& width, const
RenderTarget->FillRoundedRectangle(roundedRect, Brush);
}

void OutlineCorneredRectangle(const int& x, const int& y, const int& width, const int& height, const int& linewidth, MyColour colour)
{
RenderTarget->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
Brush->SetColor(colour.Get());
Brush->SetOpacity(colour.a);

float lineW = static_cast<float>(width) / 3.0f;
float lineH = static_cast<float>(height) / 3.0f;

struct Corner {
float startX, startY, endX, endY;
};

Corner corners[] = {
{ x, y, x, y + lineH},
{ x, y, x + lineW, y},
{ x + width - lineW, y, x + width, y},
{ x + width, y, x + width, y + lineH},
{ x, y + height - lineH, x, y + height},
{ x, y + height, x + lineW, y + height},
{ x + width - lineW, y + height, x + width, y + height},
{ x + width, y + height - lineH, x + width, y + height}
};

for (const auto& corner : corners)
{
D2D1_POINT_2F start = { corner.startX, corner.startY };
D2D1_POINT_2F finish = { corner.endX, corner.endY };
RenderTarget->DrawLine(start, finish, Brush, linewidth);
}
}

void FilledLine(const int& xstart, const int& ystart, const int& xend, const int& yend, const int& width, MyColour colour)
{
RenderTarget->SetAntialiasMode(D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
Expand Down Expand Up @@ -514,4 +546,4 @@ void CreateDirectXBitmap(const std::wstring& filename, ID2D1Bitmap** bmp)
wicDecoder->Release();
WicConverter->Release();
WicFrame->Release();
}
}