Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4   7.5    Statistic  

GMImage.DrawRectangle

Draws a rectangle.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
GraphicsMagick 3.0 Yes Yes Yes Yes Yes

MBS( "GMImage.DrawRectangle"; ImageRef; upperLeftX; upperLeftY; lowerRightX; lowerRightY )

Parameters

Parameter Description Example value
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.

Result

Returns OK or error message.

Description

Draws a rectangle.
Draw a rectangle using stroke color and thickness from upper-left coordinates to lower-right coordinates.
If a fill color is specified, then the object is filled.

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 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.DrawRectangle"; $img; 50; 50; 250; 150) ]
Set Variable [ $png; Wert:MBS("GMImage.WriteToPNGContainer"; $img; "test.png") ]
Set Variable [ $r; Wert:MBS("GMImage.Destroy"; $img) ]
Set Field [ Drawing::Image; $png ]

Draws a cirlce in a rectangle in a circle:

Set Variable [$img; Value:MBS( "GMImage.New"; "100x100"; "COLOR 255 255 255" )]
Set Variable [$r; Value:MBS( "GMImage.SetFillColor"; $img; "RGB 1 0 0" )]
Set Variable [$r; Value:MBS( "GMImage.SetStrokeColor"; $img; "RGB 0 0 1" )]
Set Variable [$r; Value:MBS( "GMImage.DrawCircle"; $img; 50; 50; 50; 90 )]
Set Variable [$r; Value:MBS( "GMImage.DrawRectangle"; $img; 22; 22; 100-22; 100-22 )]
Set Variable [$r; Value:MBS( "GMImage.DrawCircle"; $img; 50; 50; 50; 100-22 )]
Set Field [test::test; MBS( "GMImage.WriteToPNGContainer"; $img; "test.png" )]
Set Variable [$r; Value:MBS( "GMImage.Destroy"; $img)]

Draw something and write to file on desktop:

# New Image
Set Variable [$img; Value:MBS("GMImage.New"; "300x200"; "RGB 1 1 1")]
# Set colors and line width
Set Variable [$r; Value:MBS("GMImage.SetStrokeColor"; $img; "RGB 1 0 0")]
Set Variable [$r; Value:MBS("GMImage.SetFillColor"; $img; "RGB 0 0 1")]
Set Variable [$r; Value:MBS("GMImage.SetLineWidth"; $img; 5)]
# draw a rectangle
Set Variable [$r; Value:MBS("GMImage.DrawRectangle"; $img; 50; 50; 250; 150)]
# save to test.png on desktop:
Set Variable [$DesktopPath; Value:MBS( "Folders.UserDesktop" )]
Set Variable [$path; Value:MBS( "Path.AddPathComponent"; $DesktopPath; "test.png")]
Set Variable [$r; Value:MBS("GMImage.WriteToFile"; $img; $path)]
# cleanup
Set Variable [$r; Value:MBS("GMImage.Destroy"; $img)]

See also

Example Databases


GMImage.DrawPath   -   GMImage.DrawRoundRectangle

Feedback: Report problem or ask question.




Links
MBS FileMaker tutorial videos