Upgrade to JDK 17. Add @JvmRecord annotations
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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<ColorHPLUVa>,
|
||||
HueShiftableColor<ColorHPLUVa>,
|
||||
|
||||
@@ -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<ColorHSLUVa>,
|
||||
HueShiftableColor<ColorHSLUVa>,
|
||||
@@ -89,8 +91,6 @@ data class ColorHSLUVa(val h: Double, val s: Double, val l: Double, override val
|
||||
LuminosityColor<ColorHSLUVa>,
|
||||
AlgebraicColor<ColorHSLUVa> {
|
||||
|
||||
@Deprecated("Legacy alpha parameter name", ReplaceWith("alpha"))
|
||||
val a = alpha
|
||||
|
||||
fun toLCHUVa(): ColorLCHUVa {
|
||||
|
||||
|
||||
@@ -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<ColorOKHSLa>,
|
||||
HueShiftableColor<ColorOKHSLa>,
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<ColorOKHSVa>,
|
||||
HueShiftableColor<ColorOKHSVa>,
|
||||
@@ -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)
|
||||
|
||||
@@ -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<ColorOKLABa>,
|
||||
ShadableColor<ColorOKLABa>,
|
||||
|
||||
@@ -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<ColorOKLCHa>,
|
||||
ShadableColor<ColorOKLCHa>,
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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<ColorXSLUVa>,
|
||||
HueShiftableColor<ColorXSLUVa>,
|
||||
@@ -14,8 +16,6 @@ data class ColorXSLUVa(val x: Double, val s: Double, val l: Double, override val
|
||||
ShadableColor<ColorXSLUVa>,
|
||||
AlgebraicColor<ColorXSLUVa> {
|
||||
|
||||
@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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 <F : Filter2to1> Layer.blend(filter: F, configure: F.() -> Unit = {}): F {
|
||||
return filter
|
||||
}
|
||||
|
||||
@JvmRecord
|
||||
data class ColorBufferCacheKey(
|
||||
val colorType: ColorType,
|
||||
val contentScale: Double
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 = {}) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
/**
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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<NodeContent<Light>>,
|
||||
val shadowMaps: Map<ShadowLight, RenderTarget>)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<FacetCombiner>,
|
||||
val renderOpaque: Boolean = true,
|
||||
val renderTransparent: Boolean = false,
|
||||
|
||||
@@ -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?) {
|
||||
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -33,6 +33,7 @@ enum class OliveScriptHost {
|
||||
KOTLIN_SCRIPT
|
||||
}
|
||||
|
||||
@JvmRecord
|
||||
data class ScriptLoadedEvent(val scriptFile: String)
|
||||
|
||||
enum class ScriptMode {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<Vector2> = shape.triangulation.uniform(sampleCount)
|
||||
fun ShapeProvider.uniform(sampleCount: Int, random: Random = Random.Default) : List<Vector2> = shape.triangulation.uniform(sampleCount, random)
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<Triangle>.uniform(count: Int): List<Vector2> {
|
||||
fun List<Triangle>.uniform(count: Int, random: Random = Random.Default): List<Vector2> {
|
||||
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<Vector2>()
|
||||
var idx = 0
|
||||
@@ -17,7 +18,7 @@ fun List<Triangle>.uniform(count: Int): List<Vector2> {
|
||||
for (t in this) {
|
||||
sum += t.area
|
||||
while (idx < randoms.lastIndex && sum > randoms[idx]) {
|
||||
result.add(t.randomPoint())
|
||||
result.add(t.randomPoint(random))
|
||||
idx++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T>(val nearest: T, val neighbours: List<T>, val quads: List<Quadtree<T>>)
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<C>(
|
||||
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>, C: CastableToVector4 {
|
||||
|
||||
@@ -29,6 +29,8 @@ open class LinearGradientBase<C>(
|
||||
|
||||
@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<C>(
|
||||
@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<C>(
|
||||
this.offset = offset
|
||||
this.rotation = rotation
|
||||
this.exponent = exponent
|
||||
this.quantize = quantize
|
||||
|
||||
fragmentPreamble = """
|
||||
|#pragma import color.oklab_to_linear_rgb
|
||||
@@ -60,7 +66,12 @@ open class LinearGradientBase<C>(
|
||||
vec4 color0 = p_color0;
|
||||
vec4 color1 = p_color1;
|
||||
|
||||
vec4 gradient = mix(color0, color1, pow(f, p_exponent));
|
||||
float t = pow(f, p_exponent);
|
||||
if (p_quantize > 0) {
|
||||
t = floor(t * float(p_quantize)) / float(p_quantize);
|
||||
}
|
||||
|
||||
vec4 gradient = mix(color0, color1, t);
|
||||
${generateColorTransform(color0::class)}
|
||||
x_fill *= gradient;
|
||||
"""
|
||||
@@ -68,8 +79,8 @@ open class LinearGradientBase<C>(
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 <E> List<E>.update(vararg updates: Pair<Int, E>): List<E> {
|
||||
* of changes in the contour topology.
|
||||
* @since 0.4.4
|
||||
*/
|
||||
@JvmRecord
|
||||
data class ContourEdge(
|
||||
val contour: ShapeContour,
|
||||
val segmentIndex: Int,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user