Demos: ensure 720px wide, reduce indentation

openrndr-demos, orx-color, orx-jumpflood, orx-no-clear
This commit is contained in:
Abe Pazos
2025-01-25 13:30:18 +01:00
parent f84bf69713
commit fc4f7275fb
74 changed files with 1314 additions and 1293 deletions

View File

@@ -1,16 +1,13 @@
import org.openrndr.application
import org.openrndr.draw.loadImage
fun main() {
application {
program {
val image16 = loadImage("demo-data/images/16-bit.png")
val image8 = loadImage("demo-data/images/image-001.png")
extend {
drawer.image(image16)
drawer.image(image8, 320.0, 0.0)
}
fun main() = application {
program {
val image16 = loadImage("demo-data/images/16-bit.png")
val image8 = loadImage("demo-data/images/image-001.png")
extend {
drawer.image(image16)
drawer.image(image8, 320.0, 0.0)
}
}
}

View File

@@ -1,14 +1,12 @@
import org.openrndr.application
import org.openrndr.internal.colorBufferLoader
fun main() {
application {
program {
extend {
val proxy = colorBufferLoader.loadFromUrl("https://avatars3.githubusercontent.com/u/31103334?s=200&v=4")
proxy.colorBuffer?.let {
drawer.image(it)
}
fun main() = application {
program {
extend {
val proxy = colorBufferLoader.loadFromUrl("https://avatars3.githubusercontent.com/u/31103334?s=200&v=4")
proxy.colorBuffer?.let {
drawer.image(it)
}
}
}

View File

@@ -11,14 +11,12 @@ import org.openrndr.math.Vector3
fun main() = application {
configure {
multisample = WindowMultisample.SampleCount(8)
}
program {
extend(Orbital())
val circlePositions = vertexBuffer(vertexFormat {
attribute("position", VertexElementType.VECTOR3_FLOAT32)
attribute("scale", VertexElementType.FLOAT32)
@@ -31,7 +29,6 @@ fun main() = application {
}
}
extend {
drawer.perspective(90.0, width*1.0/height*1.0, 0.1, 100.0)

View File

@@ -9,7 +9,9 @@ import org.openrndr.shape.ShapeContour
fun main() = application {
program {
val points = List(6) { Polar(it * 70.0, 100.0).cartesian + drawer.bounds.center }
val points = List(6) {
Polar(it * 70.0, 100.0).cartesian + drawer.bounds.center
}
val cmr = CatmullRomChain2(points, 1.0, loop = true)
val contour = ShapeContour.fromPoints(cmr.positions(200), true)

View File

@@ -10,7 +10,6 @@ This program demonstrates dynamic circle batches
fun main() = application {
program {
extend {
drawer.clear(ColorRGBa.GRAY)
drawer.circles {

View File

@@ -12,7 +12,6 @@ fun main() {
}
program {
val cs = Rectangle(0.0, 0.0, 200.0, 200.0).contour
val cc = Circle(100.0, 0.0, 100.0).contour

View File

@@ -5,33 +5,35 @@ import org.openrndr.shape.Circle
import org.openrndr.shape.Rectangle
import org.openrndr.shape.intersections
fun main() {
application {
program {
extend {
val circle = Circle(mouse.position, 200.0).contour
fun main() = application {
program {
extend {
val circle = Circle(mouse.position, 200.0).contour
drawer.fill = null
for (y in 50 until height step 100) {
for (x in 50 until width step 100) {
drawer.fill = null
for (y in 50 until height step 100) {
for (x in 50 until width step 100) {
for (ring in 0 until 10) {
val r = Rectangle.fromCenter(Vector2(x * 1.0, y * 1.0), 90.0 - ring * 8.0, 90.0 - ring * 8.0).contour
for (ring in 0 until 10) {
val r = Rectangle.fromCenter(
Vector2(x * 1.0, y * 1.0),
90.0 - ring * 8.0,
90.0 - ring * 8.0
).contour
val ints = intersections(circle, r)
if (ints.isEmpty()) {
drawer.stroke = ColorRGBa.GREEN
drawer.contour(r)
} else {
drawer.stroke = ColorRGBa.WHITE
ints.map { it.b.contourT }.let { it + it.take(1) }.zipWithNext().forEach {
val end = if (it.second <= it.first) it.second + 1.0 else it.second
val sub = r.sub(it.first, end)
val length = sub.length
val ta = sub.tForLength(2.0)
val tb = sub.tForLength(length - 2.0)
drawer.contour(sub.sub(ta, tb))
}
val ints = intersections(circle, r)
if (ints.isEmpty()) {
drawer.stroke = ColorRGBa.GREEN
drawer.contour(r)
} else {
drawer.stroke = ColorRGBa.WHITE
ints.map { it.b.contourT }.let { it + it.take(1) }.zipWithNext().forEach {
val end = if (it.second <= it.first) it.second + 1.0 else it.second
val sub = r.sub(it.first, end)
val length = sub.length
val ta = sub.tForLength(2.0)
val tb = sub.tForLength(length - 2.0)
drawer.contour(sub.sub(ta, tb))
}
}
}

View File

@@ -12,12 +12,12 @@ fun main() = application {
val points = 200
extend {
val contour = ShapeContour.fromPoints(
List(points) {
val a = PI * 2 * it / points
val x = (200 + 50 * cos(a * 2)) * sin(a * 3 + sin(a))
val y = 150 * cos(a * 2 + seconds * 0.2)
Vector2(x, y)
}, closed = true
List(points) {
val a = PI * 2 * it / points
val x = (200 + 50 * cos(a * 2)) * sin(a * 3 + sin(a))
val y = 150 * cos(a * 2 + seconds * 0.2)
Vector2(x, y)
}, closed = true
)
val ints = intersections(contour, contour)
drawer.run {

View File

@@ -1,16 +1,17 @@
import org.openrndr.application
import org.openrndr.draw.*
import org.openrndr.draw.DrawPrimitive
import org.openrndr.draw.Session
import org.openrndr.draw.loadCubemap
import org.openrndr.draw.shadeStyle
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.boxMesh
fun main() = application {
program {
val cubemap = loadCubemap("demo-data/cubemaps/garage_iem.dds", null, session = Session.active)
val cube = boxMesh()
extend(Orbital()) {
}
extend(Orbital())
extend {
drawer.shadeStyle = shadeStyle {
fragmentTransform = """

View File

@@ -7,13 +7,17 @@ fun main() = application {
program {
val cubemap1 = loadCubemap("demo-data/cubemaps/garage_iem.dds", null, session = Session.active)
val cube = boxMesh()
val cubemap2 = cubemap(cubemap1.width, format = cubemap1.format, type = cubemap1.type, levels = 2, session = Session.active)
val cubemap2 = cubemap(
cubemap1.width,
format = cubemap1.format,
type = cubemap1.type,
levels = 2,
session = Session.active
)
cubemap1.copyTo(cubemap2, 0, 0)
cubemap2.generateMipmaps()
extend(Orbital()) {
}
extend(Orbital())
extend {
drawer.shadeStyle = shadeStyle {
fragmentTransform = """

View File

@@ -7,7 +7,13 @@ fun main() = application {
program {
val cubemap1 = loadCubemap("demo-data/cubemaps/garage_iem.dds", null, session = Session.active)
val cube = boxMesh()
val cubemap2 = cubemap(cubemap1.width, format = cubemap1.format, type = cubemap1.type, levels = 2, session = Session.active)
val cubemap2 = cubemap(
cubemap1.width,
format = cubemap1.format,
type = cubemap1.type,
levels = 2,
session = Session.active
)
cubemap1.copyTo(cubemap2, 0, 0)
cubemap2.generateMipmaps()
@@ -18,9 +24,7 @@ fun main() = application {
cma.generateMipmaps()
extend(Orbital()) {
}
extend(Orbital())
extend {
drawer.shadeStyle = shadeStyle {
fragmentTransform = """

View File

@@ -1,15 +1,13 @@
import org.openrndr.application
import org.openrndr.draw.loadImage
fun main() {
application {
program {
val image = loadImage("demo-data/images/image-001.dds")
println(image.format)
println(image.type)
extend {
drawer.image(image)
}
fun main() = application {
program {
val image = loadImage("demo-data/images/image-001.dds")
println(image.format)
println(image.type)
extend {
drawer.image(image)
}
}
}

View File

@@ -6,27 +6,25 @@ import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.boxMesh
import org.openrndr.resourceText
fun main() {
application {
program {
val vb = boxMesh()
val shader = Shader.createFromCode(
vsCode = resourceText("/shaders/gs-01.vert"),
gsCode = resourceText("/shaders/gs-01.geom"),
fsCode = resourceText("/shaders/gs-01.frag"),
name = "x"
)
extend(Orbital())
extend {
drawer.clear(ColorRGBa.PINK)
shader.begin()
shader.uniform("offset", mouse.position.xy0)
shader.uniform("view", drawer.view)
shader.uniform("proj", drawer.projection)
shader.uniform("model", drawer.model)
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.TRIANGLES, 0, vb.vertexCount)
shader.end()
}
fun main() = application {
program {
val vb = boxMesh()
val shader = Shader.createFromCode(
vsCode = resourceText("/shaders/gs-01.vert"),
gsCode = resourceText("/shaders/gs-01.geom"),
fsCode = resourceText("/shaders/gs-01.frag"),
name = "x"
)
extend(Orbital())
extend {
drawer.clear(ColorRGBa.PINK)
shader.begin()
shader.uniform("offset", mouse.position.xy0)
shader.uniform("view", drawer.view)
shader.uniform("proj", drawer.projection)
shader.uniform("model", drawer.model)
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.TRIANGLES, 0, vb.vertexCount)
shader.end()
}
}
}

View File

@@ -5,12 +5,11 @@ import org.openrndr.extra.meshgenerators.planeMesh
import org.openrndr.internal.Driver
import org.openrndr.math.Vector3
fun main() = application {
program {
val shader = Shader.createFromCode(vsCode =
"""${Driver.instance.shaderConfiguration()}
val shader = Shader.createFromCode(
vsCode =
"""${Driver.instance.shaderConfiguration(ShaderType.VERTEX)}
in vec3 a_position;
in vec2 a_texCoord0;
in vec3 a_normal;
@@ -21,14 +20,15 @@ void main() {
gl_Position = projMatrix * vec4(a_position, 1.0);
}
""",
fsCode = """${Driver.instance.shaderConfiguration()}
fsCode = """${Driver.instance.shaderConfiguration(ShaderType.FRAGMENT)}
out vec4 o_color;
layout(rgba8) uniform writeonly image2D bla;
void main() {
imageStore(bla, ivec2(30,30), vec4(1.0, 0.0, 0.0, 1.0));
o_color = vec4(1.0);
o_color = vec4(1.0);
}
""", name = "ils")
""", name = "ils"
)
val cb = colorBuffer(128, 128, type = ColorType.UINT8)
val mesh = planeMesh(Vector3.ZERO, Vector3.UNIT_X, Vector3.UNIT_Y, -Vector3.UNIT_Z, 100.0, 100.0)
@@ -44,6 +44,5 @@ void main() {
drawer.clear(ColorRGBa.BLACK)
drawer.image(cb)
}
}
}

View File

@@ -2,7 +2,6 @@ import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.*
fun main() = application {
program {
val cb = colorBuffer(128, 128, type = ColorType.UINT8)
@@ -15,7 +14,6 @@ fun main() = application {
image("image", cb.imageBinding(0, ImageAccess.WRITE))
}
extend {
drawer.shadeStyle = ss
drawer.clear(ColorRGBa.PINK)
drawer.rectangle(0.0, 0.0, 100.0, 100.0)

View File

@@ -1,13 +1,12 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.color.rgb
import org.openrndr.draw.*
fun main() = application {
program {
val cb = colorBuffer(128, 128)
val at = arrayTexture(128, 128, 32)
val vt = volumeTexture(32, 32, 32)
val cb = colorBuffer(128, 128, type = ColorType.UINT8)
val at = arrayTexture(128, 128, 32, type = ColorType.UINT8)
val vt = volumeTexture(32, 32, 32, type = ColorType.UINT8)
extend {
val ss = shadeStyle {
fragmentTransform = """
@@ -16,12 +15,13 @@ fun main() = application {
imageStore(p_at, ivec3(2, 2, 2), vec4(1.0, 0.0, 0.0, 1.0));
""".trimIndent()
parameter("at", at.imageBinding(0, ImageAccess.READ_WRITE))
parameter("image", cb.imageBinding(0, ImageAccess.READ_WRITE))
parameter("vt", vt.imageBinding(0, ImageAccess.READ_WRITE))
image("at", at.imageBinding(0, ImageAccess.READ_WRITE))
image("image", cb.imageBinding(0, ImageAccess.READ_WRITE))
image("vt", vt.imageBinding(0, ImageAccess.READ_WRITE))
}
drawer.shadeStyle = ss
drawer.clear(ColorRGBa.PINK)
drawer.clear(rgb(0.1))
drawer.fill = rgb(0.2)
drawer.rectangle(0.0, 0.0, 100.0, 100.0)
drawer.image(cb, 0.0, 200.0)
}

View File

@@ -33,9 +33,9 @@ fun main() {
stroke = ColorRGBa.PINK
strokeWeight = 8.0
fontMap = font
LineCap.values().forEachIndexed { x, cap ->
LineCap.entries.forEachIndexed { x, cap ->
lineCap = cap
LineJoin.values().forEachIndexed { y, join ->
LineJoin.entries.forEachIndexed { y, join ->
lineJoin = join
val pos = IntVector2(x - 1, y - 1).vector2 * 180.0
isolated {

View File

@@ -8,7 +8,8 @@ fun main() = application {
program {
val style = shadeStyle {
//fragmentTransform = "x_stroke.a *= step(0.5, fract(c_contourPosition / p_dashLen));"
fragmentTransform = "x_stroke.a *= smoothstep(0.0, 1.0, mod(c_contourPosition, p_dashLen)) * smoothstep(p_dashLen, p_dashLen-1.0, mod(c_contourPosition, p_dashLen));"
fragmentTransform =
"x_stroke.a *= smoothstep(0.0, 1.0, mod(c_contourPosition, p_dashLen)) * smoothstep(p_dashLen, p_dashLen-1.0, mod(c_contourPosition, p_dashLen));"
parameter("dashLen", 20.0)
}
extend {
@@ -25,8 +26,7 @@ fun main() = application {
shadeStyle = style
contour(c)
drawer.lineSegment(0.0, 0.0, width*1.0, height*1.0)
drawer.lineSegment(0.0, 0.0, width * 1.0, height * 1.0)
}
}
}

View File

@@ -8,36 +8,34 @@ import org.openrndr.extra.meshgenerators.boxMesh
import org.openrndr.ffmpeg.VideoPlayerFFMPEG
import org.openrndr.math.Vector3
fun main() {
application {
program {
val cube = boxMesh()
val screen = VideoPlayerFFMPEG.fromScreen(
frameRate = 15.0,
imageWidth = 300,
imageHeight = 300
)
fun main() = application {
program {
val cube = boxMesh()
val screen = VideoPlayerFFMPEG.fromScreen(
frameRate = 15.0,
imageWidth = 300,
imageHeight = 300
)
screen.play()
extend {
screen.draw(drawer, true) // update the screen grabber
drawer.isolated {
clear(ColorRGBa.WHITE)
perspective(60.0, width * 1.0 / height, 0.01, 1000.0)
depthWrite = true
depthTestPass = DepthTestPass.LESS_OR_EQUAL
shadeStyle = shadeStyle {
fragmentTransform = "x_fill = texture(p_tex, vec2(1.0-va_texCoord0.x, va_texCoord0.y));"
screen.colorBuffer?.run {
parameter("tex", this)
}
screen.play()
extend {
screen.draw(drawer, true) // update the screen grabber
drawer.isolated {
clear(ColorRGBa.WHITE)
perspective(60.0, width * 1.0 / height, 0.01, 1000.0)
depthWrite = true
depthTestPass = DepthTestPass.LESS_OR_EQUAL
shadeStyle = shadeStyle {
fragmentTransform = "x_fill = texture(p_tex, vec2(1.0-va_texCoord0.x, va_texCoord0.y));"
screen.colorBuffer?.run {
parameter("tex", this)
}
rotate(Vector3.UNIT_Z, 90.0)
translate(0.0, 0.0, -120.0)
rotate(Vector3.UNIT_X, seconds * 10)
scale(90.0)
vertexBuffer(cube, DrawPrimitive.TRIANGLES)
}
rotate(Vector3.UNIT_Z, 90.0)
translate(0.0, 0.0, -120.0)
rotate(Vector3.UNIT_X, seconds * 10)
scale(90.0)
vertexBuffer(cube, DrawPrimitive.TRIANGLES)
}
}
}

View File

@@ -1,5 +1,8 @@
import org.openrndr.application
import org.openrndr.draw.*
import org.openrndr.draw.BufferPrimitiveType
import org.openrndr.draw.shadeStyle
import org.openrndr.draw.shaderStorageBuffer
import org.openrndr.draw.shaderStorageFormat
import java.nio.ByteBuffer
import java.nio.ByteOrder
@@ -46,6 +49,5 @@ fun main() = application {
// Therefore the value of `f1` can vary from frame to frame,
// because we don't know how many times `+= 2.0` was executed.
}
}
}

View File

@@ -7,46 +7,44 @@ import org.openrndr.draw.vertexFormat
import org.openrndr.math.Vector3
import org.openrndr.resourceText
fun main() {
application {
program {
val vb = vertexBuffer(vertexFormat {
position(3)
}, 12)
val shader = Shader.Companion.createFromCode(
vsCode = resourceText("/shaders/ts-01.vert"),
tcsCode = resourceText("/shaders/ts-01.tesc"),
tesCode = resourceText("/shaders/ts-01.tese"),
fsCode = resourceText("/shaders/ts-01.frag"),
name = "x"
)
fun main() = application {
program {
val vb = vertexBuffer(vertexFormat {
position(3)
}, 12)
val shader = Shader.Companion.createFromCode(
vsCode = resourceText("/shaders/ts-01.vert"),
tcsCode = resourceText("/shaders/ts-01.tesc"),
tesCode = resourceText("/shaders/ts-01.tese"),
fsCode = resourceText("/shaders/ts-01.frag"),
name = "x"
)
vb.put {
write(Vector3(0.0, 0.0, 0.0))
write(Vector3(100.0, 0.0, 0.0))
write(Vector3(140.0, 200.0, 0.0))
write(Vector3(200.0, 300.0, 0.0))
write(Vector3(0.0, 0.0, 0.0))
write(Vector3(100.0, 0.0, 0.0))
write(Vector3(140.0, 200.0, 0.0))
write(Vector3(200.0, 400.0, 0.0))
write(Vector3(0.0, 0.0, 0.0))
write(Vector3(100.0, 0.0, 0.0))
write(Vector3(140.0, 200.0, 0.0))
write(Vector3(200.0, 500.0, 0.0))
}
vb.put {
write(Vector3(0.0, 0.0, 0.0))
write(Vector3(100.0, 0.0, 0.0))
write(Vector3(140.0, 200.0, 0.0))
write(Vector3(200.0, 300.0, 0.0))
write(Vector3(0.0, 0.0, 0.0))
write(Vector3(100.0, 0.0, 0.0))
write(Vector3(140.0, 200.0, 0.0))
write(Vector3(200.0, 400.0, 0.0))
write(Vector3(0.0, 0.0, 0.0))
write(Vector3(100.0, 0.0, 0.0))
write(Vector3(140.0, 200.0, 0.0))
write(Vector3(200.0, 500.0, 0.0))
}
extend {
drawer.clear(ColorRGBa.PINK)
shader.begin()
shader.uniform("offset", mouse.position.xy0)
shader.uniform("view", drawer.view)
shader.uniform("proj", drawer.projection)
shader.uniform("model", drawer.model)
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
extend {
drawer.clear(ColorRGBa.PINK)
shader.begin()
shader.uniform("offset", mouse.position.xy0)
shader.uniform("view", drawer.view)
shader.uniform("proj", drawer.projection)
shader.uniform("model", drawer.model)
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
shader.end()
}
shader.end()
}
}
}

View File

@@ -7,45 +7,43 @@ import org.openrndr.draw.vertexFormat
import org.openrndr.resourceText
import org.openrndr.shape.Ellipse
fun main() {
application {
program {
val ellipse = Ellipse(width/2.0, height/2.0, 100.0, 300.0).contour
fun main() = application {
program {
val ellipse = Ellipse(width / 2.0, height / 2.0, 100.0, 300.0).contour
val vb = vertexBuffer(vertexFormat {
position(3)
}, ellipse.segments.size * 4)
val vb = vertexBuffer(vertexFormat {
position(3)
}, ellipse.segments.size * 4)
val shader = Shader.createFromCode(
vsCode = resourceText("/shaders/ts-02.vert"),
tcsCode = resourceText("/shaders/ts-02.tesc"),
tesCode = resourceText("/shaders/ts-02.tese"),
gsCode = resourceText("/shaders/ts-02.geom"),
fsCode = resourceText("/shaders/ts-02.frag"),
name = "x"
)
val shader = Shader.createFromCode(
vsCode = resourceText("/shaders/ts-02.vert"),
tcsCode = resourceText("/shaders/ts-02.tesc"),
tesCode = resourceText("/shaders/ts-02.tese"),
gsCode = resourceText("/shaders/ts-02.geom"),
fsCode = resourceText("/shaders/ts-02.frag"),
name = "x"
)
vb.put {
for (segment in ellipse.segments) {
val cubic = segment.cubic
write(cubic.start.xy0)
write(cubic.control[0].xy0)
write(cubic.control[1].xy0)
write(cubic.end.xy0)
}
vb.put {
for (segment in ellipse.segments) {
val cubic = segment.cubic
write(cubic.start.xy0)
write(cubic.control[0].xy0)
write(cubic.control[1].xy0)
write(cubic.end.xy0)
}
}
extend {
drawer.clear(ColorRGBa.PINK)
shader.begin()
shader.uniform("offset", mouse.position.xy0)
shader.uniform("view", drawer.view)
shader.uniform("proj", drawer.projection)
shader.uniform("model", drawer.model)
shader.uniform("resolution", ((mouse.position.x / width) * 63 + 1).toInt())
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
shader.end()
}
extend {
drawer.clear(ColorRGBa.PINK)
shader.begin()
shader.uniform("offset", mouse.position.xy0)
shader.uniform("view", drawer.view)
shader.uniform("proj", drawer.projection)
shader.uniform("model", drawer.model)
shader.uniform("resolution", ((mouse.position.x / width) * 63 + 1).toInt())
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
shader.end()
}
}
}

View File

@@ -7,51 +7,49 @@ import org.openrndr.draw.vertexFormat
import org.openrndr.resourceText
import org.openrndr.shape.Ellipse
fun main() {
application {
program {
fun main() = application {
program {
val ellipse = Ellipse(width/2.0, height/2.0, 100.0, 200.0).contour
val ellipse = Ellipse(width / 2.0, height / 2.0, 100.0, 200.0).contour
val vb = vertexBuffer(vertexFormat {
position(3)
}, ellipse.segments.size * 4)
val vb = vertexBuffer(vertexFormat {
position(3)
}, ellipse.segments.size * 4)
val shader = Shader.createFromCode(
vsCode = resourceText("/shaders/ts-03.vert"),
tcsCode = resourceText("/shaders/ts-03.tesc"),
tesCode = resourceText("/shaders/ts-03.tese"),
gsCode = resourceText("/shaders/ts-03.geom"),
fsCode = resourceText("/shaders/ts-03.frag"),
name = "x"
)
val shader = Shader.createFromCode(
vsCode = resourceText("/shaders/ts-03.vert"),
tcsCode = resourceText("/shaders/ts-03.tesc"),
tesCode = resourceText("/shaders/ts-03.tese"),
gsCode = resourceText("/shaders/ts-03.geom"),
fsCode = resourceText("/shaders/ts-03.frag"),
name = "x"
)
vb.put {
for (segment in ellipse.segments) {
val cubic = segment.cubic
write(cubic.start.xy0)
write(cubic.control[0].xy0)
write(cubic.control[1].xy0)
write(cubic.end.xy0)
}
vb.put {
for (segment in ellipse.segments) {
val cubic = segment.cubic
write(cubic.start.xy0)
write(cubic.control[0].xy0)
write(cubic.control[1].xy0)
write(cubic.end.xy0)
}
}
extend {
drawer.clear(ColorRGBa.PINK)
drawer.translate(width/2.0, height/2.0, 0.0)
drawer.rotate(seconds*45.0)
drawer.translate(-width/2.0, -height/2.0, 0.0)
extend {
drawer.clear(ColorRGBa.PINK)
drawer.translate(width / 2.0, height / 2.0, 0.0)
drawer.rotate(seconds * 45.0)
drawer.translate(-width / 2.0, -height / 2.0, 0.0)
shader.begin()
shader.uniform("offset", mouse.position.xy0)
shader.uniform("view", drawer.view)
shader.uniform("proj", drawer.projection)
shader.uniform("model", drawer.model)
shader.uniform("resolution", ((mouse.position.x / width) * 63 + 1).toInt())
shader.uniform("weight",((mouse.position.y / height) * 128 + 1) )
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
shader.end()
}
shader.begin()
shader.uniform("offset", mouse.position.xy0)
shader.uniform("view", drawer.view)
shader.uniform("proj", drawer.projection)
shader.uniform("model", drawer.model)
shader.uniform("resolution", ((mouse.position.x / width) * 63 + 1).toInt())
shader.uniform("weight", ((mouse.position.y / height) * 128 + 1))
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
shader.end()
}
}
}

View File

@@ -1,73 +1,67 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.*
import org.openrndr.extra.noise.uniform
import org.openrndr.extra.noise.uniformRing
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.camera.OrbitalCamera
import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.extra.noise.uniformRing
import org.openrndr.extra.shaderphrases.preprocessedFromUrls
import org.openrndr.math.Vector3
import org.openrndr.resourceUrl
import org.openrndr.shape.Ellipse
import org.openrndr.shape.path3D
import org.openrndr.extra.shaderphrases.preprocessedFromUrls
import kotlin.math.cos
fun main() {
application {
program {
extend(Orbital())
fun main() = application {
program {
extend(Orbital())
val path = path3D {
moveTo(Vector3.ZERO)
for (i in 0 until 100) {
continueTo(anchor + Vector3.uniformRing(0.0, 10.0),anchor + Vector3.uniformRing(0.0, 10.0))
val path = path3D {
moveTo(Vector3.ZERO)
for (i in 0 until 100) {
continueTo(anchor + Vector3.uniformRing(0.0, 10.0), anchor + Vector3.uniformRing(0.0, 10.0))
}
}
val vb = vertexBuffer(vertexFormat {
position(3)
}, path.segments.size * 4)
val shader = Shader.preprocessedFromUrls(
vsUrl = resourceUrl("/shaders/ts-04.vert"),
tcsUrl = resourceUrl("/shaders/ts-04.tesc"),
tesUrl = resourceUrl("/shaders/ts-04.tese"),
gsUrl = resourceUrl("/shaders/ts-04.geom"),
fsUrl = resourceUrl("/shaders/ts-04.frag")
)
val mesh = sphereMesh()
extend {
val vc = vb.put {
for (segment in path.sub(0.0, cos(seconds * 0.1) * 0.5 + 0.5).segments) {
val cubic = segment.cubic
write(cubic.start)
write(cubic.control[0])
write(cubic.control[1])
write(cubic.end)
}
}
val vb = vertexBuffer(vertexFormat {
position(3)
}, path.segments.size * 4)
drawer.clear(ColorRGBa.PINK)
drawer.depthTestPass = DepthTestPass.LESS_OR_EQUAL
drawer.depthWrite = true
drawer.vertexBuffer(mesh, DrawPrimitive.TRIANGLES)
val shader = Shader.preprocessedFromUrls(
vsUrl = resourceUrl("/shaders/ts-04.vert"),
tcsUrl = resourceUrl("/shaders/ts-04.tesc"),
tesUrl = resourceUrl("/shaders/ts-04.tese"),
gsUrl = resourceUrl("/shaders/ts-04.geom"),
fsUrl = resourceUrl("/shaders/ts-04.frag")
)
shader.begin()
shader.uniform("offset", mouse.position.xy0)
shader.uniform("view", drawer.view)
shader.uniform("proj", drawer.projection)
shader.uniform("model", drawer.model)
shader.uniform("resolution", 32)
shader.uniform("weight", 3.0 + cos(seconds))
shader.uniform("time", seconds * 0.0)
drawer.depthWrite = false
val mesh = sphereMesh()
extend {
val vc = vb.put {
for (segment in path.sub(0.0, cos(seconds*0.1)*0.5+ 0.5).segments) {
val cubic = segment.cubic
write(cubic.start)
write(cubic.control[0])
write(cubic.control[1])
write(cubic.end)
}
}
drawer.clear(ColorRGBa.PINK)
drawer.depthTestPass = DepthTestPass.LESS_OR_EQUAL
drawer.depthWrite = true
drawer.vertexBuffer(mesh, DrawPrimitive.TRIANGLES)
shader.begin()
shader.uniform("offset", mouse.position.xy0)
shader.uniform("view", drawer.view)
shader.uniform("proj", drawer.projection)
shader.uniform("model", drawer.model)
shader.uniform("resolution", 32)
shader.uniform("weight", 3.0 + cos(seconds))
shader.uniform("time", seconds*0.0)
drawer.depthWrite = false
driver.setState(drawer.drawStyle)
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vc)
shader.end()
drawer.fill = ColorRGBa.WHITE
}
driver.setState(drawer.drawStyle)
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vc)
shader.end()
drawer.fill = ColorRGBa.WHITE
}
}
}

View File

@@ -4,7 +4,7 @@ import org.openrndr.draw.*
fun main() = application {
program {
val volumeTexture = VolumeTexture.create(128,128,32, type = ColorType.UINT8)
val volumeTexture = VolumeTexture.create(128, 128, 32, type = ColorType.UINT8)
val rt = renderTarget(128, 128) {
volumeTexture(volumeTexture, 0)
}

View File

@@ -31,9 +31,11 @@ fun main() = application {
// Rectangles with the bottom right corner centered in the window
drawer.rectangles(List(10) {
Rectangle(drawer.bounds.center,
-squareSize * 2 + it * 10,
-squareSize * 2 + it * 10)
Rectangle(
drawer.bounds.center,
-squareSize * 2 + it * 10,
-squareSize * 2 + it * 10
)
})
}
}

View File

@@ -11,10 +11,9 @@ fun main() = application {
drawer.stroke = ColorRGBa.WHITE
drawer.strokeWeight = 2.0
drawer.rectangles {
for (y in 0 until height/20) {
for (x in 0 until width/20) {
rectangle(x * 20.0, y * 20.0, 10.0, 15.0, (x + y) * 10.0 + seconds*90.0)
for (y in 0 until height / 20) {
for (x in 0 until width / 20) {
rectangle(x * 20.0, y * 20.0, 10.0, 15.0, (x + y) * 10.0 + seconds * 90.0)
}
}
}

View File

@@ -49,6 +49,56 @@ for (c in cs blend (width / 40)) {
Two color spaces are added: `ColorHSLUVa` and `ColorHPLUVa`, they are an implementation of the colorspaces presented at [hsluv.org](http://www.hsluv.org)
<!-- __demos__ -->
## Demos
### colormap/DemoSpectralZucconiColormap
[source code](src/jvmDemo/kotlin/colormap/DemoSpectralZucconiColormap.kt)
![colormap-DemoSpectralZucconiColormapKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colormap-DemoSpectralZucconiColormapKt.png)
### colormap/DemoSpectralZucconiColormapPhrase
[source code](src/jvmDemo/kotlin/colormap/DemoSpectralZucconiColormapPhrase.kt)
![colormap-DemoSpectralZucconiColormapPhraseKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colormap-DemoSpectralZucconiColormapPhraseKt.png)
### colormap/DemoSpectralZucconiColormapPlot
[source code](src/jvmDemo/kotlin/colormap/DemoSpectralZucconiColormapPlot.kt)
![colormap-DemoSpectralZucconiColormapPlotKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colormap-DemoSpectralZucconiColormapPlotKt.png)
### colormap/DemoTurboColormap
[source code](src/jvmDemo/kotlin/colormap/DemoTurboColormap.kt)
![colormap-DemoTurboColormapKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colormap-DemoTurboColormapKt.png)
### colormap/DemoTurboColormapPhrase
[source code](src/jvmDemo/kotlin/colormap/DemoTurboColormapPhrase.kt)
![colormap-DemoTurboColormapPhraseKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colormap-DemoTurboColormapPhraseKt.png)
### colormap/DemoTurboColormapPlot
[source code](src/jvmDemo/kotlin/colormap/DemoTurboColormapPlot.kt)
![colormap-DemoTurboColormapPlotKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colormap-DemoTurboColormapPlotKt.png)
### colorRange/DemoColorRange01
[source code](src/jvmDemo/kotlin/colorRange/DemoColorRange01.kt)
![colorRange-DemoColorRange01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colorRange-DemoColorRange01Kt.png)
### colorRange/DemoColorRange02
[source code](src/jvmDemo/kotlin/colorRange/DemoColorRange02.kt)
![colorRange-DemoColorRange02Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colorRange-DemoColorRange02Kt.png)
### colorRange/DemoColorRange03
[source code](src/jvmDemo/kotlin/colorRange/DemoColorRange03.kt)
![colorRange-DemoColorRange03Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colorRange-DemoColorRange03Kt.png)
### colorRange/DemoColorRange04
[source code](src/jvmDemo/kotlin/colorRange/DemoColorRange04.kt)
![colorRange-DemoColorRange04Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colorRange-DemoColorRange04Kt.png)
### DemoColorPalette01
[source code](src/jvmDemo/kotlin/DemoColorPalette01.kt)
@@ -69,26 +119,6 @@ Two color spaces are added: `ColorHSLUVa` and `ColorHPLUVa`, they are an impleme
![DemoColorPlane02Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoColorPlane02Kt.png)
### DemoColorRange01
[source code](src/jvmDemo/kotlin/DemoColorRange01.kt)
![DemoColorRange01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoColorRange01Kt.png)
### DemoColorRange02
[source code](src/jvmDemo/kotlin/DemoColorRange02.kt)
![DemoColorRange02Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoColorRange02Kt.png)
### DemoColorRange03
[source code](src/jvmDemo/kotlin/DemoColorRange03.kt)
![DemoColorRange03Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoColorRange03Kt.png)
### DemoColorRange04
[source code](src/jvmDemo/kotlin/DemoColorRange04.kt)
![DemoColorRange04Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoColorRange04Kt.png)
### DemoColorSequence01
[source code](src/jvmDemo/kotlin/DemoColorSequence01.kt)
@@ -109,21 +139,6 @@ Two color spaces are added: `ColorHSLUVa` and `ColorHPLUVa`, they are an impleme
![DemoFettePalette02Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoFettePalette02Kt.png)
### DemoHistogram01
[source code](src/jvmDemo/kotlin/DemoHistogram01.kt)
![DemoHistogram01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoHistogram01Kt.png)
### DemoHistogram02
[source code](src/jvmDemo/kotlin/DemoHistogram02.kt)
![DemoHistogram02Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoHistogram02Kt.png)
### DemoHistogram03
[source code](src/jvmDemo/kotlin/DemoHistogram03.kt)
![DemoHistogram03Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoHistogram03Kt.png)
### DemoHSLUV01
[source code](src/jvmDemo/kotlin/DemoHSLUV01.kt)
@@ -149,37 +164,22 @@ Two color spaces are added: `ColorHSLUVa` and `ColorHPLUVa`, they are an impleme
![DemoOKHSV01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoOKHSV01Kt.png)
### DemoSpectralZucconiColormap
[source code](src/jvmDemo/kotlin/DemoSpectralZucconiColormap.kt)
![DemoSpectralZucconiColormapKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoSpectralZucconiColormapKt.png)
### DemoSpectralZucconiColormapPhrase
[source code](src/jvmDemo/kotlin/DemoSpectralZucconiColormapPhrase.kt)
![DemoSpectralZucconiColormapPhraseKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoSpectralZucconiColormapPhraseKt.png)
### DemoSpectralZucconiColormapPlot
[source code](src/jvmDemo/kotlin/DemoSpectralZucconiColormapPlot.kt)
![DemoSpectralZucconiColormapPlotKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoSpectralZucconiColormapPlotKt.png)
### DemoTurboColormap
[source code](src/jvmDemo/kotlin/DemoTurboColormap.kt)
![DemoTurboColormapKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoTurboColormapKt.png)
### DemoTurboColormapPhrase
[source code](src/jvmDemo/kotlin/DemoTurboColormapPhrase.kt)
![DemoTurboColormapPhraseKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoTurboColormapPhraseKt.png)
### DemoTurboColormapPlot
[source code](src/jvmDemo/kotlin/DemoTurboColormapPlot.kt)
![DemoTurboColormapPlotKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoTurboColormapPlotKt.png)
### DemoXSLUV01
[source code](src/jvmDemo/kotlin/DemoXSLUV01.kt)
![DemoXSLUV01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoXSLUV01Kt.png)
### histogram/DemoHistogram01
[source code](src/jvmDemo/kotlin/histogram/DemoHistogram01.kt)
![histogram-DemoHistogram01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/histogram-DemoHistogram01Kt.png)
### histogram/DemoHistogram02
[source code](src/jvmDemo/kotlin/histogram/DemoHistogram02.kt)
![histogram-DemoHistogram02Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/histogram-DemoHistogram02Kt.png)
### histogram/DemoHistogram03
[source code](src/jvmDemo/kotlin/histogram/DemoHistogram03.kt)
![histogram-DemoHistogram03Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/histogram-DemoHistogram03Kt.png)

View File

@@ -11,7 +11,10 @@ import org.openrndr.extra.color.spaces.*
* Demonstrates the creation of color palettes using various available methods
*/
fun main() = application {
configure { }
configure {
width = 720
height = 540
}
program {
// HueShiftableColor:
// HPLuv HSL HSV LCHab LCHuv XSL XSV XSLuv HSLuv OKHSL OKHSV OKLCH
@@ -27,34 +30,33 @@ fun main() = application {
palette0.forEachIndexed { i, c ->
drawer.fill = c
drawer.circle(100.0 + i * 40.0, 80.0, 40.0)
drawer.circle(100.0 + i * 50.0, 80.0, 50.0)
}
palette1.forEachIndexed { i, c ->
drawer.fill = c
drawer.circle(100.0 + i * 40.0, 180.0, 40.0)
drawer.circle(100.0 + i * 50.0, 200.0, 50.0)
}
palette2.forEachIndexed { i, c ->
drawer.fill = c
drawer.circle(380.0 + i * 40.0, 180.0, 40.0)
drawer.circle(440.0 + i * 50.0, 200.0, 50.0)
}
palette3.forEachIndexed { i, c ->
drawer.fill = c
drawer.circle(100.0 + i * 40.0, 280.0, 40.0)
drawer.circle(100.0 + i * 50.0, 320.0, 50.0)
}
palette4.forEachIndexed { i, c ->
drawer.fill = c
drawer.circle(350.0 + i * 40.0, 280.0, 40.0)
drawer.circle(400.0 + i * 50.0, 320.0, 50.0)
}
palette5.forEachIndexed { i, c ->
drawer.fill = c
drawer.circle(100.0 + i * 40.0, 380.0, 40.0)
drawer.circle(100.0 + i * 50.0, 440.0, 50.0)
}
}
}
}

View File

@@ -11,6 +11,10 @@ import org.openrndr.extra.color.tools.shadeLuminosity
* an increased dynamic range.
*/
fun main() = application {
configure {
width = 720
height = 360
}
program {
val count = 8
val palette = RGB.PINK.analogous<HSLuv>(360.0, count).mapIndexed { i, c ->

View File

@@ -7,80 +7,75 @@ import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.math.Vector3
import kotlin.math.cos
fun main() {
application {
configure {
width = 800
height = 800
fun main() = application {
configure {
width = 720
height = 720
}
program {
val mesh = sphereMesh(8, 8, radius = 0.1)
}
program {
val mesh = sphereMesh(8, 8, radius = 0.1)
val instanceData = vertexBuffer(
vertexFormat {
attribute("instanceColor", VertexElementType.VECTOR4_FLOAT32)
attribute("instancePosition", VertexElementType.VECTOR3_FLOAT32)
},
90 * 100
)
println(extensions.size)
extend(Orbital())
val instanceData = vertexBuffer(
vertexFormat {
attribute("instanceColor", VertexElementType.VECTOR4_FLOAT32)
attribute("instancePosition", VertexElementType.VECTOR3_FLOAT32)
},
90 * 100
)
println(extensions.size)
extend(Orbital())
extend {
drawer.clear(ColorRGBa.WHITE)
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
extend {
drawer.clear(ColorRGBa.WHITE)
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
instanceData.put {
for (hue in 0 until 360 step 4) {
for (chroma in 0 until 100 step 1) {
val lch = ColorOKLCHa(cos(seconds * 0.1) * 0.5 + 0.5, chroma / 100.0, hue.toDouble())
val srgb = lch.toRGBa().toSRGB().clip()
write(srgb)
write(Vector3((srgb.r - 0.5) * 10.0, (srgb.g - 0.5) * 10.0, (srgb.b - 0.5) * 10.0))
}
instanceData.put {
for (hue in 0 until 360 step 4) {
for (chroma in 0 until 100 step 1) {
val lch = ColorOKLCHa(cos(seconds * 0.1) * 0.5 + 0.5, chroma / 100.0, hue.toDouble())
val srgb = lch.toRGBa().toSRGB().clip()
write(srgb)
write(Vector3((srgb.r - 0.5) * 10.0, (srgb.g - 0.5) * 10.0, (srgb.b - 0.5) * 10.0))
}
}
drawer.isolated {
drawer.shadeStyle = shadeStyle {
}
drawer.isolated {
drawer.shadeStyle = shadeStyle {
vertexTransform = """
vertexTransform = """
x_position += i_instancePosition;
""".trimIndent()
fragmentTransform = """
fragmentTransform = """
x_fill = vi_instanceColor;
""".trimIndent()
}
drawer.vertexBufferInstances(listOf(mesh), listOf(instanceData), DrawPrimitive.TRIANGLES, 90 * 100)
}
drawer.stroke = ColorRGBa.BLACK.opacify(0.25)
drawer.strokeWeight = 10.0
drawer.lineSegments(
listOf(
Vector3(-5.0, -5.0, -5.0), Vector3(5.0, -5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, 5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, 5.0, -5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, -5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, -5.0, 5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, 5.0, -5.0), Vector3(5.0, 5.0, 5.0),
)
)
drawer.vertexBufferInstances(listOf(mesh), listOf(instanceData), DrawPrimitive.TRIANGLES, 90 * 100)
}
drawer.stroke = ColorRGBa.BLACK.opacify(0.25)
drawer.strokeWeight = 10.0
drawer.lineSegments(
listOf(
Vector3(-5.0, -5.0, -5.0), Vector3(5.0, -5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, 5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, 5.0, -5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, -5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, -5.0, 5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, 5.0, -5.0), Vector3(5.0, 5.0, 5.0),
)
)
}
}
}

View File

@@ -7,73 +7,71 @@ import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.math.Vector3
import kotlin.math.cos
fun main() {
application {
configure {
width = 800
height = 800
}
program {
val mesh = sphereMesh(8, 8, radius = 0.1)
fun main() = application {
configure {
width = 720
height = 720
}
program {
val mesh = sphereMesh(8, 8, radius = 0.1)
val instanceData = vertexBuffer(
vertexFormat {
attribute("instanceColor", VertexElementType.VECTOR4_FLOAT32)
attribute("instancePosition", VertexElementType.VECTOR3_FLOAT32)
},
100 * 100
)
extend(Orbital())
extend {
drawer.clear(ColorRGBa.WHITE)
val instanceData = vertexBuffer(
vertexFormat {
attribute("instanceColor", VertexElementType.VECTOR4_FLOAT32)
attribute("instancePosition", VertexElementType.VECTOR3_FLOAT32)
},
100 * 100
)
extend(Orbital())
extend {
drawer.clear(ColorRGBa.WHITE)
drawer.stroke = null
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
instanceData.put {
for (lumo in 0 until 100 step 1) {
for (chroma in 0 until 100 step 1) {
val lch = ColorOKLCHa(lumo / 100.0, chroma / 100.0, cos(seconds * 0.1) * 360.0)
val srgb = lch.toRGBa().toSRGB().clip()
write(srgb)
write(Vector3((srgb.r - 0.5) * 10.0, (srgb.g - 0.5) * 10.0, (srgb.b - 0.5) * 10.0))
}
instanceData.put {
for (lumo in 0 until 100 step 1) {
for (chroma in 0 until 100 step 1) {
val lch = ColorOKLCHa(lumo / 100.0, chroma / 100.0, cos(seconds * 0.1) * 360.0)
val srgb = lch.toRGBa().toSRGB().clip()
write(srgb)
write(Vector3((srgb.r - 0.5) * 10.0, (srgb.g - 0.5) * 10.0, (srgb.b - 0.5) * 10.0))
}
}
drawer.isolated {
drawer.shadeStyle = shadeStyle {
vertexTransform = """
}
drawer.isolated {
drawer.shadeStyle = shadeStyle {
vertexTransform = """
x_position += i_instancePosition;
""".trimIndent()
fragmentTransform = """
fragmentTransform = """
x_fill = vi_instanceColor;
""".trimIndent()
}
drawer.vertexBufferInstances(listOf(mesh), listOf(instanceData), DrawPrimitive.TRIANGLES, 90 * 100)
}
drawer.stroke = ColorRGBa.BLACK.opacify(0.25)
drawer.strokeWeight = 10.0
drawer.lineSegments(
listOf(
Vector3(-5.0, -5.0, -5.0), Vector3(5.0, -5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, 5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, 5.0, -5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, -5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, -5.0, 5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, 5.0, -5.0), Vector3(5.0, 5.0, 5.0),
)
)
drawer.vertexBufferInstances(listOf(mesh), listOf(instanceData), DrawPrimitive.TRIANGLES, 90 * 100)
}
drawer.stroke = ColorRGBa.BLACK.opacify(0.25)
drawer.strokeWeight = 10.0
drawer.lineSegments(
listOf(
Vector3(-5.0, -5.0, -5.0), Vector3(5.0, -5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, 5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, 5.0, -5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, -5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, -5.0, 5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, 5.0, -5.0), Vector3(5.0, 5.0, 5.0),
)
)
}
}
}

View File

@@ -1,52 +0,0 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.loadFont
import org.openrndr.extra.color.spaces.*
import org.openrndr.extra.color.palettes.rangeTo
fun main() {
application {
configure {
height = 30 + 50 * 11 // row count
}
program {
extend {
drawer.clear(ColorRGBa.WHITE)
val colorA = ColorRGBa.BLUE
val colorB = ColorRGBa.PINK
val stepCount = 25
val allSteps = listOf(
"RGB" to (colorA..colorB blend stepCount),
"RGB linear" to (colorA.toLinear()..colorB.toLinear() blend stepCount),
"HSV" to (colorA..colorB.toHSVa() blend stepCount),
"Lab" to (colorA.toLABa()..colorB.toLABa() blend stepCount),
"LCh(ab)" to (colorA.toLCHABa()..colorB.toLCHABa() blend stepCount),
"OKLab" to (colorA.toOKLABa()..colorB.toOKLABa() blend stepCount),
"OKLCh" to (colorA.toOKLCHa()..colorB.toOKLCHa() blend stepCount),
"OKHSV" to (colorA.toOKHSVa()..colorB.toOKHSVa() blend stepCount),
"OKHSL" to (colorA.toOKHSLa()..colorB.toOKHSLa() blend stepCount),
"HSLUV" to (colorA.toHSLUVa()..colorB.toHSLUVa() blend stepCount),
"XSLUV" to (colorA.toXSLUVa()..colorB.toXSLUVa() blend stepCount),
)
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
drawer.translate(20.0, 20.0)
for ((label, steps) in allSteps) {
drawer.fill = ColorRGBa.GRAY.shade(0.25)
drawer.text(label, 0.0, 24.0)
for (i in steps.indices) {
drawer.fill = steps[i].toSRGB()
drawer.rectangle(100.0 + i * 20.0, 0.0, 20.0, 40.0)
}
drawer.translate(0.0, 50.0)
}
}
}
}
}

View File

@@ -1,87 +0,0 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.DrawPrimitive
import org.openrndr.draw.isolated
import org.openrndr.draw.loadFont
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.color.palettes.rangeTo
import org.openrndr.extra.color.spaces.toHSLUVa
import org.openrndr.extra.color.spaces.toOKLABa
import org.openrndr.extra.color.spaces.toOKLCHa
import org.openrndr.extra.color.spaces.toXSLUVa
import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.math.Vector3
fun main() {
application {
configure {
width = 800
height = 800
}
program {
val mesh = sphereMesh(8, 8, radius = 0.1)
extend(Orbital())
extend {
drawer.clear(ColorRGBa.WHITE)
val colorA = ColorRGBa.BLUE.toHSVa().shiftHue(seconds * 40.0).toRGBa()
val colorB = ColorRGBa.PINK.toHSVa().shiftHue(-seconds * 34.0).toRGBa()
val stepCount = 25
val allSteps = listOf(
"RGB" to (colorA..colorB blend stepCount),
"RGB linear" to (colorA.toLinear()..colorB.toLinear() blend stepCount),
"HSV" to (colorA..colorB.toHSVa() blend stepCount),
"Lab" to (colorA.toLABa()..colorB.toLABa() blend stepCount),
"LCh(ab)" to (colorA.toLCHABa()..colorB.toLCHABa() blend stepCount),
"OKLab" to (colorA.toOKLABa()..colorB.toOKLABa() blend stepCount),
"OKLCh" to (colorA.toOKLCHa()..colorB.toOKLCHa() blend stepCount),
"HSLUV" to (colorA.toHSLUVa()..colorB.toHSLUVa() blend stepCount),
"XSLUV" to (colorA.toXSLUVa()..colorB.toXSLUVa() blend stepCount),
)
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
for ((_, steps) in allSteps) {
for (i in steps.indices) {
val srgb = steps[i].toSRGB().clip()
drawer.fill = srgb
drawer.isolated {
drawer.translate((srgb.r - 0.5) * 10.0, (srgb.g - 0.5) * 10.0, (srgb.b - 0.5) * 10.0)
drawer.vertexBuffer(mesh, DrawPrimitive.TRIANGLES)
}
}
val positions = steps.map {
val l = it.toSRGB().clip()
Vector3((l.r - 0.5) * 10.0, (l.g - 0.5) * 10.0, (l.b - 0.5) * 10.0)
}
drawer.stroke = ColorRGBa.BLACK.opacify(0.25)
drawer.strokeWeight = 10.0
drawer.lineStrip(positions)
}
drawer.lineSegments(
listOf(
Vector3(-5.0, -5.0, -5.0), Vector3(5.0, -5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, 5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, 5.0, -5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, -5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, -5.0, 5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, 5.0, -5.0), Vector3(5.0, 5.0, 5.0),
)
)
}
}
}
}

View File

@@ -24,45 +24,43 @@ import org.openrndr.math.Vector3
* - Applying a custom fragment shader with a palette-based shading style.
* - Rendering a grid of 3D spheres, each transformed and rotated to create a dynamic pattern.
*/
fun main() {
application {
configure {
width = 720
height = 720
}
program {
val cs = ColorSequence(
listOf(
0.0 to ColorRGBa.PINK,
0.25 to ColorRGBa.ORANGE.toOKLABa(),
0.27 to ColorRGBa.WHITE.toOKLABa(),
0.32 to ColorRGBa.BLUE,
1.0 to ColorRGBa.MEDIUM_AQUAMARINE
)
fun main() = application {
configure {
width = 720
height = 720
}
program {
val cs = ColorSequence(
listOf(
0.0 to ColorRGBa.PINK,
0.25 to ColorRGBa.ORANGE.toOKLABa(),
0.27 to ColorRGBa.WHITE.toOKLABa(),
0.32 to ColorRGBa.BLUE,
1.0 to ColorRGBa.MEDIUM_AQUAMARINE
)
val palette = cs.toColorBuffer(drawer, 256, 16)
val sphere = sphereMesh(sides = 48, segments = 48)
)
val palette = cs.toColorBuffer(drawer, 256, 16)
val sphere = sphereMesh(sides = 48, segments = 48)
extend(Orbital()) {
fov = 50.0
eye = Vector3(0.0, 0.0, 13.0)
}
extend {
drawer.shadeStyle = shadeStyle {
fragmentTransform = """
extend(Orbital()) {
fov = 50.0
eye = Vector3(0.0, 0.0, 13.0)
}
extend {
drawer.shadeStyle = shadeStyle {
fragmentTransform = """
float d = normalize(va_normal).z;
x_fill = texture(p_palette, vec2(1.0-d, 0.0));
""".trimIndent()
parameter("palette", palette)
}
for (j in -2..2) {
for (i in -2..2) {
drawer.isolated {
drawer.translate(i * 2.0, j * 2.0, 0.0)
drawer.rotate(Vector3.UNIT_Y, j * 30.0)
drawer.rotate(Vector3.UNIT_X, i * 30.0)
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
}
parameter("palette", palette)
}
for (j in -2..2) {
for (i in -2..2) {
drawer.isolated {
drawer.translate(i * 2.0, j * 2.0, 0.0)
drawer.rotate(Vector3.UNIT_Y, j * 30.0)
drawer.rotate(Vector3.UNIT_X, i * 30.0)
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
}
}
}

View File

@@ -4,33 +4,31 @@ import org.openrndr.extra.color.spaces.toOKHSVa
import org.openrndr.extra.color.statistics.deltaE76
import org.openrndr.math.Polar
fun main() {
application {
configure {
width = 720
height = 720
}
program {
extend {
drawer.clear(ColorRGBa.BLACK)
drawer.fill = null
drawer.stroke = ColorRGBa.WHITE.opacify(0.2)
for (i in 10 until 270 step 10) {
drawer.circle(drawer.bounds.center, i.toDouble())
}
fun main() = application {
configure {
width = 720
height = 720
}
program {
extend {
drawer.clear(ColorRGBa.BLACK)
drawer.fill = null
drawer.stroke = ColorRGBa.WHITE.opacify(0.2)
for (i in 10 until 270 step 10) {
drawer.circle(drawer.bounds.center, i.toDouble())
}
drawer.stroke = null
drawer.stroke = null
val startColor = ColorRGBa.RED.toOKHSVa().shiftHue(seconds*36.0).toRGBa()
drawer.circles {
for (j in 99 downTo 0) {
for (i in 0 until 360 step 10) {
val color = startColor.toOKHSVa().shiftHue(i.toDouble()).saturate(j / 99.0).toRGBa()
val distance = color.deltaE76(startColor)
val p = Polar(seconds * 36.0 + i.toDouble(), distance).cartesian + drawer.bounds.center
fill = color
circle(p, 2.0)
}
val startColor = ColorRGBa.RED.toOKHSVa().shiftHue(seconds * 36.0).toRGBa()
drawer.circles {
for (j in 99 downTo 0) {
for (i in 0 until 360 step 10) {
val color = startColor.toOKHSVa().shiftHue(i.toDouble()).saturate(j / 99.0).toRGBa()
val distance = color.deltaE76(startColor)
val p = Polar(seconds * 36.0 + i.toDouble(), distance).cartesian + drawer.bounds.center
fill = color
circle(p, 2.0)
}
}
}

View File

@@ -6,81 +6,79 @@ import org.openrndr.extra.color.fettepalette.generateColorRamp
import org.openrndr.math.Vector2
import kotlin.random.Random
fun main() {
application {
configure {
width = 720
height = 720
}
fun main() = application {
configure {
width = 720
height = 720
}
program {
val total = 9
extend {
val ramp = generateColorRamp(
total = total,
centerHue = (mouse.position.x / width) * 360.0,
curveMethod = Lamé,
hueCycle = mouse.position.y / height,
curveAccent = 0.0,
offsetTint = 0.01,
offsetShade = 0.01,
tintShadeHueShift = 0.01,
offsetCurveModTint = 0.03,
offsetCurveModShade = 0.03,
minSaturationLight = Vector2.ZERO,
maxSaturationLight = Vector2.ONE,
useOK = true
)
fun rampSquare(ramp: ColorRamp, random: Random, position: Vector2, width: Double) {
drawer.isolated {
drawer.fill = ramp.baseColors.random(random).toRGBa()
drawer.stroke = null
drawer.rectangle(position, width, width)
drawer.fill = ramp.lightColors.random(random).toRGBa()
drawer.rectangle(position + Vector2(width / 4.0, width / 4.0), width / 4.0, width / 2.0)
val dc = ramp.darkColors.shuffled(random).take(2)
drawer.fill = dc[0].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 4.0), width / 4.0, width / 4.0)
drawer.fill = dc[1].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 2.0), width / 4.0, width / 4.0)
}
}
program {
val total = 9
extend {
val ramp = generateColorRamp(
total = total,
centerHue = (mouse.position.x / width) * 360.0,
curveMethod = Lamé,
hueCycle = mouse.position.y / height,
curveAccent = 0.0,
offsetTint = 0.01,
offsetShade = 0.01,
tintShadeHueShift = 0.01,
offsetCurveModTint = 0.03,
offsetCurveModShade = 0.03,
minSaturationLight = Vector2.ZERO,
maxSaturationLight = Vector2.ONE,
useOK = true
)
fun rampSquare(ramp: ColorRamp, random: Random, position: Vector2, width: Double) {
drawer.isolated {
for ((index, i) in ramp.lightColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 20.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.baseColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 70.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.darkColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 120.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.fill = ramp.baseColors.random(random).toRGBa()
drawer.stroke = null
drawer.rectangle(position, width, width)
val random = Random(seconds.toInt())
rampSquare(ramp, random, Vector2(180.0, 180.0), 360.0)
drawer.fill = ramp.lightColors.random(random).toRGBa()
drawer.rectangle(position + Vector2(width / 4.0, width / 4.0), width / 4.0, width / 2.0)
val dc = ramp.darkColors.shuffled(random).take(2)
drawer.fill = dc[0].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 4.0), width / 4.0, width / 4.0)
drawer.fill = dc[1].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 2.0), width / 4.0, width / 4.0)
}
}
drawer.isolated {
for ((index, i) in ramp.lightColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 20.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.baseColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 70.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.darkColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 120.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
val random = Random(seconds.toInt())
rampSquare(ramp, random, Vector2(180.0, 180.0), 360.0)
}
}
}

View File

@@ -8,70 +8,68 @@ import org.openrndr.extra.gui.addTo
import org.openrndr.math.Vector2
import kotlin.random.Random
fun main() {
application {
configure {
width = 720
height = 720
}
fun main() = application {
configure {
width = 720
height = 720
}
program {
val gui = GUI()
val parameters = ColorRampParameters()
parameters.addTo(gui)
extend(gui)
extend {
val ramp = generateColorRamp(parameters)
fun rampSquare(ramp: ColorRamp, random: Random, position: Vector2, width: Double) {
drawer.isolated {
drawer.fill = ramp.baseColors.random(random).toRGBa()
drawer.stroke = null
drawer.rectangle(position, width, width)
drawer.fill = ramp.lightColors.random(random).toRGBa()
drawer.rectangle(position + Vector2(width / 4.0, width / 4.0), width / 4.0, width / 2.0)
val dc = ramp.darkColors.shuffled(random).take(2)
drawer.fill = dc[0].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 4.0), width / 4.0, width / 4.0)
drawer.fill = dc[1].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 2.0), width / 4.0, width / 4.0)
}
}
drawer.translate(200.0, 0.0)
program {
val gui = GUI()
val parameters = ColorRampParameters()
parameters.addTo(gui)
extend(gui)
extend {
val ramp = generateColorRamp(parameters)
fun rampSquare(ramp: ColorRamp, random: Random, position: Vector2, width: Double) {
drawer.isolated {
for ((index, i) in ramp.lightColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 20.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.baseColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 70.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.darkColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 120.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.fill = ramp.baseColors.random(random).toRGBa()
drawer.stroke = null
drawer.rectangle(position, width, width)
val random = Random(seconds.toInt())
rampSquare(ramp, random, Vector2(20.0, 180.0), 360.0)
drawer.fill = ramp.lightColors.random(random).toRGBa()
drawer.rectangle(position + Vector2(width / 4.0, width / 4.0), width / 4.0, width / 2.0)
val dc = ramp.darkColors.shuffled(random).take(2)
drawer.fill = dc[0].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 4.0), width / 4.0, width / 4.0)
drawer.fill = dc[1].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 2.0), width / 4.0, width / 4.0)
}
}
drawer.translate(200.0, 0.0)
drawer.isolated {
for ((index, i) in ramp.lightColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 20.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.baseColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 70.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.darkColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 120.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
val random = Random(seconds.toInt())
rampSquare(ramp, random, Vector2(20.0, 180.0), 360.0)
}
}
}

View File

@@ -10,37 +10,41 @@ import org.openrndr.extra.color.spaces.ColorHSLUVa
import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
fun main() {
application {
program {
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 26.0)
extend {
drawer.stroke = null
drawer.clear(rgb(0.3))
val s = mouse.position.x / width
val l = mouse.position.y / height
for (a in 0 until 360 step 12) {
val pos = Vector2(0.0, 110.0)
drawer.isolated {
translate(bounds.center)
rotate(a * 1.0)
fun main() = application {
configure {
width = 720
height = 540
}
program {
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 26.0)
extend {
drawer.stroke = null
drawer.clear(rgb(0.3))
val s = mouse.position.x / width
val l = mouse.position.y / height
for (a in 0 until 360 step 12) {
val pos = Vector2(0.0, 110.0)
drawer.isolated {
translate(bounds.center)
rotate(a * 1.0)
fill = ColorHSLUVa(a * 1.0, s, l).toRGBa().toSRGB()
rectangle(Rectangle(pos * 1.2, 40.0, 300.0))
fill = ColorHSLUVa(a * 1.0, s, l).toRGBa().toSRGB()
rectangle(Rectangle(pos * 1.2, 40.0, 300.0))
fill = ColorHSLa(a * 1.0, s, l).toRGBa()
rectangle(Rectangle.fromCenter(pos, 30.0, 60.0))
}
fill = ColorHSLa(a * 1.0, s, l).toRGBa()
rectangle(Rectangle.fromCenter(pos, 30.0, 60.0))
}
drawer.fontMap = font
drawer.fill = if(l > 0.8) ColorRGBa.BLACK else ColorRGBa.WHITE
drawer.text("HSLa", width * 0.48, height * 0.73)
drawer.text("HSLUVa", width * 0.8, height * 0.52)
drawer.text("hue: 0 to 360, " +
}
drawer.fontMap = font
drawer.fill = if (l > 0.8) ColorRGBa.BLACK else ColorRGBa.WHITE
drawer.text("HSLa", width * 0.48, height * 0.73)
drawer.text("HSLUVa", width * 0.8, height * 0.52)
drawer.text(
"hue: 0 to 360, " +
"saturation: ${String.format("%.02f", s)}, " +
"lightness: ${String.format("%.02f", l)}",
30.0, 460.0)
}
30.0, height - 30.0
)
}
}
}

View File

@@ -7,39 +7,38 @@ import org.openrndr.math.Polar
import org.openrndr.math.Vector2
import kotlin.math.sqrt
fun main() {
application {
configure {
width = 720
height = 720
fun main() = application {
configure {
width = 720
height = 720
}
val g = Math.PI * 2.0 * (1.0 - 1.0 / 1.61803398875)
fun phyllotaxis(count: Int) = sequence {
for (i in 0 until count) {
yield(Polar(Math.toDegrees(i * 1.0), g * i))
}
}
val g = Math.PI * 2.0 * (1.0 - 1.0 / 1.61803398875)
fun phyllotaxis(count: Int) = sequence {
for (i in 0 until count) {
yield(Polar(Math.toDegrees(i * 1.0), g * i))
}
}
program {
extend {
drawer.clear(ColorRGBa.GRAY)
val color = ColorRGBa.RED
val hc = color.toHSLUVa()
drawer.stroke = null
drawer.strokeWeight = 0.0
program {
extend {
drawer.clear(ColorRGBa.GRAY)
val color = ColorRGBa.RED
val hc = color.toHSLUVa()
drawer.stroke = null
drawer.strokeWeight = 0.0
val count = 400
val bobRadius = 20.0
val count = 400
val bobRadius = 20.0
for (i in phyllotaxis(count)) {
val h = i.theta
val s = i.radius / (count * g)
for (l in 9 downTo 0) {
val position = i.cartesian / (count * g) * (width / 2.0 - bobRadius) + Vector2(width / 2.0, height / 2.0)
drawer.fill = hc.shiftHue(h).saturate(s).shade((9 - l) / 4.5).toRGBa().toSRGB()
drawer.circle(position, sqrt(s) * 20.0 * l / 9.0)
}
for (i in phyllotaxis(count)) {
val h = i.theta
val s = i.radius / (count * g)
for (l in 9 downTo 0) {
val position =
i.cartesian / (count * g) * (width / 2.0 - bobRadius) + Vector2(width / 2.0, height / 2.0)
drawer.fill = hc.shiftHue(h).saturate(s).shade((9 - l) / 4.5).toRGBa().toSRGB()
drawer.circle(position, sqrt(s) * 20.0 * l / 9.0)
}
}
}

View File

@@ -5,36 +5,34 @@ import org.openrndr.extra.color.spaces.OKHSV
import org.openrndr.extra.color.tools.mixHue
import org.openrndr.extra.color.tools.withHue
fun main() {
application {
configure {
width = 800
height = 800
}
program {
extend {
val seedColor = ColorRGBa.PINK
val targetHue = seconds*100.0
fun main() = application {
configure {
width = 720
height = 720
}
program {
extend {
val seedColor = ColorRGBa.PINK
val targetHue = seconds * 100.0
val rows = 10
val columns = 12
val rows = 10
val columns = 12
val cellWidth = width / columns.toDouble()
val cellHeight = height / rows.toDouble()
val cellWidth = width / columns.toDouble()
val cellHeight = height / rows.toDouble()
drawer.stroke = null
for (j in 0 until 10) {
drawer.isolated {
for (i in 0 until columns) {
drawer.fill = seedColor
.withHue<OKHSV>(i * 360.0 / columns)
.mixHue<OKHSV>(targetHue, j / (rows.toDouble()-1.0))
drawer.rectangle(0.0, 0.0, cellWidth, cellHeight)
drawer.translate(cellWidth, 0.0)
}
drawer.stroke = null
for (j in 0 until 10) {
drawer.isolated {
for (i in 0 until columns) {
drawer.fill = seedColor
.withHue<OKHSV>(i * 360.0 / columns)
.mixHue<OKHSV>(targetHue, j / (rows.toDouble() - 1.0))
drawer.rectangle(0.0, 0.0, cellWidth, cellHeight)
drawer.translate(cellWidth, 0.0)
}
drawer.translate(0.0, cellHeight)
}
drawer.translate(0.0, cellHeight)
}
}
}

View File

@@ -3,41 +3,33 @@ import org.openrndr.color.ColorRGBa
import org.openrndr.draw.isolated
import org.openrndr.extra.color.mixing.mixSpectral
import org.openrndr.extra.color.spaces.OKHSV
import org.openrndr.extra.color.spaces.OKLab
import org.openrndr.extra.color.tools.saturate
import org.openrndr.extra.color.tools.shadeLuminosity
import org.openrndr.extra.color.tools.shiftHue
fun main() {
application {
configure {
width = 800
height = 800
}
program {
fun main() = application {
configure {
width = 720
height = 720
}
program {
extend {
val a = ColorRGBa.BLUE.shiftHue<OKHSV>(0.0).saturate<OKHSV>(0.3).shadeLuminosity<OKLab>(0.3)
val b = ColorRGBa.BLUE.shiftHue<OKHSV>(60.0).saturate<OKHSV>(0.8)
extend {
drawer.isolated {
for (i in 0 until 60) {
val c = mixSpectral(a, b, i / 59.0, 0.0, 0.0).toSRGB()
drawer.fill = c
drawer.stroke = null
drawer.rectangle(0.0, 0.0, width / 60.0, 1.0 * height)
for (j in 0 until 60) {
val p = 3.0
val a = ColorRGBa.BLUE.shiftHue<OKHSV>(j * p)
val b = ColorRGBa.BLUE.shiftHue<OKHSV>(j * p + 180.0)
drawer.translate(width / 60.0, 0.0)
drawer.isolated {
for (i in 0 until 60) {
val c = mixSpectral(a, b, i / 59.0, 0.0, 0.0).toSRGB()
drawer.fill = c
drawer.stroke = null
drawer.rectangle(0.0, 0.0, width/60.0, 0.5 * height/60.0)
drawer.fill = a.mix(b, i / 59.0)
drawer.rectangle(0.0, 0.5 * height, width/60.0, 0.5 * height/60.0)
drawer.translate(width/60.0, 0.0)
}
}
drawer.translate(0.0, 0.5 * height/60.0)
}
}
drawer.translate(0.0, 0.5 * height / 60.0)
}
}
}

View File

@@ -1,11 +1,18 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.color.rgb
import org.openrndr.extra.color.spaces.ColorOKHSLa
import org.openrndr.extra.color.spaces.ColorOKHSVa
fun main() = application {
configure {
width = 720
height = 160
}
program {
extend {
drawer.clear(rgb(0.2))
val c = ColorRGBa.GREEN
val okhsv = ColorOKHSVa.fromColorRGBa(c)
val hsv = c.toHSVa()

View File

@@ -3,15 +3,22 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.color.spaces.ColorXSLUVa
import org.openrndr.extra.color.spaces.toHSLUVa
import org.openrndr.math.Polar
import org.openrndr.shape.contour
fun main() {
fun main() = application {
configure {
width = 720
height = 720
}
class Arc(val start: Double, val radius: Double, val length: Double, val height: Double) {
fun split(offset: Double = 0.0): List<Arc> {
val hl = length / 2.0
return listOf(Arc(start, radius + offset, hl, height), Arc(start + hl, radius + offset, hl, height))
return listOf(
Arc(start, radius + offset, hl, height),
Arc(start + hl, radius + offset, hl, height)
)
}
val contour
@@ -31,29 +38,21 @@ fun main() {
this + flatMap { it.split(it.height) }.split(depth - 1)
}
application {
configure {
width = 720
height = 720
}
program {
val arcs = (0..4).map { Arc(it * 90.0 - 45.0, 50.0, 90.0, 50.0) }.split(5)
program {
val arcs = (0..4).map { Arc(it * 90.0 - 45.0, 50.0, 90.0, 50.0) }.split(5)
extend {
drawer.clear(ColorRGBa.GRAY)
val color = ColorRGBa.RED
val hc = color.toHSLUVa()
drawer.stroke = ColorRGBa.BLACK
drawer.strokeWeight = 1.0
drawer.translate(drawer.bounds.center)
val l = if (System.getProperty("takeScreenshot") == "true") 0.7 else mouse.position.y / height
val s = if (System.getProperty("takeScreenshot") == "true") 1.0 else mouse.position.x / width
for (arc in arcs) {
val xsluv = ColorXSLUVa(arc.start + arc.length / 2.0, s, l, 1.0)
drawer.fill = xsluv.toRGBa()
drawer.contour(arc.contour)
}
extend {
drawer.clear(ColorRGBa.GRAY)
val color = ColorRGBa.RED
drawer.stroke = ColorRGBa.BLACK
drawer.strokeWeight = 1.0
drawer.translate(drawer.bounds.center)
val l = if (System.getProperty("takeScreenshot") == "true") 0.7 else mouse.position.y / height
val s = if (System.getProperty("takeScreenshot") == "true") 1.0 else mouse.position.x / width
for (arc in arcs) {
val xsluv = ColorXSLUVa(arc.start + arc.length / 2.0, s, l, 1.0)
drawer.fill = xsluv.toRGBa()
drawer.contour(arc.contour)
}
}
}

View File

@@ -1,3 +1,5 @@
package colorRange
// Comparison of color lists generated by interpolating from
// PINK to BLUE in different color models
@@ -10,6 +12,10 @@ import org.openrndr.math.map
import org.openrndr.shape.Rectangle
fun main() = application {
configure {
width = 720
height = 540
}
program {
val numColors = 10
val colorLists = listOf(

View File

@@ -1,3 +1,5 @@
package colorRange
// Create a colorSequence with multiple color models
import org.openrndr.application
@@ -6,6 +8,10 @@ import org.openrndr.extra.color.palettes.colorSequence
import org.openrndr.extra.color.spaces.toHSLUVa
fun main() = application {
configure {
width = 720
height = 360
}
program {
extend {
val cs = colorSequence(0.0 to ColorRGBa.PINK,

View File

@@ -0,0 +1,53 @@
package colorRange
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.loadFont
import org.openrndr.extra.color.palettes.rangeTo
import org.openrndr.extra.color.spaces.*
fun main() = application {
configure {
width = 720
height = 30 + 50 * 11 // row count
}
program {
extend {
drawer.clear(ColorRGBa.WHITE)
val colorA = ColorRGBa.BLUE
val colorB = ColorRGBa.PINK
val stepCount = 25
val allSteps = listOf(
"RGB" to (colorA..colorB blend stepCount),
"RGB linear" to (colorA.toLinear()..colorB.toLinear() blend stepCount),
"HSV" to (colorA..colorB.toHSVa() blend stepCount),
"Lab" to (colorA.toLABa()..colorB.toLABa() blend stepCount),
"LCh(ab)" to (colorA.toLCHABa()..colorB.toLCHABa() blend stepCount),
"OKLab" to (colorA.toOKLABa()..colorB.toOKLABa() blend stepCount),
"OKLCh" to (colorA.toOKLCHa()..colorB.toOKLCHa() blend stepCount),
"OKHSV" to (colorA.toOKHSVa()..colorB.toOKHSVa() blend stepCount),
"OKHSL" to (colorA.toOKHSLa()..colorB.toOKHSLa() blend stepCount),
"HSLUV" to (colorA.toHSLUVa()..colorB.toHSLUVa() blend stepCount),
"XSLUV" to (colorA.toXSLUVa()..colorB.toXSLUVa() blend stepCount),
)
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
drawer.translate(20.0, 20.0)
for ((label, steps) in allSteps) {
drawer.fill = ColorRGBa.GRAY.shade(0.25)
drawer.text(label, 0.0, 24.0)
for (i in steps.indices) {
drawer.fill = steps[i].toSRGB()
drawer.rectangle(100.0 + i * 20.0, 0.0, 20.0, 40.0)
}
drawer.translate(0.0, 50.0)
}
}
}
}

View File

@@ -0,0 +1,87 @@
package colorRange
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.DrawPrimitive
import org.openrndr.draw.isolated
import org.openrndr.draw.loadFont
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.color.palettes.rangeTo
import org.openrndr.extra.color.spaces.toHSLUVa
import org.openrndr.extra.color.spaces.toOKLABa
import org.openrndr.extra.color.spaces.toOKLCHa
import org.openrndr.extra.color.spaces.toXSLUVa
import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.math.Vector3
fun main() = application {
configure {
width = 720
height = 720
}
program {
val mesh = sphereMesh(8, 8, radius = 0.1)
extend(Orbital())
extend {
drawer.clear(ColorRGBa.WHITE)
val colorA = ColorRGBa.BLUE.toHSVa().shiftHue(seconds * 40.0).toRGBa()
val colorB = ColorRGBa.PINK.toHSVa().shiftHue(-seconds * 34.0).toRGBa()
val stepCount = 25
val allSteps = listOf(
"RGB" to (colorA..colorB blend stepCount),
"RGB linear" to (colorA.toLinear()..colorB.toLinear() blend stepCount),
"HSV" to (colorA..colorB.toHSVa() blend stepCount),
"Lab" to (colorA.toLABa()..colorB.toLABa() blend stepCount),
"LCh(ab)" to (colorA.toLCHABa()..colorB.toLCHABa() blend stepCount),
"OKLab" to (colorA.toOKLABa()..colorB.toOKLABa() blend stepCount),
"OKLCh" to (colorA.toOKLCHa()..colorB.toOKLCHa() blend stepCount),
"HSLUV" to (colorA.toHSLUVa()..colorB.toHSLUVa() blend stepCount),
"XSLUV" to (colorA.toXSLUVa()..colorB.toXSLUVa() blend stepCount),
)
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
for ((_, steps) in allSteps) {
for (i in steps.indices) {
val srgb = steps[i].toSRGB().clip()
drawer.fill = srgb
drawer.isolated {
drawer.translate((srgb.r - 0.5) * 10.0, (srgb.g - 0.5) * 10.0, (srgb.b - 0.5) * 10.0)
drawer.vertexBuffer(mesh, DrawPrimitive.TRIANGLES)
}
}
val positions = steps.map {
val l = it.toSRGB().clip()
Vector3((l.r - 0.5) * 10.0, (l.g - 0.5) * 10.0, (l.b - 0.5) * 10.0)
}
drawer.stroke = ColorRGBa.BLACK.opacify(0.25)
drawer.strokeWeight = 10.0
drawer.lineStrip(positions)
}
drawer.lineSegments(
listOf(
Vector3(-5.0, -5.0, -5.0), Vector3(5.0, -5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, 5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, 5.0, -5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, -5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, -5.0, 5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, 5.0, -5.0), Vector3(5.0, 5.0, 5.0),
)
)
}
}
}

View File

@@ -1,9 +1,15 @@
package colormap
import org.openrndr.application
import org.openrndr.extra.color.colormaps.spectralZucconi6
import org.openrndr.extra.noise.fastFloor
import kotlin.math.sin
fun main() = application {
configure {
width = 720
height = 360
}
program {
extend {
drawer.stroke = null

View File

@@ -1,9 +1,15 @@
package colormap
import org.openrndr.application
import org.openrndr.draw.shadeStyle
import org.openrndr.extra.color.colormaps.ColormapPhraseBook
import org.openrndr.extra.shaderphrases.preprocess
fun main() = application {
configure {
width = 720
height = 360
}
program {
ColormapPhraseBook.register()
val style = shadeStyle {
@@ -11,10 +17,8 @@ fun main() = application {
fragmentTransform = "x_fill.rgb = spectral_zucconi6(c_boundsPosition.x);"
}
extend {
drawer.run {
shadeStyle = style
rectangle(bounds)
}
drawer.shadeStyle = style
drawer.rectangle(drawer.bounds)
}
}
}

View File

@@ -1,3 +1,5 @@
package colormap
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.shadeStyle
@@ -7,22 +9,28 @@ import org.openrndr.extra.shaderphrases.preprocess
import org.openrndr.math.Vector2
fun main() = application {
configure {
width = 720
height = 360
}
program {
ColormapPhraseBook.register()
val backgroundStyle = shadeStyle {
fragmentPreamble = "#pragma import colormap.spectral_zucconi6".preprocess()
fragmentTransform = "x_fill.rgb = spectral_zucconi6(c_boundsPosition.x);"
}
fun getColormapPoints(
block: ColorRGBa.() -> Double
) = List(width) { x ->
Vector2(
x = x.toDouble(),
y = height.toDouble()
- block(spectralZucconi6(x / width.toDouble()))
* height.toDouble()
x.toDouble(),
height.toDouble()
- block(spectralZucconi6(x / width.toDouble()))
* height.toDouble()
)
}
val redPoints = getColormapPoints { r }
val greenPoints = getColormapPoints { g }
val bluePoints = getColormapPoints { b }

View File

@@ -1,9 +1,15 @@
package colormap
import org.openrndr.application
import org.openrndr.extra.color.colormaps.turboColormap
import org.openrndr.extra.noise.fastFloor
import kotlin.math.sin
fun main() = application {
configure {
width = 720
height = 360
}
program {
extend {
drawer.stroke = null

View File

@@ -1,9 +1,15 @@
package colormap
import org.openrndr.application
import org.openrndr.draw.shadeStyle
import org.openrndr.extra.color.colormaps.ColormapPhraseBook
import org.openrndr.extra.shaderphrases.preprocess
fun main() = application {
configure {
width = 720
height = 360
}
program {
ColormapPhraseBook.register()
val style = shadeStyle {
@@ -11,10 +17,8 @@ fun main() = application {
fragmentTransform = "x_fill.rgb = turbo_colormap(c_boundsPosition.x);"
}
extend {
drawer.run {
shadeStyle = style
rectangle(bounds)
}
drawer.shadeStyle = style
drawer.rectangle(drawer.bounds)
}
}
}

View File

@@ -1,3 +1,5 @@
package colormap
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.shadeStyle
@@ -7,6 +9,10 @@ import org.openrndr.extra.shaderphrases.preprocess
import org.openrndr.math.Vector2
fun main() = application {
configure {
width = 720
height = 360
}
program {
ColormapPhraseBook.register()
val backgroundStyle = shadeStyle {

View File

@@ -1,10 +1,14 @@
// Show color histogram of an image
package histogram// Show color histogram of an image
import org.openrndr.application
import org.openrndr.draw.loadImage
import org.openrndr.extra.color.statistics.calculateHistogramRGB
fun main() = application {
configure {
width = 720
height = 540
}
program {
val useColors = 32
val image = loadImage("demo-data/images/image-001.png")
@@ -29,7 +33,7 @@ fun main() = application {
"% of the image colors.")
extend {
drawer.image(image)
drawer.image(image, 0.0, 0.0, width * 1.0, height * 1.0)
drawer.stroke = null
var x = 0.0
topColorsSortedByLuminosity.forEachIndexed { i, (color, freq) ->

View File

@@ -1,4 +1,4 @@
// Show color histogram using non-uniform weighting
package histogram// Show color histogram using non-uniform weighting
import org.openrndr.application
import org.openrndr.draw.loadImage
@@ -6,6 +6,10 @@ import org.openrndr.extra.color.statistics.calculateHistogramRGB
import kotlin.math.pow
fun main() = application {
configure {
width = 720
height = 540
}
program {
val image = loadImage("demo-data/images/image-001.png")
// -- here we use non-uniform weighting, such that bright colors are prioritized
@@ -16,7 +20,7 @@ fun main() = application {
// .subList(0, 32).sortedBy { it.first.toHSLa().h } // sort by hue
extend {
drawer.image(image)
drawer.image(image, 0.0, 0.0, width * 1.0, height * 1.0)
for (i in 0 until 32) {
drawer.fill = colors[i].first
drawer.stroke = null

View File

@@ -1,15 +1,18 @@
// Create a simple rectangle composition based on colors sampled from image
package histogram// Create a simple rectangle composition based on colors sampled from image
import org.openrndr.application
import org.openrndr.draw.loadImage
import org.openrndr.extra.color.statistics.calculateHistogramRGB
fun main() = application {
configure {
width = 720
height = 540
}
program {
val image = loadImage("demo-data/images/image-001.png")
val histogram = calculateHistogramRGB(image)
extend {
drawer.image(image)
for (j in 0 until height step 32) {
for (i in 0 until width step 32) {
drawer.stroke = null

View File

@@ -18,8 +18,8 @@ import org.openrndr.shape.Rectangle
*/
fun main() = application {
configure {
width = 1024
height = 1024
width = 720
height = 720
}
program {

View File

@@ -1,25 +1,23 @@
import org.openrndr.MouseTracker
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.*
import org.openrndr.draw.ColorType
import org.openrndr.draw.constant
import org.openrndr.draw.createEquivalent
import org.openrndr.draw.tint
import org.openrndr.drawImage
import org.openrndr.extra.jumpfill.DirectionalField
import org.openrndr.extra.noise.scatter
import org.openrndr.extra.noise.simplex
import org.openrndr.math.IntVector2
import org.openrndr.math.Vector2
import org.openrndr.math.Vector3
import org.openrndr.math.clamp
import org.openrndr.shape.Rectangle
import kotlin.math.abs
/**
* Create directional distance field and demonstrate signed distance
*/
fun main() = application {
configure {
width = 1024
height = 1024
width = 720
height = 720
}
program {
@@ -37,7 +35,10 @@ fun main() = application {
ddf.shadow.download()
extend {
val p = (mouse.position * ddf.contentScale).toInt().clamp(IntVector2.ZERO, IntVector2(width-1, height-1))
val p = (mouse.position * ddf.contentScale).toInt().clamp(
IntVector2.ZERO,
IntVector2(width - 1, height - 1)
)
val c = ddf.shadow[p.x, p.y]
val sdf3 = Vector3(c.r, c.g, c.b)

View File

@@ -25,8 +25,8 @@ import org.openrndr.shape.Rectangle
*/
fun main() = application {
configure {
width = 1024
height = 1024
width = 720
height = 720
}
program {

View File

@@ -8,6 +8,10 @@ import org.openrndr.extra.fx.patterns.Checkers
import org.openrndr.extra.jumpfill.fx.InnerGlow
fun main() = application {
configure {
width = 720
height = 720
}
program {
val c = compose {
layer {

View File

@@ -8,6 +8,10 @@ import org.openrndr.extra.fx.patterns.Checkers
import org.openrndr.extra.jumpfill.fx.InnerGlow
fun main() = application {
configure {
width = 720
height = 720
}
program {
val c = compose {
layer {

View File

@@ -6,28 +6,26 @@ import org.openrndr.draw.colorBuffer
import org.openrndr.extra.jumpfill.ShapeSDF
import org.openrndr.extra.svg.loadSVG
fun main() {
application {
configure {
width = 1280
height = 720
}
program {
val sdf = ShapeSDF()
val df = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
fun main() = application {
configure {
width = 720
height = 405
}
program {
val sdf = ShapeSDF()
val df = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
sdf.setShapes(shapes)
sdf.apply(emptyArray(), df)
val mouseTracker = MouseTracker(mouse)
val mouseTracker = MouseTracker(mouse)
extend {
if(mouseTracker.pressedButtons.isEmpty())
drawer.image(df)
else
drawer.shapes(shapes)
}
extend {
if(mouseTracker.pressedButtons.isEmpty())
drawer.image(df)
else
drawer.shapes(shapes)
}
}
}

View File

@@ -13,50 +13,48 @@ import org.openrndr.math.transforms.transform
import kotlin.math.min
fun main() {
application {
configure {
width = 1280
height = 720
}
program {
val sdf0 = ShapeSDF()
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
fun main() = application {
configure {
width = 720
height = 405
}
program {
val sdf0 = ShapeSDF()
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val sdf1 = ShapeSDF()
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val sdf1 = ShapeSDF()
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
val union = SDFSmoothIntersection()
val onion = SDFOnion()
val union = SDFSmoothIntersection()
val onion = SDFOnion()
val strokeFill = SDFStrokeFill()
val strokeFill = SDFStrokeFill()
extend {
drawer.clear(ColorRGBa.PINK)
extend {
drawer.clear(ColorRGBa.PINK)
sdf0.setShapes(shapes)
sdf0.setShapes(shapes)
sdf1.setShapes(shapes.map {
it.transform(transform {
translate(1280 / 2.0, 720.0 / 2)
rotate(Vector3.Companion.UNIT_Z, seconds * 45.0 - 30.0)
translate(-1280 / 2.0, -720.0 / 2.0)
})
sdf1.setShapes(shapes.map {
it.transform(transform {
translate(drawer.bounds.center)
rotate(Vector3.Companion.UNIT_Z, seconds * 45.0 - 30.0)
translate(-drawer.bounds.center)
})
})
sdf0.apply(emptyArray(), df0)
sdf1.apply(emptyArray(), df1)
union.radius = 10.0 + min(mouse.position.y, 100.0)
union.apply(arrayOf(df0, df1), df0)
onion.radius = 20.0
onion.apply(df0, df0)
strokeFill.strokeWeight = 2.0
strokeFill.apply(df0, df0)
drawer.image(df0)
}
sdf0.apply(emptyArray(), df0)
sdf1.apply(emptyArray(), df1)
union.radius = 10.0 + min(mouse.position.y, 100.0)
union.apply(arrayOf(df0, df1), df0)
onion.radius = 20.0
onion.apply(df0, df0)
strokeFill.strokeWeight = 2.0
strokeFill.apply(df0, df0)
drawer.image(df0)
}
}
}

View File

@@ -9,47 +9,44 @@ import org.openrndr.extra.jumpfill.draw.SDFStrokeFill
import org.openrndr.extra.jumpfill.ops.SDFSmoothDifference
import org.openrndr.extra.svg.loadSVG
fun main() = application {
configure {
width = 720
height = 405
}
program {
val sdf0 = ShapeSDF()
val sdf1 = ShapeSDF()
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
fun main() {
application {
configure {
width = 1280
height = 720
}
program {
val sdf0 = ShapeSDF()
val sdf1 = ShapeSDF()
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val fd = FluidDistort()
fd.outputUV = true
val fd = FluidDistort()
fd.outputUV = true
val uvmap = colorBuffer(width, height, type = ColorType.FLOAT16)
val uvmap = colorBuffer(width, height, type = ColorType.FLOAT16)
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
val union = SDFSmoothDifference()
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
val union = SDFSmoothDifference()
sdf0.setShapes(shapes)
sdf1.setShapes(shapes)
sdf0.setShapes(shapes)
sdf1.setShapes(shapes)
val strokeFill = SDFStrokeFill()
val strokeFill = SDFStrokeFill()
extend {
drawer.clear(ColorRGBa.PINK)
extend {
drawer.clear(ColorRGBa.PINK)
fd.apply(emptyArray(), uvmap)
fd.apply(emptyArray(), uvmap)
sdf0.useUV = true
sdf0.apply(uvmap, df0)
sdf1.apply(uvmap, df1)
union.radius = 10.0
union.apply(arrayOf(df0, df1), df0)
sdf0.useUV = true
sdf0.apply(uvmap, df0)
sdf1.apply(uvmap, df1)
union.radius = 10.0
union.apply(arrayOf(df0, df1), df0)
strokeFill.strokeWeight = 10.0
strokeFill.apply(df0, df0)
drawer.image(df0)
}
strokeFill.strokeWeight = 10.0
strokeFill.apply(df0, df0)
drawer.image(df0)
}
}
}

View File

@@ -11,52 +11,49 @@ import org.openrndr.extra.jumpfill.ops.SDFSmoothDifference
import org.openrndr.extra.svg.loadSVG
import org.openrndr.shape.Circle
fun main() = application {
configure {
width = 720
height = 405
}
program {
val gui = GUI()
val sdf0 = ShapeSDF()
val sdf1 = ShapeSDF()
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
fun main() {
application {
configure {
width = 1280
height = 720
}
program {
val gui = GUI()
val sdf0 = ShapeSDF()
val sdf1 = ShapeSDF()
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val perturb = Perturb()
perturb.outputUV = true
val perturb = Perturb()
perturb.outputUV = true
val uvmap = colorBuffer(width, height, type = ColorType.FLOAT16)
val uvmap = colorBuffer(width, height, type = ColorType.FLOAT16)
val circleShapes = List(1) { Circle(drawer.bounds.center, 200.0).shape }
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
val circleShapes = List(1) { Circle(width/2.0, height/2.0, 200.0).shape}
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
sdf0.setShapes(circleShapes)
sdf1.setShapes(shapes)
sdf0.setShapes(circleShapes)
sdf1.setShapes(shapes)
val difference = SDFSmoothDifference()
val strokeFill = SDFStrokeFill()
val difference = SDFSmoothDifference()
val strokeFill = SDFStrokeFill()
gui.add(perturb)
extend(gui)
extend {
drawer.clear(ColorRGBa.PINK)
gui.add(perturb)
extend(gui)
extend {
drawer.clear(ColorRGBa.PINK)
perturb.phase = seconds * 0.1
perturb.apply(uvmap, uvmap)
perturb.phase = seconds * 0.1
perturb.apply(uvmap, uvmap)
sdf0.useUV = true
sdf0.apply(uvmap, df0)
sdf1.apply(uvmap, df1)
difference.radius = 10.0
difference.apply(arrayOf(df0, df1), df0)
sdf0.useUV = true
sdf0.apply(uvmap, df0)
sdf1.apply(uvmap, df1)
difference.radius = 10.0
difference.apply(arrayOf(df0, df1), df0)
strokeFill.strokeWeight = 10.0
strokeFill.apply(df0, df0)
drawer.image(df0)
}
strokeFill.strokeWeight = 10.0
strokeFill.apply(df0, df0)
drawer.image(df0)
}
}
}

View File

@@ -11,66 +11,63 @@ import org.openrndr.extra.jumpfill.ops.SDFSmoothDifference
import org.openrndr.extra.svg.loadSVG
import org.openrndr.math.Vector2
import org.openrndr.shape.Circle
import kotlin.math.cos
import kotlin.math.sin
fun main() {
application {
configure {
width = 1280
height = 720
}
program {
val gui = GUI()
val sdf0 = ShapeSDF()
val sdf1 = ShapeSDF()
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
fun main() = application {
configure {
width = 720
height = 405
}
program {
val gui = GUI()
val sdf0 = ShapeSDF()
val sdf1 = ShapeSDF()
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val perturb = Perturb()
val perturb = Perturb()
perturb.outputUV = true
val uvmap = colorBuffer(width, height, type = ColorType.FLOAT16)
val uvmap2 = colorBuffer(width, height, type = ColorType.FLOAT16)
val circleShapes = List(1) { Circle(drawer.bounds.center, 200.0).shape }
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
sdf0.setShapes(circleShapes)
sdf1.setShapes(shapes)
val difference = SDFSmoothDifference()
val strokeFill = SDFStrokeFill()
sdf0.useUV = true
gui.add(sdf0)
gui.add(perturb)
gui.add(strokeFill)
gui.add(difference)
extend(gui)
extend {
drawer.clear(ColorRGBa.PINK)
perturb.offset = Vector2(cos(seconds * 0.2), sin(seconds * 0.2))
perturb.outputUV = true
perturb.phase = seconds * 0.1
perturb.apply(uvmap, uvmap)
val uvmap = colorBuffer(width, height, type = ColorType.FLOAT16)
val uvmap2 = colorBuffer(width, height, type = ColorType.FLOAT16)
perturb.offset = Vector2.ZERO
perturb.outputUV = false
perturb.phase = seconds * 0.05
perturb.apply(uvmap, uvmap2)
val circleShapes = List(1) { Circle(width/2.0, height/2.0, 200.0).shape}
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
sdf0.apply(uvmap2, df0)
sdf1.apply(uvmap2, df1)
sdf0.setShapes(circleShapes)
sdf1.setShapes(shapes)
difference.apply(arrayOf(df0, df1), df0)
val difference = SDFSmoothDifference()
val strokeFill = SDFStrokeFill()
sdf0.useUV = true
gui.add(sdf0)
gui.add(perturb)
gui.add(strokeFill)
gui.add(difference)
extend(gui)
extend {
drawer.clear(ColorRGBa.PINK)
perturb.offset = Vector2(cos(seconds*0.2), sin(seconds*0.2))
perturb.outputUV = true
perturb.phase = seconds * 0.1
perturb.apply(uvmap, uvmap)
perturb.offset = Vector2.ZERO
perturb.outputUV = false
perturb.phase = seconds * 0.05
perturb.apply(uvmap, uvmap2)
sdf0.apply(uvmap2, df0)
sdf1.apply(uvmap2, df1)
difference.apply(arrayOf(df0, df1), df0)
strokeFill.apply(df0, df0)
drawer.image(df0)
}
strokeFill.apply(df0, df0)
drawer.image(df0)
}
}
}

View File

@@ -7,40 +7,38 @@ import org.openrndr.draw.renderTarget
import org.openrndr.extra.jumpfill.fx.Skeleton
import org.openrndr.extra.noise.simplex
fun main() {
application {
configure {
width = 1280
height = 720
}
program {
val skeleton = Skeleton()
fun main() = application {
configure {
width = 720
height = 540
}
program {
val skeleton = Skeleton()
val input = renderTarget(width, height) {
colorBuffer()
}
val field = input.colorBuffer(0).createEquivalent(type = ColorType.FLOAT32)
extend {
drawer.isolatedWithTarget(input) {
// -- draw something interesting
drawer.stroke = null
drawer.clear(ColorRGBa.BLACK)
drawer.fill = ColorRGBa.WHITE
drawer.circle(mouse.position, 300.0)
drawer.fill = ColorRGBa.BLACK
drawer.circle(mouse.position, 150.0)
drawer.fill = ColorRGBa.WHITE
for (i in 0 until 30) {
val time = seconds * 0.25
val x = simplex(i * 20, time) * width / 2 + width / 2
val y = simplex(i * 20 + 5, time) * height / 2 + height / 2
val r = simplex(i*30, time) * 50.0 + 50.0
drawer.circle(x, y, r)
}
val input = renderTarget(width, height) {
colorBuffer()
}
val field = input.colorBuffer(0).createEquivalent(type = ColorType.FLOAT32)
extend {
drawer.isolatedWithTarget(input) {
// -- draw something interesting
drawer.stroke = null
drawer.clear(ColorRGBa.BLACK)
drawer.fill = ColorRGBa.WHITE
drawer.circle(mouse.position, 300.0)
drawer.fill = ColorRGBa.BLACK
drawer.circle(mouse.position, 150.0)
drawer.fill = ColorRGBa.WHITE
for (i in 0 until 30) {
val time = seconds * 0.25
val x = simplex(i * 20, time) * width / 2 + width / 2
val y = simplex(i * 20 + 5, time) * height / 2 + height / 2
val r = simplex(i * 30, time) * 50.0 + 50.0
drawer.circle(x, y, r)
}
skeleton.apply(input.colorBuffer(0), field)
drawer.image(field)
}
skeleton.apply(input.colorBuffer(0), field)
drawer.image(field)
}
}
}

View File

@@ -2,46 +2,43 @@ import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.ColorType
import org.openrndr.draw.createEquivalent
import org.openrndr.draw.isolatedWithTarget
import org.openrndr.draw.renderTarget
import org.openrndr.extra.jumpfill.fx.StraightSkeleton
import org.openrndr.extra.noise.simplex
fun main() {
application {
configure {
width = 1280
height = 720
fun main() = application {
configure {
width = 720
height = 720
}
program {
val straightSkeleton = StraightSkeleton()
val input = renderTarget(width, height) {
colorBuffer()
}
program {
val straightSkeleton = StraightSkeleton()
val input = renderTarget(width, height) {
colorBuffer()
}
val field = input.colorBuffer(0).createEquivalent(type = ColorType.FLOAT32)
val field = input.colorBuffer(0).createEquivalent(type = ColorType.FLOAT32)
extend {
drawer.isolatedWithTarget(input) {
// -- draw something interesting
drawer.stroke = null
drawer.clear(ColorRGBa.BLACK)
drawer.fill = ColorRGBa.WHITE
drawer.circle(mouse.position, 300.0)
drawer.fill = ColorRGBa.BLACK
drawer.circle(mouse.position, 150.0)
drawer.fill = ColorRGBa.WHITE
for (i in 0 until 30) {
val time = seconds * 0.25
val x = simplex(i * 20, time) * width / 2 + width / 2
val y = simplex(i * 20 + 5, time) * height / 2 + height / 2
val r = simplex(i*30, time) * 50.0 + 50.0
drawer.circle(x, y, r)
}
extend {
drawer.isolatedWithTarget(input) {
// -- draw something interesting
drawer.stroke = null
drawer.clear(ColorRGBa.BLACK)
drawer.fill = ColorRGBa.WHITE
drawer.circle(mouse.position, 300.0)
drawer.fill = ColorRGBa.BLACK
drawer.circle(mouse.position, 150.0)
drawer.fill = ColorRGBa.WHITE
for (i in 0 until 30) {
val time = seconds * 0.25
val x = simplex(i * 20, time) * width / 2 + width / 2
val y = simplex(i * 20 + 5, time) * height / 2 + height / 2
val r = simplex(i * 30, time) * 50.0 + 50.0
drawer.circle(x, y, r)
}
straightSkeleton.apply(input.colorBuffer(0), field)
drawer.image(field)
}
straightSkeleton.apply(input.colorBuffer(0), field)
drawer.image(field)
}
}
}

View File

@@ -13,14 +13,14 @@ fun main() = application {
height = 512
}
program {
val rt = renderTarget(512, 512, 1.0) {
val rt = renderTarget(width, height, 1.0) {
colorBuffer(type = ColorType.FLOAT32)
}
val encoder = EncodePoints()
val jf = JumpFlooder(512, 512, encodePoints = Passthrough())
val jf2 = JumpFlooder(512, 512, encodePoints = Passthrough())
val jf = JumpFlooder(width, height, encodePoints = Passthrough())
val jf2 = JumpFlooder(width, height, encodePoints = Passthrough())
val idcontours = IdContourPoints()
val contoured = colorBuffer(512, 512, type = ColorType.FLOAT32)
val contoured = colorBuffer(width, height, type = ColorType.FLOAT32)
extend {
fun plot(x: Double, y: Double, id: Double) {
drawer.fill = ColorRGBa(id, 0.0, 0.0, 1.0)
@@ -53,7 +53,7 @@ fun main() = application {
drawer.image(contoured)
val flooded2 = jf2.jumpFlood(contoured)
drawer.image(flooded2, 512.0, 0.0)
drawer.image(flooded2, width * 1.0, 0.0)
drawer.shadeStyle = shadeStyle {
fragmentTransform = """

View File

@@ -10,11 +10,11 @@ fun main() = application {
height = 512
}
program {
val rt = renderTarget(512, 512, 1.0) {
val rt = renderTarget(width, height, 1.0) {
colorBuffer(type = ColorType.FLOAT32)
}
val flowfield = colorBuffer(512, 512, type = ColorType.FLOAT32)
val flowfield = colorBuffer(width, height, type = ColorType.FLOAT32)
val cluster = ClusteredField(decodeMode = DecodeMode.DISTANCE, outputDistanceToContours = true)

View File

@@ -9,11 +9,11 @@ import org.openrndr.math.Vector2
fun main() = application {
configure {
width = 720
height = 720
width = 512
height = 512
}
program {
val rt = renderTarget(720, 720, 1.0) {
val rt = renderTarget(width, height, 1.0) {
colorBuffer(type = ColorType.FLOAT32)
}
val flowfield = colorBuffer(width, height, type = ColorType.FLOAT32)
@@ -28,9 +28,9 @@ fun main() = application {
val points = drawer.bounds.scatter(20.0)
drawer.points {
for ((index, point) in points.withIndex()) {
fill = ColorRGBa((index+1.0)/points.size, 0.0, 0.0, 1.0)
fill = ColorRGBa((index + 1.0) / points.size, 0.0, 0.0, 1.0)
for (i in 0 until 30) {
point(point + Vector2.uniformRing(15.0, 25.0)* Vector2(1.0, 1.0))
point(point + Vector2.uniformRing(15.0, 25.0) * Vector2(1.0, 1.0))
}
}
}

View File

@@ -1,12 +1,8 @@
<svg version="1.1" baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 1280 720" xml:space="preserve">
<polygon fill="#FF00FF" stroke="#000000" stroke-miterlimit="2.6131" points="1013.8,424.3 1013.8,238 957.1,238 957.1,238
794.7,238 794.7,294.7 957.1,294.7 957.1,318.9 794.7,318.9 794.7,375.6 957.1,375.6 957.1,424.3 794.7,424.3 794.7,481 957.1,481
1013.8,481 1037.8,481 1037.8,424.3 "/>
<path fill="#FF00FF" stroke="#000000" stroke-miterlimit="2.6131" d="M705.7,263.3H576V239h-56.7v119.2l0,0V401h93.2v24.3h-93.2V482
h243.1v-56.7h-93.2V401h93.2V239h-56.7V263.3L705.7,263.3z M705.7,344.3H576V320h129.7V344.3z"/>
<path fill="#FF00FF" d="M356.6,279L356.6,279L356.6,279z"/>
<path fill="#FF00FF" stroke="#000000" stroke-miterlimit="2.6131" d="M356.6,279c-9.2-3.3-19-5-28.8-5c-47.2,0-85.5,38.3-85.5,85.5
s38.3,85.5,85.5,85.5s85.5-38.3,85.5-85.5c0-0.1,0-0.3,0-0.4C413.3,323.1,390.5,291,356.6,279z M327.8,387.4
c-15.7,0-28.4-12.7-28.4-28.4c0-15.7,12.7-28.4,28.4-28.4c15.6,0,28.4,12.7,28.4,28.4C356.1,374.7,343.4,387.4,327.8,387.4z"/>
<rect x="430.1" y="238" fill="#FF00FF" stroke="#000000" stroke-miterlimit="2.6131" width="56.7" height="243"/>
</svg>
<?xml version="1.0" encoding="UTF-8"?>
<svg width="720" height="405" version="1.1" viewBox="0 0 720 405" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><g fill="#f0f">
<path d="m538 166v13.6h-91.3v31.8h91.3v27.3h-91.3v31.8h137v-31.8h-13.5v-104h-123v31.8z" stroke="#000" stroke-miterlimit="2.61"/>
<path d="m397 148h-72.9v-13.6h-31.9v90.8h52.4v13.6h-52.4v31.8h137v-31.8h-52.4v-13.6h52.4v-90.8h-31.9zm0 45.4h-72.9v-13.6h72.9z" stroke="#000" stroke-miterlimit="2.61"/>
<path d="m201 157"/>
<path d="m201 157c-5.17-1.85-10.7-2.8-16.2-2.8-26.5 0-48 21.5-48 47.9 0 26.5 21.5 47.9 48 47.9 26.5 0 48-21.5 48-47.9v-0.224c0-20.2-12.8-38.2-31.9-44.9zm-16.2 60.8c-8.82 0-16-7.12-16-15.9s7.14-15.9 16-15.9c8.77 0 16 7.12 16 15.9-0.0562 8.8-7.19 15.9-16 15.9z" stroke="#000" stroke-miterlimit="2.61"/>
<rect x="242" y="134" width="31.9" height="136" stroke="#000" stroke-miterlimit="2.61"/>
</g></svg>

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 897 B

View File

@@ -16,6 +16,12 @@ fun main() = application {
program {
var time = 0.0
if (System.getProperty("takeScreenshot") == "true") {
extensions.filterIsInstance<SingleScreenshot>().forEach {
it.delayFrames = 200
}
}
// ------------------------------------------------------------
// By default OPENRNDR clears the canvas on each animation
// frame. NoClear disables that behavior, letting you
@@ -29,11 +35,6 @@ fun main() = application {
backdrop = { drawer.clear(rgb(0.15)) }
}
if (System.getProperty("takeScreenshot") == "true") {
extensions.filterIsInstance<SingleScreenshot>().forEach {
it.delayFrames = 60
}
}
extend {
// Draw something. For this demo *what* you draw is not so
// important, only the fact that it stays on the canvas