diff --git a/openrndr-demos/src/demo/kotlin/DemoShaderStorageBuffer01.kt b/openrndr-demos/src/demo/kotlin/DemoShaderStorageBuffer01.kt index ca58c693..8f316e69 100644 --- a/openrndr-demos/src/demo/kotlin/DemoShaderStorageBuffer01.kt +++ b/openrndr-demos/src/demo/kotlin/DemoShaderStorageBuffer01.kt @@ -1,39 +1,39 @@ -import org.openrndr.application -import org.openrndr.draw.VertexElementType -import org.openrndr.draw.shadeStyle -import org.openrndr.draw.shaderStorageBuffer -import org.openrndr.draw.shaderStorageFormat -import java.nio.ByteBuffer -import java.nio.ByteOrder - -fun main() = application { - program { - - val ssb = shaderStorageBuffer(shaderStorageFormat { - attribute("foo", VertexElementType.FLOAT32, 1000) - - }) - val ss = shadeStyle { - buffer("someBuffer", ssb) - fragmentTransform = "float a = b_someBuffer.foo[0]; b_someBuffer.foo[1] += 2.0;" - } - - val bb = ByteBuffer.allocateDirect(ssb.format.size) - bb.order(ByteOrder.nativeOrder()) - - extend { - ssb.clear() - - drawer.shadeStyle = ss - drawer.circle(100.0, 100.0, 200.0) - bb.rewind() - ssb.read(bb) - bb.rewind() - val f0 = bb.float - val f1 = bb.float - println(f1) - - } - - } -} \ No newline at end of file +//import org.openrndr.application +//import org.openrndr.draw.VertexElementType +//import org.openrndr.draw.shadeStyle +//import org.openrndr.draw.shaderStorageBuffer +//import org.openrndr.draw.shaderStorageFormat +//import java.nio.ByteBuffer +//import java.nio.ByteOrder +// +//fun main() = application { +// program { +// +// val ssb = shaderStorageBuffer(shaderStorageFormat { +// //member("foo", VertexElementType.FLOAT32, 1000) +// +// }) +// val ss = shadeStyle { +// buffer("someBuffer", ssb) +// fragmentTransform = "float a = b_someBuffer.foo[0]; b_someBuffer.foo[1] += 2.0;" +// } +// +// val bb = ByteBuffer.allocateDirect(ssb.format.size) +// bb.order(ByteOrder.nativeOrder()) +// +// extend { +// ssb.clear() +// +// drawer.shadeStyle = ss +// drawer.circle(100.0, 100.0, 200.0) +// bb.rewind() +// ssb.read(bb) +// bb.rewind() +// val f0 = bb.float +// val f1 = bb.float +// println(f1) +// +// } +// +// } +//} \ No newline at end of file diff --git a/orx-color/src/demo/kotlin/DemoHistogram01.kt b/orx-color/src/demo/kotlin/DemoHistogram01.kt index 527fcda4..46b7bb00 100644 --- a/orx-color/src/demo/kotlin/DemoHistogram01.kt +++ b/orx-color/src/demo/kotlin/DemoHistogram01.kt @@ -30,7 +30,7 @@ fun main() = application { } println(" and sort them by luminosity.") - val topColorsFreqSum = topColors.sumByDouble { it.second } + val topColorsFreqSum = topColors.sumOf { it.second } println("\nThose top $useColors colors represent " + String.format("%.02f", 100 * topColorsFreqSum) + "% of the image colors.") diff --git a/orx-color/src/main/kotlin/spaces/ColorHSLUVa.kt b/orx-color/src/main/kotlin/spaces/ColorHSLUVa.kt index e5fbea11..8bb697fa 100644 --- a/orx-color/src/main/kotlin/spaces/ColorHSLUVa.kt +++ b/orx-color/src/main/kotlin/spaces/ColorHSLUVa.kt @@ -123,11 +123,11 @@ data class ColorHSLUVa(val h: Double, val s: Double, val l: Double, val a: Doubl override fun opacify(factor: Double) = copy(a = a * factor) - override fun minus(other: ColorHSLUVa) = copy(h = h - other.h, s = s - other.s, l = l - other.l, a = a - other.a) + override fun minus(right: ColorHSLUVa) = copy(h = h - right.h, s = s - right.s, l = l - right.l, a = a - right.a) - override fun plus(other: ColorHSLUVa) = copy(h = h + other.h, s = s + other.s, l = l + other.l, a = a + other.a) + override fun plus(right: ColorHSLUVa) = copy(h = h + right.h, s = s + right.s, l = l + right.l, a = a + right.a) - override fun times(factor: Double) = copy(h = h * factor, s = s * factor, l = l * factor, a = a * factor) + override fun times(scale: Double) = copy(h = h * scale, s = s * scale, l = l * scale, a = a * scale) override fun mix(other: ColorHSLUVa, factor: Double) = mix(this, other, factor) @@ -163,11 +163,11 @@ data class ColorXSLUVa(val x: Double, val s: Double, val l: Double, val a: Doubl override fun opacify(factor: Double) = copy(a = a * factor) - override fun minus(other: ColorXSLUVa) = copy(x = x - other.x, s = s - other.s, l = l - other.l, a = a - other.a) + override fun minus(right: ColorXSLUVa) = copy(x = x - right.x, s = s - right.s, l = l - right.l, a = a - right.a) - override fun plus(other: ColorXSLUVa) = copy(x = x + other.x, s = s + other.s, l = l + other.l, a = a + other.a) + override fun plus(right: ColorXSLUVa) = copy(x = x + right.x, s = s + right.s, l = l + right.l, a = a + right.a) - override fun times(factor: Double) = copy(x = x * factor, s = s * factor, l = l * factor, a = a * factor) + override fun times(scale: Double) = copy(x = x * scale, s = s * scale, l = l * scale, a = a * scale) override fun mix(other: ColorXSLUVa, factor: Double) = mix(this, other, factor) } @@ -254,11 +254,11 @@ data class ColorHPLUVa(val h: Double, val s: Double, val l: Double, val a: Doubl override fun opacify(factor: Double) = copy(a = a * factor) - override fun minus(other: ColorHPLUVa) = copy(h = h - other.h, s = s - other.s, l = l - other.l, a = a - other.a) + override fun minus(right: ColorHPLUVa) = copy(h = h - right.h, s = s - right.s, l = l - right.l, a = a - right.a) - override fun plus(other: ColorHPLUVa) = copy(h = h + other.h, s = s + other.s, l = l + other.l, a = a + other.a) + override fun plus(right: ColorHPLUVa) = copy(h = h + right.h, s = s + right.s, l = l + right.l, a = a + right.a) - override fun times(factor: Double) = copy(h = h * factor, s = s * factor, l = l * factor, a = a * factor) + override fun times(scale: Double) = copy(h = h * scale, s = s * scale, l = l * scale, a = a * scale) override fun mix(other: ColorHPLUVa, factor: Double) = mix(this, other, factor) diff --git a/orx-gradient-descent/src/main/kotlin/GradientDescent.kt b/orx-gradient-descent/src/main/kotlin/GradientDescent.kt index ae5cc56f..314bf14e 100644 --- a/orx-gradient-descent/src/main/kotlin/GradientDescent.kt +++ b/orx-gradient-descent/src/main/kotlin/GradientDescent.kt @@ -86,7 +86,7 @@ private fun mul(x: DoubleArray, y: DoubleArray) = DoubleArray(x.size) { x[it] * private fun div(x: Array, y: Double) = Array(x.size) { div(x[it], y) } private fun div(x: DoubleArray, y: Double) = DoubleArray(x.size) { x[it] / y } private fun norm2(x: DoubleArray): Double { - return sqrt(x.sumByDouble { it * it }) + return sqrt(x.sumOf { it * it }) } internal fun dot(x: DoubleArray, y: DoubleArray): Double = (x.mapIndexed { index, it -> it * y[index] }).sum() diff --git a/orx-interval-tree/src/main/kotlin/IntervalTree.kt b/orx-interval-tree/src/main/kotlin/IntervalTree.kt index 9048b34c..a6e17b72 100644 --- a/orx-interval-tree/src/main/kotlin/IntervalTree.kt +++ b/orx-interval-tree/src/main/kotlin/IntervalTree.kt @@ -39,7 +39,7 @@ class IntervalNode(val center: Double) { fun buildIntervalTree(items: List, intervalFunction: (T) -> Pair): IntervalNode { val ranges = items.map { intervalFunction(it) } - val center = ranges.sumByDouble { (it.first + it.second) / 2.0 } / ranges.size + val center = ranges.sumOf { (it.first + it.second) / 2.0 } / ranges.size val node = IntervalNode(center) val leftItems = mutableListOf() val rightItems = mutableListOf() diff --git a/orx-noise/src/main/kotlin/Random.kt b/orx-noise/src/main/kotlin/Random.kt index 558d1c23..ad9cf34b 100644 --- a/orx-noise/src/main/kotlin/Random.kt +++ b/orx-noise/src/main/kotlin/Random.kt @@ -22,7 +22,7 @@ object Random { private var nextGaussian: Double = 0.0 private var hasNextGaussian = false - private lateinit var state: RandomState + private var state: RandomState enum class Fractal { FBM, BILLOW, RIGID diff --git a/orx-panel/src/main/kotlin/org/openrndr/panel/layout/Layouter.kt b/orx-panel/src/main/kotlin/org/openrndr/panel/layout/Layouter.kt index e69ffa53..1b180deb 100644 --- a/orx-panel/src/main/kotlin/org/openrndr/panel/layout/Layouter.kt +++ b/orx-panel/src/main/kotlin/org/openrndr/panel/layout/Layouter.kt @@ -59,11 +59,11 @@ class Layouter { val verticalPadding = element.computedStyle.effectivePaddingTop + element.computedStyle.effectivePaddingBottom val totalHeight = element.children .filter { it.computedStyle.display in blockLike && it.computedStyle.position !in manualPosition } - .sumByDouble { height(it, width(it)) } + .sumOf { height(it, width(it)) } val remainder = ((element.layout.screenHeight - verticalPadding) - totalHeight) val totalGrow = element.children .filter { it.computedStyle.display in blockLike && it.computedStyle.position !in manualPosition } - .sumByDouble { (it.computedStyle.flexGrow as FlexGrow.Ratio).value } + .sumOf { (it.computedStyle.flexGrow as FlexGrow.Ratio).value } element.children.filter { it.computedStyle.display in blockLike && it.computedStyle.position !in manualPosition }.forEach { child -> val elementGrow = (child.computedStyle.flexGrow as FlexGrow.Ratio).value