GMImage.DrawRoundRectangle
--------------------------

Draw a rounded rectangle.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [GraphicsMagick](component_GraphicsMagick.md) | [3.0](newinversion30.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "GMImage.DrawRoundRectangle"; ImageRef; upperLeftX; upperLeftY; lowerRightX; lowerRightY { ; cornerWidth; cornerHeight } ) 

**MBS**( **"GMImage.DrawRoundRectangle";** /\* Draw a rounded rectangle. \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$upperLeftX**; /\* Upper left X position. \*/   
**$upperLeftY**; /\* Upper left Y position. \*/   
**$lowerRightX**; /\* Lower right X position. \*/   
**$lowerRightY**; /\* Lower right Y position. \*/   
**$cornerWidth**; /\* Optional; The width of the corner arc. \*/   
**$cornerHeight**) /\* Optional; The height of the corner arc. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| ImageRef | The image reference number. | 1 |  |
| upperLeftX | Upper left X position. |  |  |
| upperLeftY | Upper left Y position. |  |  |
| lowerRightX | Lower right X position. |  |  |
| lowerRightY | Lower right Y position. |  |  |
| cornerWidth | The width of the corner arc. |  | Optional |
| cornerHeight | The height of the corner arc. |  | Optional |

### Result

Returns OK or error message.

### Description

Draw a rounded rectangle.  
Draw a rounded rectangle using stroke color and thickness, with specified top left and right bottom coordinates, and specified corner width and height. If a fill color is specified, then the object is filled.  
You can set fill color to transparent to not draw it.  
  
If you have an open path, the command is added there for later drawing with [GMImage.DrawPath](GMImageDrawPath.md).  
### Examples

Creates a new image and draws a round rectangle inside:

 Set Variable \[ $img ; Value:MBS ("[GMImage.New](GMImageNew.md)"; "300x200"; "RGB 1 1 1") \]  
Set Variable \[ $r ; Value:MBS ("[GMImage.SetStrokeColor](GMImageSetStrokeColor.md)"; $img ; "RGB 1 0 0") \]  
Set Variable \[ $r ; Value:MBS ("[GMImage.SetFillColor](GMImageSetFillColor.md)"; $img ; "RGB 0 0 1") \]  
Set Variable \[ $r ; Value:MBS ("[GMImage.SetLineWidth](GMImageSetLineWidth.md)"; $img ; 5) \]  
Set Variable \[ $r ; Value:MBS ("GMImage.DrawRoundRectangle"; $img ; 50; 50; 250; 150; 10; 10) \]   
Set Variable \[ $png ; Value:MBS ("[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $img ; "test.png") \]  
Set Variable \[ $r ; Value:MBS ("[GMImage.Release](GMImageRelease.md)"; $img ) \]   
Set Field \[ Drawing::Image ; $png \]  
Use one picture as pattern to draw round rectangle:

 # Load big picture   
Set Variable \[ $BigImageRef ; Value: MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; Combine Pictures::BigImage ) \]   
\# load pattern picture   
Set Variable \[ $SmallImageRef ; Value: MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; Combine Pictures::SmallImage ) \]   
\# Draw a rectangle using small image as pattern   
Set Variable \[ $Error ; Value: MBS ( "[GMImage.FillPattern](GMImageFillPattern.md)"; $BigImageRef ; $SmallImageRef ) \]   
Set Variable \[ $Error ; Value: MBS ( "GMImage.DrawRoundRectangle"; $BigImageRef ; 100; 100; 300; 300; 20; 20) \]   
\# Write to container and free references   
Set Field \[ Combine Pictures::Result ; MBS ( "[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $BigImageRef ) \]   
Set Variable \[ $Error ; Value: MBS ("[GMImage.Free](GMImageFree.md)";$BigImageRef ) \]   
Set Variable \[ $Error ; Value: MBS ("[GMImage.Free](GMImageFree.md)";$SmallImageRef ) \]  
Creates a transparent round rectangle on a transparent background

 # create environment   
Set Variable \[ $img ; Value: MBS ("[GMImage.New](GMImageNew.md)"; "300x200"; "white") \]   
Set Variable \[ $r ; Value: MBS ("[GMImage.SetType](GMImageSetType.md)"; $img ; 7) // RGBA image \]   
\# clear pixels   
Set Variable \[ $r ; Value: MBS ( "[GMImage.SetBackgroundColor](GMImageSetBackgroundColor.md)"; $img ; "transparent") \]   
Set Variable \[ $r ; Value: MBS ( "[GMImage.Erase](GMImageErase.md)"; $img ) \]   
\# Define the settings for the RoundRectangle   
Set Variable \[ $r ; Value: MBS ("[GMImage.SetStrokeColor](GMImageSetStrokeColor.md)"; $img ; "RGB 1 0 0") \]   
Set Variable \[ $r ; Value: MBS ("[GMImage.SetFillColor](GMImageSetFillColor.md)"; $img ; "transparent") \]   
Set Variable \[ $r ; Value: MBS ("[GMImage.SetLineWidth](GMImageSetLineWidth.md)"; $img ; 5) \]   
\# draw in enviroment   
Set Variable \[ $r ; Value: MBS ("GMImage.DrawRoundRectangle"; $img ; 50; 50; 250; 150; 10; 10) \]   
\# write image to container   
Set Variable \[ $png ; Value: MBS ("[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $img ; "test.png") \]   
\# Release enviroment   
Set Variable \[ $r ; Value: MBS ("[GMImage.Free](GMImageFree.md)"; $img ) \]   
Set Field \[ Drawing::Image ; $png \]  
### See also

- [GMImage.Erase](GMImageErase.md)
- [GMImage.FillPattern](GMImageFillPattern.md)
- [GMImage.Free](GMImageFree.md)
- [GMImage.NewFromContainer](GMImageNewFromContainer.md)
- [GMImage.Release](GMImageRelease.md)
- [GMImage.SetBackgroundColor](GMImageSetBackgroundColor.md)
- [GMImage.SetFillColor](GMImageSetFillColor.md)
- [GMImage.SetLineWidth](GMImageSetLineWidth.md)
- [GMImage.SetStrokeColor](GMImageSetStrokeColor.md)
- [GMImage.SetType](GMImageSetType.md)

### Example Databases

- [Barcode/Barcode Generation JSON](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Barcode/Barcode%20Generation%20JSON.shtml#9ScriptAnchor_)
- [GraphicsMagick/Combine Pictures](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Combine%20Pictures.shtml#3ScriptAnchor_)
- [GraphicsMagick/Drawing](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Drawing.shtml#7ScriptAnchor_)
- [Overlay](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Overlay.shtml#4ScriptAnchor_)

### Blog Entries

- [GraphicsMagick in FileMaker, part 20](https://www.mbsplugins.de/archive/2022-12-20/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 4th September 2025

  
[GMImage.DrawRectangle](GMImageDrawRectangle.md) - [GMImage.Edge](GMImageEdge.md)

[HTML Version](GMImageDrawRoundRectangle.shtml)