Delphi draw a closed rectangle with two rounded corners and to rectangular corners

user2383818

How can I draw a rectangle that has two round corners and the opposite corners are rectangular corners. The shape must be closed so it can be filled with the Brush color. The Polyline method doesn't draw curved lines. Can I add the points of an Arc to the polyline points? I tried to draw a RoundRect using Canvas method and then, overlapping a rectangle over the lower round corners, but I couldn't figure out how to erase the upper line of the rectangle when drawign just the border of the shape without filling it. Note: if you think is relevant, I can add the code I used.

Sample of the desired shape:

enter image description here

Sample of what I got with Delphi:

enter image description here

Remy Lebeau

You don't have to fill the shape at the same time you draw it. You can use a series of TCanvas.LineTo() and TCanvas.ArcTo()/TCanvas.AngleArc() calls first to create the shape, then call TCanvas.FloodFill() afterwards to fill it.

Otherwise, you can overlap TCanvas.Rectangle() on top of TCanvas.RoundRect() with the same fill color, and then use TCanvas.MoveTo()/TCanvas.LineTo() to draw over the dividing line with the same fill color.

Another option would be to forget using TCanvas drawing methods and just use Win32 API calls instead. Use CreateRoundRectRgn(), CreateRectRgn(), and CombineRn() to create a HRGN that has your desired shape, then use FillRgn() and FrameRgn() to draw on your TCanvas using that HRGN.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to draw a rectangle with rounded corners using XML?

Css - Draw rectangle with rounded corners as background

Create a rectangle with just two rounded corners in swift?

javafx rounded rectangle corners

Rectangle spinner with rounded corners

How to rounded the corners when I draw rectangle using UIBezierPath points

Using bezier curves to draw a rectangle with rounded corners in PyMuPDF

How to draw text on a rectangle with rounded corners using ffmpeg?

Draw label as a rectangle with edges rather than with rounded corners

GLSL Rounded Rectangle Corners Are Stretched

Responsive rectangle with responsively rounded corners

How to draw an arc with rounded corners?

How to draw a path with rounded corners

Rounded corners on rectangular image using CSS only

Transparency issues drawing a rectangle with rounded corners

How to make a tkinter canvas rectangle with rounded corners?

How to make a rectangle with inverted rounded corners?

Create a Flutter TextFormField with two corners rounded and two straight cut corners

Drawing a rectangle with only two rounded corners using Bezier Path and Storyboarding in Swift 2.3

individual rounded corners (NOT all corners)

How to draw a simple rounded rect in swift (rounded corners)

Java - Only Two Rounded Corners on a JFrame

Swift 4 - imageview with two rounded corners in swift?

Border with inverted rectangular corners

How to calculate distance of between two rectangle corners

How to create a rectangle with rounded corners with different sections in different colors

Android's elevation not working with different rounded-corners rectangle

How do I create a layer that is a rectangle with rounded corners?

Xamarin iOS CGPath draw polygon with curved/rounded corners