/
C190_Shade_style_presets.kt
155 lines (136 loc) · 4.79 KB
/
C190_Shade_style_presets.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
@file:Suppress("UNUSED_EXPRESSION")
@file:Title("Shade style presets")
@file:ParentTitle("ORX")
@file:Order("190")
@file:URL("ORX/shadeStylePresets")
package docs.`80_ORX`
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.dokgen.annotations.*
import org.openrndr.draw.loadFont
import org.openrndr.draw.loadImage
import org.openrndr.extra.shadestyles.angularGradient
import org.openrndr.extra.shadestyles.halfAngularGradient
import org.openrndr.extra.shadestyles.linearGradient
import org.openrndr.extra.shadestyles.radialGradient
import org.openrndr.math.Vector2
import kotlin.math.cos
import kotlin.math.sin
fun main() {
@Text """
# Shade style presets
The `orx-shade-styles` library provides a number of preset
[shade styles](https://guide.openrndr.org/drawing/shadeStyles.html)
## Prerequisites
Assuming you are working on an
[`openrndr-template`](https://github.com/openrndr/openrndr-template) based
project, all you have to do is enable `orx-shade-styles` in the `orxFeatures`
set in `build.gradle.kts` and reimport the gradle project.
## linearGradient
"""
@Media.Video "../media/shade-style-presets-001.mp4"
@Application
@ProduceVideo("media/shade-style-presets-001.mp4", 6.0)
@Code
application {
@Exclude
configure {
width = 640
height = 480
}
program {
val image = loadImage("data/images/cheeta.jpg")
val font = loadFont("data/fonts/default.otf", 144.0)
extend {
drawer.shadeStyle = linearGradient(ColorRGBa.PINK, ColorRGBa.RED, rotation = seconds * 60.0)
drawer.rectangle(80.0, 40.0, 200.0, 200.0)
drawer.circle(180.0, 340.0, 90.0)
drawer.image(image, 300.0, 40.0, 640 * (200 / 480.0), 200.0)
drawer.fontMap = font
drawer.text("OPEN", 300.0, 340.0)
drawer.text("RNDR", 300.0, 420.0)
}
}
}
@Text """
## radialGradient
"""
@Media.Video "../media/shade-style-presets-002.mp4"
@Application
@ProduceVideo("media/shade-style-presets-002.mp4", 6.28318)
@Code
application {
@Exclude
configure {
width = 640
height = 480
}
program {
val image = loadImage("data/images/cheeta.jpg")
val font = loadFont("data/fonts/default.otf", 144.0)
extend {
drawer.shadeStyle = radialGradient(ColorRGBa.RED, ColorRGBa.PINK, length = 0.5, offset = Vector2(cos(seconds), sin(seconds*0.5)))
drawer.rectangle(80.0, 40.0, 200.0, 200.0)
drawer.circle(180.0, 340.0, 90.0)
drawer.image(image, 300.0, 40.0, 640 * (200 / 480.0), 200.0)
drawer.fontMap = font
drawer.text("OPEN", 300.0, 340.0)
drawer.text("RNDR", 300.0, 420.0)
}
}
}
@Text """
## angularGradient
"""
@Media.Video "../media/shade-style-presets-003.mp4"
@Application
@ProduceVideo("media/shade-style-presets-003.mp4", 6.0)
@Code
application {
@Exclude
configure {
width = 640
height = 480
}
program {
val image = loadImage("data/images/cheeta.jpg")
val font = loadFont("data/fonts/default.otf", 144.0)
extend {
drawer.shadeStyle = angularGradient(ColorRGBa.RED, ColorRGBa.PINK, rotation = seconds * 60.0)
drawer.rectangle(80.0, 40.0, 200.0, 200.0)
drawer.circle(180.0, 340.0, 90.0)
drawer.image(image, 300.0, 40.0, 640 * (200 / 480.0), 200.0)
drawer.fontMap = font
drawer.text("OPEN", 300.0, 340.0)
drawer.text("RNDR", 300.0, 420.0)
}
}
}
@Text """
## halfAngularGradient
"""
@Media.Video "../media/shade-style-presets-004.mp4"
@Application
@ProduceVideo("media/shade-style-presets-004.mp4", 6.0)
@Code
application {
@Exclude
configure {
width = 640
height = 480
}
program {
val image = loadImage("data/images/cheeta.jpg")
val font = loadFont("data/fonts/default.otf", 144.0)
extend {
drawer.shadeStyle = halfAngularGradient(ColorRGBa.RED, ColorRGBa.PINK, rotation = seconds * 60.0)
drawer.rectangle(80.0, 40.0, 200.0, 200.0)
drawer.circle(180.0, 340.0, 90.0)
drawer.image(image, 300.0, 40.0, 640 * (200 / 480.0), 200.0)
drawer.fontMap = font
drawer.text("OPEN", 300.0, 340.0)
drawer.text("RNDR", 300.0, 420.0)
}
}
}
}