-
Notifications
You must be signed in to change notification settings - Fork 5
/
Shapes002.kt
69 lines (61 loc) · 2.71 KB
/
Shapes002.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.LineCap
import org.openrndr.extensions.Screenshots
import org.openrndr.extra.compositor.*
import org.openrndr.filter.blend.multiply
import org.openrndr.math.Vector2
import org.openrndr.shape.LineSegment
fun main(args: Array<String>) {
application {
configure {
width = 480
height = 640
}
program {
extend(Screenshots().apply {
scale = 4.0
})
val poster = compose {
layer {
draw {
val baseColor = ColorRGBa(Math.random(), Math.random(), Math.random())
drawer.background(baseColor)
val radius = 15 + (Math.random() * 40.0).toInt()
val lines = mutableListOf<LineSegment>()
for (y in 0 until height / radius + 1) {
for (x in 0 until width / radius + 1) {
lines.add(LineSegment(Vector2(x * radius * 1.0, y * radius * 1.0), Vector2(x * radius + Math.random() * radius, y * radius + Math.random() * radius)))
}
}
drawer.stroke = ColorRGBa(Math.random(), Math.random(), Math.random())
drawer.lineCap = LineCap.ROUND
drawer.strokeWeight = Math.random() * 4.0 + 4.0
drawer.lineSegments(lines.flatMap { listOf(it.start, it.end) })
}
}
layer {
blend(multiply)
draw {
drawer.background(ColorRGBa.WHITE)
val radius = 15 + (Math.random() * 40.0).toInt()
val lines = mutableListOf<LineSegment>()
for (y in 0 until height / radius + 1) {
for (x in 0 until width / radius + 1) {
lines.add(LineSegment(Vector2(x * radius * 1.0, y * radius * 1.0), Vector2(x * radius + Math.random() * radius, y * radius + Math.random() * radius)))
}
}
drawer.stroke = ColorRGBa(Math.random(), Math.random(), Math.random())
drawer.lineCap = LineCap.ROUND
drawer.strokeWeight = Math.random() * 4.0 + 4.0
drawer.lineSegments(lines.flatMap { listOf(it.start, it.end) })
}
}
}
extend {
poster.draw(drawer)
Thread.sleep(500)
}
}
}
}