Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

GMImage.DrawRoundRectangle

Draw a rounded rectangle.

Component Version macOS Windows Linux Server iOS SDK
GraphicsMagick 3.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "GMImage.DrawRoundRectangle"; ImageRef; upperLeftX; upperLeftY; lowerRightX; lowerRightY { ; cornerWidth; cornerHeight } )   More

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.

Examples

Creates a new image and draws a round rectangle inside:

Set Variable [ $img; Wert:MBS("GMImage.New"; "300x200"; "RGB 1 1 1") ]
Set Variable [ $r; Wert:MBS("GMImage.SetStrokeColor"; $img; "RGB 1 0 0") ]
Set Variable [ $r; Wert:MBS("GMImage.SetFillColor"; $img; "RGB 0 0 1") ]
Set Variable [ $r; Wert:MBS("GMImage.SetLineWidth"; $img; 5) ]
Set Variable [ $r; Wert:MBS("GMImage.DrawRoundRectangle"; $img; 50; 50; 250; 150; 10; 10) ]
Set Variable [ $png; Wert:MBS("GMImage.WriteToPNGContainer"; $img; "test.png") ]
Set Variable [ $r; Wert:MBS("GMImage.Release"; $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"; Combine Pictures::BigImage) ]
# load pattern picture
Set Variable [ $SmallImageRef ; Value: MBS("GMImage.NewFromContainer"; Combine Pictures::SmallImage) ]
# Draw a rectangle using small image as pattern
Set Variable [ $Error ; Value: MBS( "GMImage.FillPattern"; $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"; $BigImageRef ) ]
Set Variable [ $Error ; Value: MBS("GMImage.Free";$BigImageRef) ]
Set Variable [ $Error ; Value: MBS("GMImage.Free";$SmallImageRef) ]

Creates a transparent round rectangle on a transparent background

# create environment
Set Variable [ $img ; Value: MBS("GMImage.New"; "300x200"; "white") ]
Set Variable [ $r ; Value: MBS("GMImage.SetType"; $img; 7) // RGBA image ]
# clear pixels
Set Variable [ $r ; Value: MBS( "GMImage.SetBackgroundColor"; $img; "transparent") ]
Set Variable [ $r ; Value: MBS( "GMImage.Erase"; $img) ]
# Define the settings for the RoundRectangle
Set Variable [ $r ; Value: MBS("GMImage.SetStrokeColor"; $img; "RGB 1 0 0") ]
Set Variable [ $r ; Value: MBS("GMImage.SetFillColor"; $img; "transparent") ]
Set Variable [ $r ; Value: MBS("GMImage.SetLineWidth"; $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"; $img; "test.png") ]
# Release enviroment
Set Variable [ $r ; Value: MBS("GMImage.Free"; $img) ]
Set Field [ Drawing::Image ; $png ]

See also

Example Databases

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 24th January 2024


GMImage.DrawRectangle - GMImage.Edge