mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 21:13:23 -07:00
BUG-1681 (3) avoid bad rendering of rounded corners which occurred due to calculation error when determining border radius
This commit is contained in:
parent
7fd0ce5037
commit
dfd5e2de19
1 changed files with 12 additions and 13 deletions
|
@ -131,20 +131,19 @@ namespace Greenshot.Drawing {
|
||||||
int tailWidth = (Math.Abs(rect.Width) + Math.Abs(rect.Height)) / 20;
|
int tailWidth = (Math.Abs(rect.Width) + Math.Abs(rect.Height)) / 20;
|
||||||
|
|
||||||
GraphicsPath bubble = new GraphicsPath();
|
GraphicsPath bubble = new GraphicsPath();
|
||||||
|
|
||||||
|
Rectangle bubbleRect = GuiRectangle.GetGuiRectangle(0, 0, rect.Width, rect.Height);
|
||||||
// adapt corner radius to small rectangle dimensions
|
// adapt corner radius to small rectangle dimensions
|
||||||
int smallerSideLength = Math.Min(rect.Width, rect.Height);
|
int smallerSideLength = Math.Min(bubbleRect.Width, bubbleRect.Height);
|
||||||
int cornerRadius = smallerSideLength>60 ? 30 : smallerSideLength/2;
|
int cornerRadius = Math.Min(30, smallerSideLength / 2 - lineThickness);
|
||||||
if (cornerRadius > 5) {
|
if (cornerRadius > 0) {
|
||||||
Rectangle bubbleRect = GuiRectangle.GetGuiRectangle(0, 0, rect.Width, rect.Height);
|
bubble.AddArc(bubbleRect.X, bubbleRect.Y, cornerRadius, cornerRadius, 180, 90);
|
||||||
bubbleRect = Rectangle.Inflate(bubbleRect, -lineThickness, -lineThickness);
|
bubble.AddArc(bubbleRect.X + bubbleRect.Width - cornerRadius, bubbleRect.Y, cornerRadius, cornerRadius, 270, 90);
|
||||||
bubble.AddArc(bubbleRect.X, bubbleRect.Y, cornerRadius, cornerRadius, 180, 90);
|
bubble.AddArc(bubbleRect.X + bubbleRect.Width - cornerRadius, bubbleRect.Y + bubbleRect.Height - cornerRadius, cornerRadius, cornerRadius, 0, 90);
|
||||||
bubble.AddArc(bubbleRect.X + bubbleRect.Width - cornerRadius, bubbleRect.Y, cornerRadius, cornerRadius, 270, 90);
|
bubble.AddArc(bubbleRect.X, bubbleRect.Y + bubbleRect.Height - cornerRadius, cornerRadius, cornerRadius, 90, 90);
|
||||||
bubble.AddArc(bubbleRect.X + bubbleRect.Width - cornerRadius, bubbleRect.Y + bubbleRect.Height - cornerRadius, cornerRadius, cornerRadius, 0, 90);
|
} else {
|
||||||
bubble.AddArc(bubbleRect.X, bubbleRect.Y + bubbleRect.Height - cornerRadius, cornerRadius, cornerRadius, 90, 90);
|
bubble.AddRectangle(bubbleRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
//bubble.AddRectangle(GuiRectangle.GetGuiRectangle(0, 0, rect.Width, rect.Height));
|
|
||||||
//bubble.AddEllipse(0, 0, Math.Abs(rect.Width), Math.Abs(rect.Height));
|
|
||||||
bubble.CloseAllFigures();
|
bubble.CloseAllFigures();
|
||||||
|
|
||||||
GraphicsPath tail = new GraphicsPath();
|
GraphicsPath tail = new GraphicsPath();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue