Skip to content

Commit

Permalink
[orx-image-fit] Add new signature do imageFit (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardomatias authored Feb 2, 2021
1 parent f5ab40a commit cc766b6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions orx-image-fit/src/main/kotlin/ImageFit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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<Rectangle, Rectangle> {
val (source, target) = fitRectangle(
img.bounds,
bounds,
horizontalPosition,
verticalPosition,
fitMethod
)

image(img, source, target)
return Pair(source, target)
}

0 comments on commit cc766b6

Please sign in to comment.