From 701f14400ab1c480ed1e4133035bd6b1e21c0bc7 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Sun, 22 Aug 2021 15:44:40 +0200 Subject: [PATCH] Fix demos, upgrade to Gradle 7.2 --- gradle/wrapper/gradle-wrapper.properties | 2 +- .../src/demo/kotlin/DemoCatmullRom01.kt | 4 ++-- orx-color/build.gradle.kts | 23 ++++++++++++------- .../commonMain/kotlin/statistics/Histogram.kt | 4 +++- .../{ => kotlin}/src/statistics/Histogram.kt | 6 +++++ .../orx-olive/src/demo/kotlin/DemoOlive01.kt | 3 ++- orx-noise/src/commonMain/kotlin/Functions.kt | 17 ++++++-------- .../kotlin/DemoFunctionalComposition01.kt | 6 +++++ orx-quadtree/build.gradle.kts | 1 + .../src/demo/kotlin/DemoQuadTree02.kt | 2 +- orx-shade-styles/build.gradle.kts | 2 +- 11 files changed, 45 insertions(+), 25 deletions(-) rename orx-color/src/jvmMain/{ => kotlin}/src/statistics/Histogram.kt (94%) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 69a97150..ffed3a25 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/openrndr-demos/src/demo/kotlin/DemoCatmullRom01.kt b/openrndr-demos/src/demo/kotlin/DemoCatmullRom01.kt index 0a9b8fc3..441f3eb7 100644 --- a/openrndr-demos/src/demo/kotlin/DemoCatmullRom01.kt +++ b/openrndr-demos/src/demo/kotlin/DemoCatmullRom01.kt @@ -2,7 +2,7 @@ import org.openrndr.application import org.openrndr.color.ColorRGBa -import org.openrndr.math.CatmullRomChain2 +import org.openrndr.math.CatmulRomChain2 import org.openrndr.math.Polar import org.openrndr.shape.ShapeContour import org.openrndr.shape.toContour @@ -10,7 +10,7 @@ import org.openrndr.shape.toContour suspend fun main() = application { program { val points = List(6) { Polar(it * 70.0, 100.0).cartesian + drawer.bounds.center } - val cmr = CatmullRomChain2(points, 1.0, loop = true) + val cmr = CatmulRomChain2(points, 1.0, loop = true) val contour = ShapeContour.fromPoints(cmr.positions(200), true) extend { diff --git a/orx-color/build.gradle.kts b/orx-color/build.gradle.kts index 6e6dff4c..bba4c390 100644 --- a/orx-color/build.gradle.kts +++ b/orx-color/build.gradle.kts @@ -24,14 +24,17 @@ kotlin { val demo by creating { defaultSourceSet { kotlin.srcDir("src/demo") - dependencies { - implementation(project(":orx-camera")) - implementation("org.openrndr:openrndr-application:$openrndrVersion") - implementation("org.openrndr:openrndr-extensions:$openrndrVersion") - runtimeOnly("org.openrndr:openrndr-gl3:$openrndrVersion") - runtimeOnly("org.openrndr:openrndr-gl3-natives-$openrndrOS:$openrndrVersion") - implementation(compilations["main"]!!.output.allOutputs) - } + } + dependencies { + implementation(project(":orx-camera")) + implementation(project(":orx-mesh-generators")) + implementation(project(":orx-color")) + + implementation("org.openrndr:openrndr-application:$openrndrVersion") + implementation("org.openrndr:openrndr-extensions:$openrndrVersion") + runtimeOnly("org.openrndr:openrndr-gl3:$openrndrVersion") + runtimeOnly("org.openrndr:openrndr-gl3-natives-$openrndrOS:$openrndrVersion") + implementation(compilations["main"]!!.output.allOutputs) } } } @@ -62,6 +65,7 @@ kotlin { implementation("io.github.microutils:kotlin-logging:$kotlinLoggingVersion") } } + @Suppress("UNUSED_VARIABLE") val commonTest by getting { dependencies { @@ -72,6 +76,9 @@ kotlin { } } + val jvmMain by getting {} + + @Suppress("UNUSED_VARIABLE") val jvmTest by getting { dependencies { diff --git a/orx-color/src/commonMain/kotlin/statistics/Histogram.kt b/orx-color/src/commonMain/kotlin/statistics/Histogram.kt index fb363b01..a15bebde 100644 --- a/orx-color/src/commonMain/kotlin/statistics/Histogram.kt +++ b/orx-color/src/commonMain/kotlin/statistics/Histogram.kt @@ -1,10 +1,12 @@ +@file:JvmName("HistogramJvm") package org.openrndr.extras.color.statistics import org.openrndr.color.ColorRGBa import org.openrndr.draw.ColorBuffer +import kotlin.jvm.JvmName import kotlin.random.Random -private fun ColorRGBa.binIndex(binCount: Int): Triple { +internal fun ColorRGBa.binIndex(binCount: Int): Triple { val rb = (r * binCount).toInt().coerceIn(0, binCount - 1) val gb = (g * binCount).toInt().coerceIn(0, binCount - 1) val bb = (b * binCount).toInt().coerceIn(0, binCount - 1) diff --git a/orx-color/src/jvmMain/src/statistics/Histogram.kt b/orx-color/src/jvmMain/kotlin/src/statistics/Histogram.kt similarity index 94% rename from orx-color/src/jvmMain/src/statistics/Histogram.kt rename to orx-color/src/jvmMain/kotlin/src/statistics/Histogram.kt index 941ed44c..8bab3cea 100644 --- a/orx-color/src/jvmMain/src/statistics/Histogram.kt +++ b/orx-color/src/jvmMain/kotlin/src/statistics/Histogram.kt @@ -1,3 +1,9 @@ +package org.openrndr.extras.color.statistics + +import org.openrndr.color.ColorRGBa +import org.openrndr.draw.ColorBuffer +import kotlin.random.Random + fun calculateHistogramRGB(buffer: ColorBuffer, binCount: Int = 16, weighting: ColorRGBa.() -> Double = { 1.0 }, diff --git a/orx-jvm/orx-olive/src/demo/kotlin/DemoOlive01.kt b/orx-jvm/orx-olive/src/demo/kotlin/DemoOlive01.kt index 1119a27c..4bbd2423 100644 --- a/orx-jvm/orx-olive/src/demo/kotlin/DemoOlive01.kt +++ b/orx-jvm/orx-olive/src/demo/kotlin/DemoOlive01.kt @@ -1,10 +1,11 @@ import org.openrndr.Extension import org.openrndr.Program import org.openrndr.application +import org.openrndr.applicationSynchronous import org.openrndr.extensions.SingleScreenshot import org.openrndr.extra.olive.Olive -fun main() = application { +fun main() = applicationSynchronous { configure { width = 768 height = 576 diff --git a/orx-noise/src/commonMain/kotlin/Functions.kt b/orx-noise/src/commonMain/kotlin/Functions.kt index 86592483..fbc33fa7 100644 --- a/orx-noise/src/commonMain/kotlin/Functions.kt +++ b/orx-noise/src/commonMain/kotlin/Functions.kt @@ -29,15 +29,9 @@ fun ((Int, Double, Double, Double) -> Double).crossFade( return { seed, x, y, z -> val a = z.map(start, end, 0.0, 1.0).mod_(1.0) val f = (a / width).coerceAtMost(1.0) - - val o = this(seed, x, y, a.map(0.0, 1.0, start, end)) * f + (1.0 - f) * this( - seed, - x, - y, - (a + 1.0).map(0.0, 1.0, start, end) - ) - o - + val o = this(seed, x, y, a.map(0.0, 1.0, start, end)) * f + val s = this(seed, x, y, (a + 1.0).map(0.0, 1.0, start, end) * (1.0 - f)) + o + s } } @@ -131,4 +125,7 @@ inline fun ((Int, Double, Double, Double) -> Double).perturb(crossinline distort inline fun ((Int, Vector4) -> Double).perturb(crossinline distort: (Vector4) -> Vector4): (Int, Vector4) -> Double = { seed, v -> this(seed, distort(v)) - } \ No newline at end of file + } + +typealias IDDD_D = ((Int, Double, Double, Double) -> Double) + diff --git a/orx-noise/src/demo/kotlin/DemoFunctionalComposition01.kt b/orx-noise/src/demo/kotlin/DemoFunctionalComposition01.kt index b5ee86e8..83c14b57 100644 --- a/orx-noise/src/demo/kotlin/DemoFunctionalComposition01.kt +++ b/orx-noise/src/demo/kotlin/DemoFunctionalComposition01.kt @@ -2,6 +2,7 @@ import org.openrndr.application import org.openrndr.color.ColorRGBa import org.openrndr.draw.LineJoin import org.openrndr.extensions.SingleScreenshot +import org.openrndr.extra.noise.perturb import org.openrndr.extra.noise.simplex import org.openrndr.extra.noise.simplex1D import org.openrndr.extra.noise.simplex2D @@ -10,6 +11,7 @@ import org.openrndr.extra.noise.withVector2Output import org.openrndr.extra.noise.gradient import org.openrndr.shape.contour +typealias IDDD_D = ((Int, Double, Double, Double) -> Double) suspend fun main() = application { configure { width = 720 @@ -21,6 +23,10 @@ suspend fun main() = application { this.outputFile = System.getProperty("screenshotPath") } } + + val c = simplex3D.perturb({v->v})::class + println(c) + println(IDDD_D::perturb) val n = simplex3D.withVector2Output().gradient() extend { drawer.stroke = null diff --git a/orx-quadtree/build.gradle.kts b/orx-quadtree/build.gradle.kts index 6e6dff4c..3a978b2c 100644 --- a/orx-quadtree/build.gradle.kts +++ b/orx-quadtree/build.gradle.kts @@ -26,6 +26,7 @@ kotlin { kotlin.srcDir("src/demo") dependencies { implementation(project(":orx-camera")) + implementation(project(":orx-noise")) implementation("org.openrndr:openrndr-application:$openrndrVersion") implementation("org.openrndr:openrndr-extensions:$openrndrVersion") runtimeOnly("org.openrndr:openrndr-gl3:$openrndrVersion") diff --git a/orx-quadtree/src/demo/kotlin/DemoQuadTree02.kt b/orx-quadtree/src/demo/kotlin/DemoQuadTree02.kt index c5239088..6e6958d7 100644 --- a/orx-quadtree/src/demo/kotlin/DemoQuadTree02.kt +++ b/orx-quadtree/src/demo/kotlin/DemoQuadTree02.kt @@ -6,7 +6,7 @@ import org.openrndr.extra.noise.Random import org.openrndr.extra.noise.gaussian import org.openrndr.math.Vector2 import org.openrndr.shape.Rectangle -import quadtree.Quadtree +import org.openrndr.extra.quadtree.Quadtree suspend fun main() { application { diff --git a/orx-shade-styles/build.gradle.kts b/orx-shade-styles/build.gradle.kts index bba10258..a93ecfef 100644 --- a/orx-shade-styles/build.gradle.kts +++ b/orx-shade-styles/build.gradle.kts @@ -25,7 +25,7 @@ kotlin { defaultSourceSet { kotlin.srcDir("src/demo") dependencies { - implementation(project(":orx-camera")) + implementation(project(":orx-color")) implementation("org.openrndr:openrndr-application:$openrndrVersion") implementation("org.openrndr:openrndr-extensions:$openrndrVersion") runtimeOnly("org.openrndr:openrndr-gl3:$openrndrVersion")