diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bb715974..cbb4cdbc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ kotlinApi = "2.0" kotlinLanguage = "2.0" kotlin = "2.0.0" -jvmTarget = "11" +jvmTarget = "17" openrndr = { require = "[0.4.2, 0.5.0)" } kotlinxCoroutines = "1.8.1" kotlinLogging = "6.0.9" diff --git a/orx-color/src/commonMain/kotlin/spaces/ColorHPLUVa.kt b/orx-color/src/commonMain/kotlin/spaces/ColorHPLUVa.kt index 3d3eb314..13ec3742 100644 --- a/orx-color/src/commonMain/kotlin/spaces/ColorHPLUVa.kt +++ b/orx-color/src/commonMain/kotlin/spaces/ColorHPLUVa.kt @@ -4,8 +4,10 @@ import kotlinx.serialization.Serializable import org.openrndr.color.* import org.openrndr.math.Vector4 import org.openrndr.math.mixAngle +import kotlin.jvm.JvmRecord @Serializable +@JvmRecord data class ColorHPLUVa(val h: Double, val s: Double, val l: Double, override val alpha: Double = 1.0) : ColorModel, HueShiftableColor, diff --git a/orx-color/src/commonMain/kotlin/spaces/ColorHSLUVa.kt b/orx-color/src/commonMain/kotlin/spaces/ColorHSLUVa.kt index 0c9ec79b..ee562bc1 100644 --- a/orx-color/src/commonMain/kotlin/spaces/ColorHSLUVa.kt +++ b/orx-color/src/commonMain/kotlin/spaces/ColorHSLUVa.kt @@ -5,6 +5,7 @@ import org.openrndr.color.* import org.openrndr.math.Vector4 import org.openrndr.math.map import org.openrndr.math.mixAngle +import kotlin.jvm.JvmRecord import kotlin.math.* private val m = arrayOf( @@ -81,6 +82,7 @@ private fun maxChromaForLH(L100: Double, H: Double): Double { * HSLUV color space */ @Serializable +@JvmRecord data class ColorHSLUVa(val h: Double, val s: Double, val l: Double, override val alpha: Double = 1.0) : ColorModel, HueShiftableColor, @@ -89,8 +91,6 @@ data class ColorHSLUVa(val h: Double, val s: Double, val l: Double, override val LuminosityColor, AlgebraicColor { - @Deprecated("Legacy alpha parameter name", ReplaceWith("alpha")) - val a = alpha fun toLCHUVa(): ColorLCHUVa { diff --git a/orx-color/src/commonMain/kotlin/spaces/ColorOKHSLa.kt b/orx-color/src/commonMain/kotlin/spaces/ColorOKHSLa.kt index 6107b41f..02116627 100644 --- a/orx-color/src/commonMain/kotlin/spaces/ColorOKHSLa.kt +++ b/orx-color/src/commonMain/kotlin/spaces/ColorOKHSLa.kt @@ -4,10 +4,12 @@ import kotlinx.serialization.Serializable import org.openrndr.color.* import org.openrndr.math.Vector4 import org.openrndr.math.mixAngle +import kotlin.jvm.JvmRecord import kotlin.math.* @Suppress("LocalVariableName") @Serializable +@JvmRecord data class ColorOKHSLa(val h: Double, val s: Double, val l: Double, override val alpha: Double = 1.0) : ColorModel, HueShiftableColor, @@ -52,8 +54,6 @@ data class ColorOKHSLa(val h: Double, val s: Double, val l: Double, override val } } - @Deprecated("Legacy alpha parameter name", ReplaceWith("alpha")) - val a = alpha override fun toRGBa(): ColorRGBa { if (l == 0.0 || l == 1.0) { diff --git a/orx-color/src/commonMain/kotlin/spaces/ColorOKHSVa.kt b/orx-color/src/commonMain/kotlin/spaces/ColorOKHSVa.kt index 9a8b6373..9dafc92d 100644 --- a/orx-color/src/commonMain/kotlin/spaces/ColorOKHSVa.kt +++ b/orx-color/src/commonMain/kotlin/spaces/ColorOKHSVa.kt @@ -4,10 +4,12 @@ import kotlinx.serialization.Serializable import org.openrndr.color.* import org.openrndr.math.Vector4 import org.openrndr.math.mixAngle +import kotlin.jvm.JvmRecord import kotlin.math.* @Suppress("LocalVariableName") @Serializable +@JvmRecord data class ColorOKHSVa(val h: Double, val s: Double, val v: Double, override val alpha: Double = 1.0) : ColorModel, HueShiftableColor, @@ -54,9 +56,6 @@ data class ColorOKHSVa(val h: Double, val s: Double, val v: Double, override val } } - @Deprecated("Legacy alpha parameter name", ReplaceWith("alpha")) - val a = alpha - override fun toRGBa(): ColorRGBa { val a_ = cos(2 * PI * h / 360.0) val b_ = sin(2 * PI * h / 360.0) diff --git a/orx-color/src/commonMain/kotlin/spaces/ColorOKLABa.kt b/orx-color/src/commonMain/kotlin/spaces/ColorOKLABa.kt index ff020fbb..3ef8dea1 100644 --- a/orx-color/src/commonMain/kotlin/spaces/ColorOKLABa.kt +++ b/orx-color/src/commonMain/kotlin/spaces/ColorOKLABa.kt @@ -3,6 +3,7 @@ package org.openrndr.extra.color.spaces import kotlinx.serialization.Serializable import org.openrndr.color.* import org.openrndr.math.Vector4 +import kotlin.jvm.JvmRecord import kotlin.math.abs import kotlin.math.pow import kotlin.math.sign @@ -15,6 +16,7 @@ import kotlin.math.sign */ @Suppress("LocalVariableName") @Serializable +@JvmRecord data class ColorOKLABa(val l: Double, val a: Double, val b: Double, override val alpha: Double = 1.0) : ColorModel, ShadableColor, diff --git a/orx-color/src/commonMain/kotlin/spaces/ColorOKLCHa.kt b/orx-color/src/commonMain/kotlin/spaces/ColorOKLCHa.kt index 2eea1614..285ca0d7 100644 --- a/orx-color/src/commonMain/kotlin/spaces/ColorOKLCHa.kt +++ b/orx-color/src/commonMain/kotlin/spaces/ColorOKLCHa.kt @@ -3,12 +3,14 @@ package org.openrndr.extra.color.spaces import kotlinx.serialization.Serializable import org.openrndr.color.* import org.openrndr.math.* +import kotlin.jvm.JvmRecord import kotlin.math.* /** * Color in cylindrical OKLab space */ @Serializable +@JvmRecord data class ColorOKLCHa(val l: Double, val c: Double, val h: Double, override val alpha: Double = 1.0) : ColorModel, ShadableColor, @@ -31,9 +33,6 @@ data class ColorOKLCHa(val l: Double, val c: Double, val h: Double, override val } } - @Deprecated("Legacy alpha parameter name", ReplaceWith("alpha")) - val a = alpha - override fun opacify(factor: Double) = copy(alpha = alpha * factor) override fun shade(factor: Double) = copy(l = l * factor) diff --git a/orx-color/src/commonMain/kotlin/spaces/ColorXSLUVa.kt b/orx-color/src/commonMain/kotlin/spaces/ColorXSLUVa.kt index b10a0773..815af22c 100644 --- a/orx-color/src/commonMain/kotlin/spaces/ColorXSLUVa.kt +++ b/orx-color/src/commonMain/kotlin/spaces/ColorXSLUVa.kt @@ -5,8 +5,10 @@ import org.openrndr.color.* import org.openrndr.math.Vector4 import org.openrndr.math.map import org.openrndr.math.mixAngle +import kotlin.jvm.JvmRecord @Serializable +@JvmRecord data class ColorXSLUVa(val x: Double, val s: Double, val l: Double, override val alpha: Double = 1.0) : ColorModel, HueShiftableColor, @@ -14,8 +16,6 @@ data class ColorXSLUVa(val x: Double, val s: Double, val l: Double, override val ShadableColor, AlgebraicColor { - @Deprecated("Legacy alpha parameter name", ReplaceWith("alpha")) - val a = alpha override val hue: Double get() = x override fun withHue(hue: Double): ColorXSLUVa = copy(x = hue) diff --git a/orx-composition/src/commonMain/kotlin/CompositionDrawer.kt b/orx-composition/src/commonMain/kotlin/CompositionDrawer.kt index 132bdb20..1a7ae093 100644 --- a/orx-composition/src/commonMain/kotlin/CompositionDrawer.kt +++ b/orx-composition/src/commonMain/kotlin/CompositionDrawer.kt @@ -12,6 +12,7 @@ import org.openrndr.math.Vector3 import org.openrndr.math.YPolarity import org.openrndr.math.transforms.* import org.openrndr.shape.* +import kotlin.jvm.JvmRecord /** * Used internally to define [ClipMode]s. @@ -71,12 +72,14 @@ private data class CompositionDrawStyle( /** * Data structure containing intersection information. */ +@JvmRecord data class ShapeNodeIntersection(val node: ShapeNode, val intersection: ContourIntersection) /** * Data structure containing information about a point * in a [ShapeContour] closest to some other 2D point. */ +@JvmRecord data class ShapeNodeNearestContour(val node: ShapeNode, val point: ContourPoint, val distanceDirection: Vector2, val distance: Double) /** diff --git a/orx-composition/src/commonMain/kotlin/CompositionStyleSheet.kt b/orx-composition/src/commonMain/kotlin/CompositionStyleSheet.kt index 412a7ff1..0a64619c 100644 --- a/orx-composition/src/commonMain/kotlin/CompositionStyleSheet.kt +++ b/orx-composition/src/commonMain/kotlin/CompositionStyleSheet.kt @@ -7,6 +7,7 @@ import org.openrndr.extra.composition.AttributeOrPropertyKey.* import org.openrndr.extra.composition.Inheritance.* import org.openrndr.math.* import org.openrndr.shape.Rectangle +import kotlin.jvm.JvmRecord import kotlin.reflect.* enum class Inheritance { @@ -216,8 +217,10 @@ enum class MeetOrSlice { SLICE } +@JvmRecord data class AspectRatio(val align: Align, val meetOrSlice: MeetOrSlice) : AttributeOrPropertyValue { - override val value = this + override val value: AspectRatio + get() = this companion object { val DEFAULT = AspectRatio(Align.X_MID_Y_MID, MeetOrSlice.MEET) @@ -267,6 +270,7 @@ sealed interface ViewBox : AttributeOrPropertyValue { } } +@JvmRecord private data class PropertyBehavior(val inherit: Inheritance, val initial: AttributeOrPropertyValue) private object PropertyBehaviors { diff --git a/orx-compositor/src/commonMain/kotlin/Compositor.kt b/orx-compositor/src/commonMain/kotlin/Compositor.kt index ec79397f..8a64d244 100644 --- a/orx-compositor/src/commonMain/kotlin/Compositor.kt +++ b/orx-compositor/src/commonMain/kotlin/Compositor.kt @@ -8,6 +8,7 @@ import org.openrndr.extra.fx.blend.SourceIn import org.openrndr.extra.fx.blend.SourceOut import org.openrndr.extra.parameters.BooleanParameter import org.openrndr.extra.parameters.Description +import kotlin.jvm.JvmRecord fun RenderTarget.deepDestroy() { val cbcopy = colorAttachments.map { it } @@ -320,6 +321,7 @@ fun Layer.blend(filter: F, configure: F.() -> Unit = {}): F { return filter } +@JvmRecord data class ColorBufferCacheKey( val colorType: ColorType, val contentScale: Double diff --git a/orx-compute-graph-nodes/src/jvmMain/kotlin/DrawCacheNode.kt b/orx-compute-graph-nodes/src/jvmMain/kotlin/DrawCacheNode.kt index e971d733..e1238253 100644 --- a/orx-compute-graph-nodes/src/jvmMain/kotlin/DrawCacheNode.kt +++ b/orx-compute-graph-nodes/src/jvmMain/kotlin/DrawCacheNode.kt @@ -13,6 +13,7 @@ import java.io.File val logger = KotlinLogging.logger { } +@JvmRecord private data class RenderTargetDescription(val width: Int, val height: Int, val contentScale: Double) private fun RenderTarget.description() = RenderTargetDescription(width, height, contentScale) diff --git a/orx-compute-graph/src/commonMain/kotlin/ComputeGraph.kt b/orx-compute-graph/src/commonMain/kotlin/ComputeGraph.kt index 202f1847..bc9d2932 100644 --- a/orx-compute-graph/src/commonMain/kotlin/ComputeGraph.kt +++ b/orx-compute-graph/src/commonMain/kotlin/ComputeGraph.kt @@ -6,10 +6,12 @@ import org.openrndr.events.Event import kotlin.contracts.ExperimentalContracts import kotlin.contracts.InvocationKind import kotlin.contracts.contract +import kotlin.jvm.JvmRecord import kotlin.reflect.KProperty private val logger = KotlinLogging.logger { } +@JvmRecord data class ComputeEvent(val source: ComputeNode) open class ComputeNode(val graph: ComputeGraph, var computeFunction: suspend () -> Unit = {}) { diff --git a/orx-envelopes/src/commonMain/kotlin/ADSR.kt b/orx-envelopes/src/commonMain/kotlin/ADSR.kt index f84fcbad..ac51bb01 100644 --- a/orx-envelopes/src/commonMain/kotlin/ADSR.kt +++ b/orx-envelopes/src/commonMain/kotlin/ADSR.kt @@ -1,6 +1,7 @@ package org.openrndr.extra.envelopes import org.openrndr.math.mix +import kotlin.jvm.JvmRecord import kotlin.math.min data class ADSR( diff --git a/orx-fcurve/src/commonMain/kotlin/FCurve.kt b/orx-fcurve/src/commonMain/kotlin/FCurve.kt index 136bec9b..f98f6faa 100644 --- a/orx-fcurve/src/commonMain/kotlin/FCurve.kt +++ b/orx-fcurve/src/commonMain/kotlin/FCurve.kt @@ -6,6 +6,7 @@ import org.openrndr.math.transforms.buildTransform import org.openrndr.shape.Segment2D import org.openrndr.shape.ShapeContour import org.openrndr.shape.bounds +import kotlin.jvm.JvmRecord import kotlin.math.abs /** diff --git a/orx-hash-grid/src/commonMain/kotlin/Box.kt b/orx-hash-grid/src/commonMain/kotlin/Box.kt index ffa75b0f..477962e1 100644 --- a/orx-hash-grid/src/commonMain/kotlin/Box.kt +++ b/orx-hash-grid/src/commonMain/kotlin/Box.kt @@ -1,7 +1,9 @@ package org.openrndr.extra.hashgrid import org.openrndr.math.Vector3 +import kotlin.jvm.JvmRecord +@JvmRecord data class Box3D(val corner: Vector3, val width: Double, val height: Double, val depth: Double) { companion object { val EMPTY = Box3D(Vector3.ZERO, 0.0, 0.0, 0.0) diff --git a/orx-hash-grid/src/commonMain/kotlin/HashGrid.kt b/orx-hash-grid/src/commonMain/kotlin/HashGrid.kt index 2b666e44..986734d0 100644 --- a/orx-hash-grid/src/commonMain/kotlin/HashGrid.kt +++ b/orx-hash-grid/src/commonMain/kotlin/HashGrid.kt @@ -2,6 +2,7 @@ package org.openrndr.extra.hashgrid import org.openrndr.math.Vector2 import org.openrndr.shape.Rectangle +import kotlin.jvm.JvmRecord import kotlin.math.abs import kotlin.math.max import kotlin.math.min @@ -12,6 +13,7 @@ private fun Double.fastFloor(): Int { return if (this >= 0) this.toInt() else this.toInt() - 1 } +@JvmRecord private data class GridCoords(val x: Int, val y: Int) { fun offset(i: Int, j: Int): GridCoords = copy(x = x + i, y = y + j) } diff --git a/orx-hash-grid/src/commonMain/kotlin/HashGrid3D.kt b/orx-hash-grid/src/commonMain/kotlin/HashGrid3D.kt index 664af03b..aa8dcf8f 100644 --- a/orx-hash-grid/src/commonMain/kotlin/HashGrid3D.kt +++ b/orx-hash-grid/src/commonMain/kotlin/HashGrid3D.kt @@ -1,5 +1,6 @@ package org.openrndr.extra.hashgrid import org.openrndr.math.Vector3 +import kotlin.jvm.JvmRecord import kotlin.math.abs import kotlin.math.max import kotlin.math.min @@ -10,6 +11,7 @@ private fun Double.fastFloor(): Int { return if (this >= 0) this.toInt() else this.toInt() - 1 } +@JvmRecord private data class GridCoords3D(val x: Int, val y: Int, val z: Int) { fun offset(i: Int, j: Int, k : Int): GridCoords3D = copy(x = x + i, y = y + j, z = z + k) } diff --git a/orx-jvm/orx-dnk3/src/main/kotlin/Light.kt b/orx-jvm/orx-dnk3/src/main/kotlin/Light.kt index 660f1db2..f57f57b7 100644 --- a/orx-jvm/orx-dnk3/src/main/kotlin/Light.kt +++ b/orx-jvm/orx-dnk3/src/main/kotlin/Light.kt @@ -8,6 +8,7 @@ import org.openrndr.math.Vector3 import org.openrndr.math.transforms.ortho import org.openrndr.math.transforms.perspective +@JvmRecord data class LightContext(val lights: List>, val shadowMaps: Map) diff --git a/orx-jvm/orx-dnk3/src/main/kotlin/Material.kt b/orx-jvm/orx-dnk3/src/main/kotlin/Material.kt index f0d71e50..807bdd72 100644 --- a/orx-jvm/orx-dnk3/src/main/kotlin/Material.kt +++ b/orx-jvm/orx-dnk3/src/main/kotlin/Material.kt @@ -52,8 +52,8 @@ data class MaterialContext(val pass: RenderPass, - +@JvmRecord data class PrimitiveContext(val hasNormalAttribute: Boolean, val hasSkinning: Boolean) - +@JvmRecord data class ContextKey(val materialContext: MaterialContext, val primitiveContext: PrimitiveContext) diff --git a/orx-jvm/orx-dnk3/src/main/kotlin/Post.kt b/orx-jvm/orx-dnk3/src/main/kotlin/Post.kt index cb5df0b9..37215e11 100644 --- a/orx-jvm/orx-dnk3/src/main/kotlin/Post.kt +++ b/orx-jvm/orx-dnk3/src/main/kotlin/Post.kt @@ -3,6 +3,7 @@ package org.openrndr.extra.dnk3 import org.openrndr.draw.* import org.openrndr.math.Matrix44 +@JvmRecord data class PostContext(val lightContext: LightContext, val inverseViewMatrix: Matrix44) interface PostStep { diff --git a/orx-jvm/orx-dnk3/src/main/kotlin/RenderPass.kt b/orx-jvm/orx-dnk3/src/main/kotlin/RenderPass.kt index 26702f0a..ec8a218f 100644 --- a/orx-jvm/orx-dnk3/src/main/kotlin/RenderPass.kt +++ b/orx-jvm/orx-dnk3/src/main/kotlin/RenderPass.kt @@ -5,6 +5,7 @@ import org.openrndr.draw.DepthFormat import org.openrndr.draw.RenderTarget import org.openrndr.draw.renderTarget +@JvmRecord data class RenderPass(val combiners: List, val renderOpaque: Boolean = true, val renderTransparent: Boolean = false, diff --git a/orx-jvm/orx-dnk3/src/main/kotlin/gltf/Gltf.kt b/orx-jvm/orx-dnk3/src/main/kotlin/gltf/Gltf.kt index 87dcdb2c..61e464ff 100644 --- a/orx-jvm/orx-dnk3/src/main/kotlin/gltf/Gltf.kt +++ b/orx-jvm/orx-dnk3/src/main/kotlin/gltf/Gltf.kt @@ -26,8 +26,10 @@ const val GLTF_ELEMENT_ARRAY_BUFFER = 34963 data class GltfAsset(val generator: String?, val version: String?) +@JvmRecord data class GltfScene(val nodes: IntArray) +@JvmRecord data class GltfNode(val name: String?, val children: IntArray?, val matrix: DoubleArray?, @@ -39,8 +41,10 @@ data class GltfNode(val name: String?, val camera: Int?, val extensions: GltfNodeExtensions?) +@JvmRecord data class KHRLightsPunctualIndex(val light: Int) +@JvmRecord data class GltfNodeExtensions(val KHR_lights_punctual: KHRLightsPunctualIndex?) { } diff --git a/orx-jvm/orx-midi/src/main/kotlin/MidiTransceiver.kt b/orx-jvm/orx-midi/src/main/kotlin/MidiTransceiver.kt index b2b553be..102af098 100644 --- a/orx-jvm/orx-midi/src/main/kotlin/MidiTransceiver.kt +++ b/orx-jvm/orx-midi/src/main/kotlin/MidiTransceiver.kt @@ -7,6 +7,7 @@ import javax.sound.midi.* private val logger = KotlinLogging.logger { } +@JvmRecord data class MidiDeviceName(val name: String, val vendor: String) class MidiDeviceCapabilities { @@ -18,6 +19,7 @@ class MidiDeviceCapabilities { } } +@JvmRecord data class MidiDeviceDescription( val name: String, val vendor: String, diff --git a/orx-jvm/orx-olive/src/demo/kotlin/DemoOlive01.kt b/orx-jvm/orx-olive/src/demo/kotlin/DemoOlive01.kt index 5d5f7abd..288d30ce 100644 --- a/orx-jvm/orx-olive/src/demo/kotlin/DemoOlive01.kt +++ b/orx-jvm/orx-olive/src/demo/kotlin/DemoOlive01.kt @@ -16,7 +16,7 @@ fun main() { } oliveProgram { extend { - drawer.clear(ColorRGBa.GRAY) + drawer.clear(ColorRGBa.PINK) drawer.fill = ColorRGBa.WHITE for (i in 0 until 100) { drawer.circle( diff --git a/orx-jvm/orx-olive/src/main/kotlin/Olive.kt b/orx-jvm/orx-olive/src/main/kotlin/Olive.kt index fa7db768..07cc2cd9 100644 --- a/orx-jvm/orx-olive/src/main/kotlin/Olive.kt +++ b/orx-jvm/orx-olive/src/main/kotlin/Olive.kt @@ -33,6 +33,7 @@ enum class OliveScriptHost { KOTLIN_SCRIPT } +@JvmRecord data class ScriptLoadedEvent(val scriptFile: String) enum class ScriptMode { diff --git a/orx-jvm/orx-panel/build.gradle.kts b/orx-jvm/orx-panel/build.gradle.kts index 0143a74c..1fb9aaaa 100644 --- a/orx-jvm/orx-panel/build.gradle.kts +++ b/orx-jvm/orx-panel/build.gradle.kts @@ -15,6 +15,7 @@ tasks.test { dependencies { implementation(project(":orx-expression-evaluator")) + implementation(project(":orx-color")) implementation(project(":orx-text-writer")) implementation(libs.openrndr.application) implementation(libs.openrndr.math) diff --git a/orx-jvm/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Element.kt b/orx-jvm/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Element.kt index 9557ab4e..dde529d2 100644 --- a/orx-jvm/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Element.kt +++ b/orx-jvm/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Element.kt @@ -14,8 +14,11 @@ import org.openrndr.shape.Rectangle import java.util.* +@JvmRecord data class ElementClass(val name: String) +@JvmRecord data class ElementPseudoClass(val name: String) +@JvmRecord data class ElementType(val name: String) val disabled = ElementPseudoClass("disabled") diff --git a/orx-jvm/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Slider.kt b/orx-jvm/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Slider.kt index 64d861a6..c8354b39 100644 --- a/orx-jvm/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Slider.kt +++ b/orx-jvm/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Slider.kt @@ -21,6 +21,7 @@ import kotlin.reflect.KMutableProperty0 private val logger = KotlinLogging.logger {} +@JvmRecord data class Range(val min: Double, val max: Double) { val span: Double get() = max - min } diff --git a/orx-jvm/orx-panel/src/main/kotlin/org/openrndr/panel/style/StyleSheet.kt b/orx-jvm/orx-panel/src/main/kotlin/org/openrndr/panel/style/StyleSheet.kt index bae16429..612c3205 100644 --- a/orx-jvm/orx-panel/src/main/kotlin/org/openrndr/panel/style/StyleSheet.kt +++ b/orx-jvm/orx-panel/src/main/kotlin/org/openrndr/panel/style/StyleSheet.kt @@ -11,6 +11,7 @@ enum class PropertyInheritance { RESET } +@JvmRecord data class Property(val name: String, val value: Any?) @@ -41,7 +42,7 @@ sealed class LinearDimension(inherit: Boolean = false) : PropertyValue(inherit) object Inherit : LinearDimension(inherit = true) } - +@JvmRecord data class PropertyBehaviour(val inheritance: PropertyInheritance, val intitial: Any) object PropertyBehaviours { diff --git a/orx-noise/src/commonMain/kotlin/ShapeNoise.kt b/orx-noise/src/commonMain/kotlin/ShapeNoise.kt index e6fe7f22..781224c6 100644 --- a/orx-noise/src/commonMain/kotlin/ShapeNoise.kt +++ b/orx-noise/src/commonMain/kotlin/ShapeNoise.kt @@ -28,7 +28,7 @@ fun ShapeProvider.uniform(distanceToEdge: Double = 0.0, random: Random = Random. /** * Generate [sampleCount] uniformly distributed points inside the area of [ShapeProvider] */ -fun ShapeProvider.uniform(sampleCount: Int) : List = shape.triangulation.uniform(sampleCount) +fun ShapeProvider.uniform(sampleCount: Int, random: Random = Random.Default) : List = shape.triangulation.uniform(sampleCount, random) /** diff --git a/orx-noise/src/commonMain/kotlin/TriangleNoise.kt b/orx-noise/src/commonMain/kotlin/TriangleNoise.kt index 11f1e04d..fcc87ab6 100644 --- a/orx-noise/src/commonMain/kotlin/TriangleNoise.kt +++ b/orx-noise/src/commonMain/kotlin/TriangleNoise.kt @@ -2,14 +2,15 @@ package org.openrndr.extra.noise import org.openrndr.math.Vector2 import org.openrndr.shape.Triangle +import kotlin.random.Random /** * Generate [count] uniform samples from a list of [Triangle]s */ -fun List.uniform(count: Int): List { +fun List.uniform(count: Int, random: Random = Random.Default): List { val totalArea = this.sumOf { it.area } val randoms = (0 until count).map { - Double.uniform(0.0, totalArea) + Double.uniform(0.0, totalArea, random = random) }.sorted() val result = mutableListOf() var idx = 0 @@ -17,7 +18,7 @@ fun List.uniform(count: Int): List { for (t in this) { sum += t.area while (idx < randoms.lastIndex && sum > randoms[idx]) { - result.add(t.randomPoint()) + result.add(t.randomPoint(random)) idx++ } } diff --git a/orx-quadtree/src/commonMain/kotlin/Quadtree.kt b/orx-quadtree/src/commonMain/kotlin/Quadtree.kt index c211a2a3..5a065a30 100644 --- a/orx-quadtree/src/commonMain/kotlin/Quadtree.kt +++ b/orx-quadtree/src/commonMain/kotlin/Quadtree.kt @@ -5,7 +5,9 @@ import org.openrndr.draw.RectangleBatchBuilder import org.openrndr.math.Vector2 import org.openrndr.shape.Rectangle import org.openrndr.shape.intersects +import kotlin.jvm.JvmRecord +@JvmRecord data class QuadtreeQuery(val nearest: T, val neighbours: List, val quads: List>) /** diff --git a/orx-shade-styles/src/commonMain/kotlin/LinearGradient.kt b/orx-shade-styles/src/commonMain/kotlin/LinearGradient.kt index ce958b2e..0cf49ba0 100644 --- a/orx-shade-styles/src/commonMain/kotlin/LinearGradient.kt +++ b/orx-shade-styles/src/commonMain/kotlin/LinearGradient.kt @@ -4,12 +4,11 @@ package org.openrndr.extra.shadestyles import org.openrndr.color.* import org.openrndr.draw.ShadeStyle -import org.openrndr.extra.parameters.ColorParameter -import org.openrndr.extra.parameters.Description -import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.shaderphrases.preprocess import org.openrndr.extra.color.phrases.ColorPhraseBook import org.openrndr.extra.color.spaces.ColorOKLABa +import org.openrndr.extra.color.spaces.toOKLABa +import org.openrndr.extra.parameters.* import org.openrndr.math.CastableToVector4 import org.openrndr.math.Vector2 import kotlin.reflect.KClass @@ -20,7 +19,8 @@ open class LinearGradientBase( color1: C, offset: Vector2 = Vector2.ZERO, rotation: Double = 0.0, - exponent: Double = 1.0 + exponent: Double = 1.0, + quantize: Int = 0, ) : ShadeStyle() where C : ConvertibleToColorRGBa, C : AlgebraicColor, C: CastableToVector4 { @@ -29,6 +29,8 @@ open class LinearGradientBase( @ColorParameter("end color", order = 1) var color1: C by Parameter() + + @Vector2Parameter("offset") var offset: Vector2 by Parameter() @DoubleParameter("rotation", -180.0, 180.0, order = 2) @@ -37,6 +39,9 @@ open class LinearGradientBase( @DoubleParameter("exponent", 0.01, 10.0, order = 3) var exponent: Double by Parameter() + @IntParameter("quantize", 0, 256) + var quantize: Int by Parameter() + init { ColorPhraseBook.register() this.color0 = color0 @@ -44,6 +49,7 @@ open class LinearGradientBase( this.offset = offset this.rotation = rotation this.exponent = exponent + this.quantize = quantize fragmentPreamble = """ |#pragma import color.oklab_to_linear_rgb @@ -59,8 +65,13 @@ open class LinearGradientBase( vec4 color0 = p_color0; vec4 color1 = p_color1; + + float t = pow(f, p_exponent); + if (p_quantize > 0) { + t = floor(t * float(p_quantize)) / float(p_quantize); + } - vec4 gradient = mix(color0, color1, pow(f, p_exponent)); + vec4 gradient = mix(color0, color1, t); ${generateColorTransform(color0::class)} x_fill *= gradient; """ @@ -68,8 +79,8 @@ open class LinearGradientBase( } class LinearGradient( - color0: ColorRGBa, - color1: ColorRGBa, + color0: ColorRGBa = ColorRGBa.BLACK, + color1: ColorRGBa = ColorRGBa.WHITE, offset: Vector2 = Vector2.ZERO, rotation: Double = 0.0, exponent: Double = 1.0 @@ -85,8 +96,8 @@ class LinearGradientOKLab( fun linearGradient( - color0: ColorRGBa, - color1: ColorRGBa, + color0: ColorRGBa = ColorRGBa.BLACK, + color1: ColorRGBa = ColorRGBa.WHITE, offset: Vector2 = Vector2.ZERO, rotation: Double = 0.0, exponent: Double = 1.0 @@ -95,8 +106,8 @@ fun linearGradient( } fun linearGradient( - color0: ColorOKLABa, - color1: ColorOKLABa, + color0: ColorOKLABa = ColorRGBa.BLACK.toOKLABa(), + color1: ColorOKLABa = ColorRGBa.WHITE.toOKLABa(), offset: Vector2 = Vector2.ZERO, rotation: Double = 0.0, exponent: Double = 1.0 diff --git a/orx-shapes/src/commonMain/kotlin/adjust/ContourAdjusterEdge.kt b/orx-shapes/src/commonMain/kotlin/adjust/ContourAdjusterEdge.kt index 45083656..196b2e35 100644 --- a/orx-shapes/src/commonMain/kotlin/adjust/ContourAdjusterEdge.kt +++ b/orx-shapes/src/commonMain/kotlin/adjust/ContourAdjusterEdge.kt @@ -2,7 +2,9 @@ package org.openrndr.extra.shapes.adjust import org.openrndr.math.Vector2 import org.openrndr.shape.ShapeContour +import kotlin.jvm.JvmRecord +@JvmRecord data class ContourAdjusterEdge(val contourAdjuster: ContourAdjuster, val segmentIndex: () -> Int) { val startPosition diff --git a/orx-shapes/src/commonMain/kotlin/adjust/ContourEdge.kt b/orx-shapes/src/commonMain/kotlin/adjust/ContourEdge.kt index 56c07ef5..d8971b23 100644 --- a/orx-shapes/src/commonMain/kotlin/adjust/ContourEdge.kt +++ b/orx-shapes/src/commonMain/kotlin/adjust/ContourEdge.kt @@ -9,6 +9,7 @@ import org.openrndr.math.transforms.buildTransform import org.openrndr.shape.Segment2D import org.openrndr.shape.SegmentType import org.openrndr.shape.ShapeContour +import kotlin.jvm.JvmRecord import kotlin.math.abs internal fun Vector2.transformedBy(t: Matrix44, mask: Int = 0x0f, maskRef: Int = 0x0f) = @@ -38,6 +39,7 @@ fun List.update(vararg updates: Pair): List { * of changes in the contour topology. * @since 0.4.4 */ +@JvmRecord data class ContourEdge( val contour: ShapeContour, val segmentIndex: Int, diff --git a/orx-shapes/src/commonMain/kotlin/adjust/ContourVertex.kt b/orx-shapes/src/commonMain/kotlin/adjust/ContourVertex.kt index dc7408c6..f714ba44 100644 --- a/orx-shapes/src/commonMain/kotlin/adjust/ContourVertex.kt +++ b/orx-shapes/src/commonMain/kotlin/adjust/ContourVertex.kt @@ -5,7 +5,9 @@ import org.openrndr.math.Matrix44 import org.openrndr.math.Vector2 import org.openrndr.math.transforms.buildTransform import org.openrndr.shape.ShapeContour +import kotlin.jvm.JvmRecord +@JvmRecord data class ContourVertex( val contour: ShapeContour, val segmentIndex: Int, diff --git a/orx-shapes/src/commonMain/kotlin/adjust/SegmentAdjustments.kt b/orx-shapes/src/commonMain/kotlin/adjust/SegmentAdjustments.kt index 167f5fde..041372b8 100644 --- a/orx-shapes/src/commonMain/kotlin/adjust/SegmentAdjustments.kt +++ b/orx-shapes/src/commonMain/kotlin/adjust/SegmentAdjustments.kt @@ -1,9 +1,12 @@ package org.openrndr.extra.shapes.adjust import org.openrndr.shape.Segment2D +import kotlin.jvm.JvmRecord sealed interface SegmentOperation { + @JvmRecord data class Remove(val index: Int, val amount: Int) : SegmentOperation + @JvmRecord data class Insert(val index: Int, val amount: Int) : SegmentOperation }