[orx-easing] convert orx-easing
This commit is contained in:
@@ -22,6 +22,8 @@ def multiplatformModules = [
|
|||||||
"orx-shader-phrases",
|
"orx-shader-phrases",
|
||||||
"orx-parameters",
|
"orx-parameters",
|
||||||
"orx-fx",
|
"orx-fx",
|
||||||
|
"orx-easing"
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
project.ext {
|
project.ext {
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
sourceSets {
|
|
||||||
demo {
|
|
||||||
java {
|
|
||||||
srcDirs = ["src/demo/kotlin"]
|
|
||||||
compileClasspath += main.getCompileClasspath()
|
|
||||||
runtimeClasspath += main.getRuntimeClasspath()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation project(":orx-shader-phrases")
|
|
||||||
implementation project(":orx-parameters")
|
|
||||||
|
|
||||||
demoImplementation(project(":orx-camera"))
|
|
||||||
demoImplementation("org.openrndr:openrndr-application:$openrndrVersion")
|
|
||||||
demoImplementation("org.openrndr:openrndr-extensions:$openrndrVersion")
|
|
||||||
demoRuntimeOnly("org.openrndr:openrndr-gl3:$openrndrVersion")
|
|
||||||
demoRuntimeOnly("org.openrndr:openrndr-gl3-natives-$openrndrOS:$openrndrVersion")
|
|
||||||
demoImplementation(sourceSets.getByName("main").output)
|
|
||||||
}
|
|
||||||
95
orx-easing/build.gradle.kts
Normal file
95
orx-easing/build.gradle.kts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import Orx_embed_shaders_gradle.EmbedShadersTask
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
kotlin("plugin.serialization")
|
||||||
|
id("orx.embed-shaders")
|
||||||
|
}
|
||||||
|
|
||||||
|
val kotlinxSerializationVersion: String by rootProject.extra
|
||||||
|
val kotestVersion: String by rootProject.extra
|
||||||
|
val junitJupiterVersion: String by rootProject.extra
|
||||||
|
val jvmTarget: String by rootProject.extra
|
||||||
|
val kotlinApiVersion: String by rootProject.extra
|
||||||
|
val kotlinVersion: String by rootProject.extra
|
||||||
|
val kotlinLoggingVersion: String by rootProject.extra
|
||||||
|
val kluentVersion: String by rootProject.extra
|
||||||
|
val openrndrVersion: String by rootProject.extra
|
||||||
|
val openrndrOS: String by rootProject.extra
|
||||||
|
val spekVersion: String by rootProject.extra
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvm {
|
||||||
|
compilations {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compilations.all {
|
||||||
|
kotlinOptions.jvmTarget = jvmTarget
|
||||||
|
kotlinOptions.apiVersion = kotlinApiVersion
|
||||||
|
}
|
||||||
|
testRuns["test"].executionTask.configure {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
js(IR) {
|
||||||
|
browser()
|
||||||
|
nodejs()
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
@Suppress("UNUSED_VARIABLE")
|
||||||
|
val commonMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(project(":orx-parameters"))
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlinxSerializationVersion")
|
||||||
|
implementation("org.openrndr:openrndr-application:$openrndrVersion")
|
||||||
|
implementation("org.openrndr:openrndr-draw:$openrndrVersion")
|
||||||
|
implementation("org.openrndr:openrndr-filter:$openrndrVersion")
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
|
||||||
|
implementation("io.github.microutils:kotlin-logging:$kotlinLoggingVersion")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Suppress("UNUSED_VARIABLE")
|
||||||
|
val commonTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-common"))
|
||||||
|
implementation(kotlin("test-annotations-common"))
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxSerializationVersion")
|
||||||
|
implementation("io.kotest:kotest-assertions-core:$kotestVersion")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED_VARIABLE")
|
||||||
|
val jvmTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-common"))
|
||||||
|
implementation(kotlin("test-annotations-common"))
|
||||||
|
implementation(kotlin("test-junit5"))
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxSerializationVersion")
|
||||||
|
runtimeOnly("org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion")
|
||||||
|
runtimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")
|
||||||
|
implementation("org.spekframework.spek2:spek-dsl-jvm:$spekVersion")
|
||||||
|
implementation("org.amshove.kluent:kluent:$kluentVersion")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED_VARIABLE")
|
||||||
|
val jsTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-js"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
package org.openrndr.extras.easing
|
package org.openrndr.extras.easing
|
||||||
|
|
||||||
import kotlin.math.cos
|
import kotlin.math.*
|
||||||
import kotlin.math.pow
|
|
||||||
import kotlin.math.sin
|
|
||||||
import kotlin.math.sqrt
|
|
||||||
|
|
||||||
typealias EasingFunction = (Double, Double, Double, Double) -> Double
|
typealias EasingFunction = (Double, Double, Double, Double) -> Double
|
||||||
|
|
||||||
@@ -167,7 +164,7 @@ fun easeElasticIn(t: Double, b: Double, c: Double, d: Double): Double {
|
|||||||
val p = d * .3
|
val p = d * .3
|
||||||
val s = p / 4
|
val s = p / 4
|
||||||
td -= 1.0
|
td -= 1.0
|
||||||
return -(c * 2.0.pow(10 * (td)) * sin((td * d - s) * (2 * Math.PI) / p)) + b
|
return -(c * 2.0.pow(10 * (td)) * sin((td * d - s) * (2 * PI) / p)) + b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,9 +179,9 @@ fun easeElasticInOut(t: Double, b: Double, c: Double, d: Double): Double {
|
|||||||
val s = p / 4
|
val s = p / 4
|
||||||
val td3 = td2 - 1.0
|
val td3 = td2 - 1.0
|
||||||
return if (td2 < 1) {
|
return if (td2 < 1) {
|
||||||
-.5 * (c * 2.0.pow(10 * (td3)) * sin((td3 - s) * (2 * Math.PI) / p)) + b
|
-.5 * (c * 2.0.pow(10 * (td3)) * sin((td3 - s) * (2 * PI) / p)) + b
|
||||||
} else {
|
} else {
|
||||||
c * 2.0.pow(-10 * (td3) * sin(td3 - s) * (2 * Math.PI) / p) * .5 + c + b
|
c * 2.0.pow(-10 * (td3) * sin(td3 - s) * (2 * PI) / p) * .5 + c + b
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -197,7 +194,7 @@ fun easeElasticOut(t: Double, b: Double, c: Double, d: Double): Double {
|
|||||||
return b + c
|
return b + c
|
||||||
val p = d * .3
|
val p = d * .3
|
||||||
val s = p / 4
|
val s = p / 4
|
||||||
return c * 2.0.pow(-10 * td) * sin((td * d - s) * (2 * Math.PI) / p) + c + b
|
return c * 2.0.pow(-10 * td) * sin((td * d - s) * (2 * PI) / p) + c + b
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- expo
|
// -- expo
|
||||||
@@ -279,13 +276,13 @@ fun easeQuintOut(t: Double, b: Double, c: Double, d: Double): Double {
|
|||||||
// -- sine
|
// -- sine
|
||||||
|
|
||||||
fun easeSineIn(t: Double, b: Double = 0.0, c: Double = 1.0, d: Double = 1.0): Double =
|
fun easeSineIn(t: Double, b: Double = 0.0, c: Double = 1.0, d: Double = 1.0): Double =
|
||||||
-c * cos(t / d * (Math.PI / 2)) + c + b
|
-c * cos(t / d * (PI / 2)) + c + b
|
||||||
|
|
||||||
fun easeSineOut(t: Double, b: Double = 0.0, c: Double = 1.0, d: Double = 1.0): Double =
|
fun easeSineOut(t: Double, b: Double = 0.0, c: Double = 1.0, d: Double = 1.0): Double =
|
||||||
c * sin(t / d * (Math.PI / 2)) + b
|
c * sin(t / d * (PI / 2)) + b
|
||||||
|
|
||||||
fun easeSineInOut(t: Double, b: Double, c: Double, d: Double): Double =
|
fun easeSineInOut(t: Double, b: Double, c: Double, d: Double): Double =
|
||||||
-c / 2 * (cos(Math.PI * t / d) - 1) + b
|
-c / 2 * (cos(PI * t / d) - 1) + b
|
||||||
|
|
||||||
|
|
||||||
enum class Easing(val function: EasingFunction) {
|
enum class Easing(val function: EasingFunction) {
|
||||||
Reference in New Issue
Block a user