From cc766b6db1b52be4bc872e2c9121dc1fd2c18aa4 Mon Sep 17 00:00:00 2001 From: Ricardo Matias Date: Tue, 2 Feb 2021 12:05:30 +0100 Subject: [PATCH] [orx-image-fit] Add new signature do imageFit (#166) --- orx-image-fit/src/main/kotlin/ImageFit.kt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/orx-image-fit/src/main/kotlin/ImageFit.kt b/orx-image-fit/src/main/kotlin/ImageFit.kt index 28b2fefd..414cfbf3 100644 --- a/orx-image-fit/src/main/kotlin/ImageFit.kt +++ b/orx-image-fit/src/main/kotlin/ImageFit.kt @@ -2,6 +2,7 @@ package org.openrndr.extras.imageFit import org.openrndr.draw.ColorBuffer import org.openrndr.draw.Drawer +import org.openrndr.math.Vector2 import org.openrndr.math.map import org.openrndr.shape.Rectangle @@ -108,6 +109,25 @@ fun Drawer.imageFit( fitMethod ) + image(img, source, target) + return Pair(source, target) +} + +fun Drawer.imageFit( + img: ColorBuffer, + bounds: Rectangle = Rectangle(Vector2.ZERO, img.width * 1.0, img.height * 1.0), + horizontalPosition: Double = 0.0, + verticalPosition: Double = 0.0, + fitMethod: FitMethod = FitMethod.Cover +): Pair { + val (source, target) = fitRectangle( + img.bounds, + bounds, + horizontalPosition, + verticalPosition, + fitMethod + ) + image(img, source, target) return Pair(source, target) } \ No newline at end of file