constrainPathToRect

Typehandler
Dictionarylibrary.widgetutils
LibraryWidget Utilities
Syntax
constrainPathToRect(<pTargetRect>,<xPath>)
Associationscom.livecode.library.widgetutils
Summary

Scales and translates a path to fit within a rectangle

Parameters
NameTypeDescription
pTargetRect

The rectangle to fit the path within

xPath

The path to transform

Example
use com.livecode.library.iconsvg

public handler OnPaint() returns nothing
	-- get the 'shopping cart' icon from the icon library
	variable tPathString as String
 	put iconSVGPathFromName("shopping cart") into tPathString

	-- create the path
	variable tPath as Path
	put path tPathString into tPath

	-- scale the path to fit within the bounds of the widget
	constrainPathToRect(my bounds, tPath)

	-- fill the path
	fill tPath on this canvas
end handler
Description

Scales and transforms xPath so that it fits within pTargetRect whilst maintaining its aspect ratio.