[orx-math] Make Complex class serializable with kotlinx.serialization

This commit is contained in:
Edwin Jakobs
2025-08-16 21:05:34 +02:00
parent 2569be0a1f
commit 4db699a81d

View File

@@ -1,5 +1,6 @@
package org.openrndr.extra.math.complex package org.openrndr.extra.math.complex
import kotlinx.serialization.Serializable
import kotlin.jvm.JvmRecord import kotlin.jvm.JvmRecord
import kotlin.math.atan2 import kotlin.math.atan2
import kotlin.math.cos import kotlin.math.cos
@@ -22,6 +23,7 @@ import kotlin.math.sinh
* @property imaginary The imaginary part of the complex number. * @property imaginary The imaginary part of the complex number.
*/ */
@JvmRecord @JvmRecord
@Serializable
data class Complex(val real: Double, val imaginary: Double) { data class Complex(val real: Double, val imaginary: Double) {
operator fun plus(other: Complex): Complex { operator fun plus(other: Complex): Complex {
return Complex(real + other.real, imaginary + other.imaginary) return Complex(real + other.real, imaginary + other.imaginary)