/
C320_Clipping.kt
54 lines (45 loc) · 1.29 KB
/
C320_Clipping.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
@file:Suppress("UNUSED_EXPRESSION")
@file:Title("Clipping")
@file:ParentTitle("Drawing")
@file:Order("320")
@file:URL("drawing/clipping")
package docs.`30_Drawing`
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.dokgen.annotations.*
import org.openrndr.shape.Rectangle
import kotlin.math.cos
import kotlin.math.sin
fun main() {
@Text
"""
# Clipping
OPENRNDR's drawer supports a single rectangular clip mask.
"""
@Media.Video "../media/clipping-001.mp4"
@Application
@ProduceVideo("media/clipping-001.mp4", 6.28318, 60)
@Code
application {
@Exclude
configure {
width = 770
height = 578
}
program {
extend {
drawer.stroke = null
drawer.fill = ColorRGBa.PINK
// -- set the rectangular clipping mask
drawer.drawStyle.clip = Rectangle(100.0, 100.0, width -200.0, height - 200.00)
drawer.circle(
cos(seconds) * width / 2.0 + width / 2.0,
sin(seconds) * height / 2.0 + height / 2.0,
200.0
)
// -- restore clipping
drawer.drawStyle.clip = null
}
}
}
}