[orx-image-fit] Add imageFitSub function
Introduce the `imageFitSub` function, enabling subsections of images to be drawn with fit and alignment capabilities. Added a demo showcasing its usage with grid-based rendering and updated dependencies with `orx-noise` for randomness support.
This commit is contained in:
28
orx-image-fit/src/jvmDemo/kotlin/DemoImageFitSub01.kt
Normal file
28
orx-image-fit/src/jvmDemo/kotlin/DemoImageFitSub01.kt
Normal file
@@ -0,0 +1,28 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.draw.loadImage
|
||||
import org.openrndr.extra.imageFit.imageFitSub
|
||||
|
||||
import org.openrndr.extra.noise.shapes.uniformSub
|
||||
import org.openrndr.extra.shapes.primitives.grid
|
||||
import kotlin.random.Random
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val image = loadImage("demo-data/images/image-001.png")
|
||||
extend {
|
||||
val grid = drawer.bounds.grid(5, 5).flatten()
|
||||
val r = Random(seconds.toInt())
|
||||
for (cell in grid) {
|
||||
drawer.imageFitSub(
|
||||
image,
|
||||
image.bounds.uniformSub(0.25, 0.75, 0.25, 0.75, random = r),
|
||||
cell
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user