/
C130_Extend.kt
48 lines (39 loc) · 1007 Bytes
/
C130_Extend.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
@file:Suppress("UNUSED_EXPRESSION")
@file:Title("Extend")
@file:ParentTitle("Program basics")
@file:Order("130")
@file:URL("programBasics/extend")
package docs.`20_Program_basics`
import org.openrndr.application
import org.openrndr.dokgen.annotations.*
fun main() {
@Text
"""
## Extend
The `program` block usually contains an `extend` block
which gets executed as often as possible.
"""
@Code
application {
program {
extend {
drawer.circle(width / 2.0, height / 2.0, 50.0)
}
}
}
@Text
"""
The `extend` block serves as a "draw loop", which is what we
need for drawing smooth animations. To demonstrate that the
result is not a still image, let's draw a circle located
wherever the mouse cursor is:
""".trimIndent()
@Code
application {
program {
extend {
drawer.circle(mouse.position, 50.0)
}
}
}
}