Demos: ensure 720px wide, reduce indentation
This commit is contained in:
@@ -3,21 +3,19 @@ import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.marchingsquares.findContours
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
fun f(v: Vector2) = v.distanceTo(drawer.bounds.center) - 200.0
|
||||
val contours = findContours(::f, drawer.bounds, 16.0)
|
||||
drawer.fill = null
|
||||
drawer.contours(contours)
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
fun f(v: Vector2) = v.distanceTo(drawer.bounds.center) - 200.0
|
||||
val contours = findContours(::f, drawer.bounds, 16.0)
|
||||
drawer.fill = null
|
||||
drawer.contours(contours)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,21 +5,19 @@ import org.openrndr.math.Vector2
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
fun f(v: Vector2) = cos((v.distanceTo(drawer.bounds.center) / 100.0) * 2 * PI)
|
||||
val contours = findContours(::f, drawer.bounds.offsetEdges(-24.0), 16.0)
|
||||
drawer.fill = null
|
||||
drawer.contours(contours)
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
fun f(v: Vector2) = cos((v.distanceTo(drawer.bounds.center) / 100.0) * 2 * PI)
|
||||
val contours = findContours(::f, drawer.bounds.offsetEdges(-24.0), 16.0)
|
||||
drawer.fill = null
|
||||
drawer.contours(contours)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,24 +6,23 @@ import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.fill = null
|
||||
fun f(v: Vector2): Double {
|
||||
val p = v + Vector2(cos(v.y * 0.1 + seconds) * 40.0, sin(v.x * 0.1 + seconds) * 40.0)
|
||||
return cos((p.distanceTo(drawer.bounds.center) / 720.0) * 12 * PI)
|
||||
}
|
||||
val contours = findContours(::f, drawer.bounds.offsetEdges(-2.0), 4.0)
|
||||
drawer.contours(contours)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.fill = null
|
||||
fun f(v: Vector2): Double {
|
||||
val p = v + Vector2(cos(v.y * 0.1 + seconds) * 40.0, sin(v.x * 0.1 + seconds) * 40.0)
|
||||
return cos((p.distanceTo(drawer.bounds.center) / 720.0) * 12 * PI)
|
||||
}
|
||||
|
||||
val contours = findContours(::f, drawer.bounds.offsetEdges(-2.0), 4.0)
|
||||
drawer.contours(contours)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,30 +7,30 @@ import org.openrndr.math.Vector2
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 640
|
||||
height = 480
|
||||
}
|
||||
program {
|
||||
val image = loadImage("demo-data/images/image-001.png")
|
||||
image.shadow.download()
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
drawer.fill = null
|
||||
fun f(v: Vector2): Double {
|
||||
val iv = v.toInt()
|
||||
val d = if (iv.x >= 0 && iv.y >= 0 && iv.x < image.width && iv.y < image.height) image.shadow[iv.x, iv.y].luminance else 0.0
|
||||
return cos(d * PI * 8.0 + seconds)
|
||||
}
|
||||
|
||||
val contours = findContours(::f, drawer.bounds.offsetEdges(32.0), 4.0)
|
||||
drawer.drawStyle.colorMatrix = grayscale()
|
||||
drawer.image(image)
|
||||
drawer.contours(contours)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 540
|
||||
}
|
||||
program {
|
||||
val image = loadImage("demo-data/images/image-001.png")
|
||||
image.shadow.download()
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
drawer.fill = null
|
||||
fun f(v: Vector2): Double {
|
||||
val iv = v.toInt()
|
||||
val d =
|
||||
if (iv.x >= 0 && iv.y >= 0 && iv.x < image.width && iv.y < image.height) image.shadow[iv.x, iv.y].luminance else 0.0
|
||||
return cos(d * PI * 8.0 + seconds)
|
||||
}
|
||||
|
||||
val contours = findContours(::f, drawer.bounds.offsetEdges(32.0), 4.0)
|
||||
drawer.drawStyle.colorMatrix = grayscale()
|
||||
drawer.scale(width.toDouble() / image.width, height.toDouble() / image.height)
|
||||
drawer.image(image)
|
||||
drawer.contours(contours)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user