fit
fun Rectangle.fit(dest: Rectangle, horizontalPosition: Double = 0.0, verticalPosition: Double = 0.0, fitMethod: FitMethod = FitMethod.Cover): Matrix44(source)
Helper function that calls fitRectangle and returns a Matrix44 instead of a Pair<Rectangle, Rectangle>
. The returned matrix can be used to draw scaled Shape
or ShapeContour
objects.
Example scaling and centering a collection of ShapeContours inside drawer.bounds
leaving a margin of 50 pixels:
val src = shapeContours.map { it.bounds }.bounds val dest = drawer.bounds.offsetEdges(-50.0) val mat = src.fit(dest, fitMethod = FitMethod.Contain) drawer.view *= mat drawer.contours(shapeContours)