Fixes for OPENRNDR 0.3.58 compatibility
This commit is contained in:
@@ -1,39 +1,39 @@
|
|||||||
import org.openrndr.application
|
//import org.openrndr.application
|
||||||
import org.openrndr.draw.VertexElementType
|
//import org.openrndr.draw.VertexElementType
|
||||||
import org.openrndr.draw.shadeStyle
|
//import org.openrndr.draw.shadeStyle
|
||||||
import org.openrndr.draw.shaderStorageBuffer
|
//import org.openrndr.draw.shaderStorageBuffer
|
||||||
import org.openrndr.draw.shaderStorageFormat
|
//import org.openrndr.draw.shaderStorageFormat
|
||||||
import java.nio.ByteBuffer
|
//import java.nio.ByteBuffer
|
||||||
import java.nio.ByteOrder
|
//import java.nio.ByteOrder
|
||||||
|
//
|
||||||
fun main() = application {
|
//fun main() = application {
|
||||||
program {
|
// program {
|
||||||
|
//
|
||||||
val ssb = shaderStorageBuffer(shaderStorageFormat {
|
// val ssb = shaderStorageBuffer(shaderStorageFormat {
|
||||||
attribute("foo", VertexElementType.FLOAT32, 1000)
|
// //member("foo", VertexElementType.FLOAT32, 1000)
|
||||||
|
//
|
||||||
})
|
// })
|
||||||
val ss = shadeStyle {
|
// val ss = shadeStyle {
|
||||||
buffer("someBuffer", ssb)
|
// buffer("someBuffer", ssb)
|
||||||
fragmentTransform = "float a = b_someBuffer.foo[0]; b_someBuffer.foo[1] += 2.0;"
|
// fragmentTransform = "float a = b_someBuffer.foo[0]; b_someBuffer.foo[1] += 2.0;"
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
val bb = ByteBuffer.allocateDirect(ssb.format.size)
|
// val bb = ByteBuffer.allocateDirect(ssb.format.size)
|
||||||
bb.order(ByteOrder.nativeOrder())
|
// bb.order(ByteOrder.nativeOrder())
|
||||||
|
//
|
||||||
extend {
|
// extend {
|
||||||
ssb.clear()
|
// ssb.clear()
|
||||||
|
//
|
||||||
drawer.shadeStyle = ss
|
// drawer.shadeStyle = ss
|
||||||
drawer.circle(100.0, 100.0, 200.0)
|
// drawer.circle(100.0, 100.0, 200.0)
|
||||||
bb.rewind()
|
// bb.rewind()
|
||||||
ssb.read(bb)
|
// ssb.read(bb)
|
||||||
bb.rewind()
|
// bb.rewind()
|
||||||
val f0 = bb.float
|
// val f0 = bb.float
|
||||||
val f1 = bb.float
|
// val f1 = bb.float
|
||||||
println(f1)
|
// println(f1)
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
@@ -30,7 +30,7 @@ fun main() = application {
|
|||||||
}
|
}
|
||||||
println(" and sort them by luminosity.")
|
println(" and sort them by luminosity.")
|
||||||
|
|
||||||
val topColorsFreqSum = topColors.sumByDouble { it.second }
|
val topColorsFreqSum = topColors.sumOf { it.second }
|
||||||
println("\nThose top $useColors colors represent " +
|
println("\nThose top $useColors colors represent " +
|
||||||
String.format("%.02f", 100 * topColorsFreqSum) +
|
String.format("%.02f", 100 * topColorsFreqSum) +
|
||||||
"% of the image colors.")
|
"% of the image colors.")
|
||||||
|
|||||||
@@ -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 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)
|
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 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)
|
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 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)
|
override fun mix(other: ColorHPLUVa, factor: Double) = mix(this, other, factor)
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ private fun mul(x: DoubleArray, y: DoubleArray) = DoubleArray(x.size) { x[it] *
|
|||||||
private fun div(x: Array<DoubleArray>, y: Double) = Array(x.size) { div(x[it], y) }
|
private fun div(x: Array<DoubleArray>, y: Double) = Array(x.size) { div(x[it], y) }
|
||||||
private fun div(x: DoubleArray, y: Double) = DoubleArray(x.size) { x[it] / y }
|
private fun div(x: DoubleArray, y: Double) = DoubleArray(x.size) { x[it] / y }
|
||||||
private fun norm2(x: DoubleArray): Double {
|
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()
|
internal fun dot(x: DoubleArray, y: DoubleArray): Double = (x.mapIndexed { index, it -> it * y[index] }).sum()
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class IntervalNode<T>(val center: Double) {
|
|||||||
|
|
||||||
fun <T : Any> buildIntervalTree(items: List<T>, intervalFunction: (T) -> Pair<Double, Double>): IntervalNode<T> {
|
fun <T : Any> buildIntervalTree(items: List<T>, intervalFunction: (T) -> Pair<Double, Double>): IntervalNode<T> {
|
||||||
val ranges = items.map { intervalFunction(it) }
|
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<T>(center)
|
val node = IntervalNode<T>(center)
|
||||||
val leftItems = mutableListOf<T>()
|
val leftItems = mutableListOf<T>()
|
||||||
val rightItems = mutableListOf<T>()
|
val rightItems = mutableListOf<T>()
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ object Random {
|
|||||||
private var nextGaussian: Double = 0.0
|
private var nextGaussian: Double = 0.0
|
||||||
private var hasNextGaussian = false
|
private var hasNextGaussian = false
|
||||||
|
|
||||||
private lateinit var state: RandomState
|
private var state: RandomState
|
||||||
|
|
||||||
enum class Fractal {
|
enum class Fractal {
|
||||||
FBM, BILLOW, RIGID
|
FBM, BILLOW, RIGID
|
||||||
|
|||||||
@@ -59,11 +59,11 @@ class Layouter {
|
|||||||
val verticalPadding = element.computedStyle.effectivePaddingTop + element.computedStyle.effectivePaddingBottom
|
val verticalPadding = element.computedStyle.effectivePaddingTop + element.computedStyle.effectivePaddingBottom
|
||||||
val totalHeight = element.children
|
val totalHeight = element.children
|
||||||
.filter { it.computedStyle.display in blockLike && it.computedStyle.position !in manualPosition }
|
.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 remainder = ((element.layout.screenHeight - verticalPadding) - totalHeight)
|
||||||
val totalGrow = element.children
|
val totalGrow = element.children
|
||||||
.filter { it.computedStyle.display in blockLike && it.computedStyle.position !in manualPosition }
|
.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 ->
|
element.children.filter { it.computedStyle.display in blockLike && it.computedStyle.position !in manualPosition }.forEach { child ->
|
||||||
val elementGrow = (child.computedStyle.flexGrow as FlexGrow.Ratio).value
|
val elementGrow = (child.computedStyle.flexGrow as FlexGrow.Ratio).value
|
||||||
|
|||||||
Reference in New Issue
Block a user