[orx-shade-styles] Add elliptical gradient support
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package gradients
|
||||
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.loadFont
|
||||
import org.openrndr.extra.color.presets.BLUE_STEEL
|
||||
import org.openrndr.extra.shadestyles.fills.FillUnits
|
||||
import org.openrndr.extra.shadestyles.fills.SpreadMethod
|
||||
import org.openrndr.extra.shadestyles.fills.gradients.gradient
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.shadeStyle = gradient<ColorRGBa> {
|
||||
stops[0.0] = ColorRGBa.BLACK
|
||||
stops[1.0] = ColorRGBa.WHITE
|
||||
|
||||
fillUnits = FillUnits.WORLD
|
||||
spreadMethod = SpreadMethod.REPEAT
|
||||
//levelWarpFunction = """float levelWarp(vec2 p, float level) { return level + cos(p.x*0.01 + level)*0.1; } """
|
||||
|
||||
//quantization = 3
|
||||
// stellar {
|
||||
// radius = drawer.bounds.width/8.0
|
||||
// center = drawer.bounds.position(0.5, 0.0)
|
||||
// sides = 6
|
||||
// sharpness = 0.5
|
||||
// rotation = seconds * 36.0
|
||||
// }
|
||||
conic {
|
||||
angle = 360.0 * 8.0
|
||||
center = drawer.bounds.position(0.5, 0.5)
|
||||
}
|
||||
}
|
||||
|
||||
drawer.rectangle(drawer.bounds)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package gradients
|
||||
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.loadFont
|
||||
import org.openrndr.extra.color.presets.BLUE_STEEL
|
||||
import org.openrndr.extra.shadestyles.fills.FillUnits
|
||||
import org.openrndr.extra.shadestyles.fills.SpreadMethod
|
||||
import org.openrndr.extra.shadestyles.fills.gradients.gradient
|
||||
import org.openrndr.extra.shapes.primitives.grid
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
val grid = drawer.bounds.grid(2, 2)
|
||||
drawer.stroke = null
|
||||
|
||||
for ((index, cell) in grid.flatten().withIndex()) {
|
||||
drawer.shadeStyle = gradient<ColorRGBa> {
|
||||
stops[0.0] = ColorRGBa.RED
|
||||
stops[0.5] = ColorRGBa.PINK
|
||||
stops[1.0] = ColorRGBa.WHITE
|
||||
|
||||
fillUnits = FillUnits.BOUNDS
|
||||
spreadMethod = SpreadMethod.REPEAT
|
||||
quantization = 8
|
||||
elliptic {
|
||||
radiusX = cos(index / 2.0 * PI + seconds) * 0.45 + 0.5
|
||||
radiusY = sin(index / 2.0 * PI + seconds) * 0.45 + 0.5
|
||||
}
|
||||
}
|
||||
|
||||
drawer.rectangle(cell)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user