Skip to content

Commit c8f7dd5

Browse files
committed
Demos: ensure all use fun main() = application {
- Adjust some demo window sizes. - Replace Random.double by Double.uniform - Tweak some demos so screenshots look more interesting
1 parent 1975a82 commit c8f7dd5

File tree

116 files changed

+2862
-2915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+2862
-2915
lines changed

openrndr-demos/src/demo/kotlin/DemoContour03.kt

+28-30
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,39 @@ import org.openrndr.draw.isolated
44
import org.openrndr.shape.Circle
55
import org.openrndr.shape.Rectangle
66

7-
fun main() {
8-
application {
9-
configure {
10-
width = 720
11-
height = 720
12-
}
7+
fun main() = application {
8+
configure {
9+
width = 720
10+
height = 720
11+
}
1312

14-
program {
15-
val cs = Rectangle(0.0, 0.0, 200.0, 200.0).contour
16-
val cc = Circle(100.0, 0.0, 100.0).contour
13+
program {
14+
val cs = Rectangle(0.0, 0.0, 200.0, 200.0).contour
15+
val cc = Circle(100.0, 0.0, 100.0).contour
1716

18-
extend {
19-
drawer.fill = ColorRGBa.GRAY
20-
drawer.stroke = ColorRGBa.PINK
21-
drawer.isolated {
22-
drawer.contour(cs)
23-
drawer.translate(300.0, 0.0)
17+
extend {
18+
drawer.fill = ColorRGBa.GRAY
19+
drawer.stroke = ColorRGBa.PINK
20+
drawer.isolated {
21+
drawer.contour(cs)
22+
drawer.translate(300.0, 0.0)
2423

25-
// this should create a contour similar to the input contour
26-
drawer.contour(cs.sampleEquidistant(4))
27-
drawer.contour(cs.sampleEquidistant(3))
28-
}
24+
// this should create a contour similar to the input contour
25+
drawer.contour(cs.sampleEquidistant(4))
26+
drawer.contour(cs.sampleEquidistant(3))
27+
}
2928

30-
drawer.isolated {
31-
drawer.translate(.0, 400.0)
32-
drawer.contour(cc)
33-
drawer.translate(300.0, 0.0)
29+
drawer.isolated {
30+
drawer.translate(.0, 400.0)
31+
drawer.contour(cc)
32+
drawer.translate(300.0, 0.0)
3433

35-
drawer.contour(cc)
36-
// this should draw a hexagon
37-
drawer.contour(cc.sampleEquidistant(6))
38-
// this should draw a triangle
39-
drawer.contour(cc.sampleEquidistant(3))
40-
}
34+
drawer.contour(cc)
35+
// this should draw a hexagon
36+
drawer.contour(cc.sampleEquidistant(6))
37+
// this should draw a triangle
38+
drawer.contour(cc.sampleEquidistant(3))
4139
}
4240
}
4341
}
44-
}
42+
}

openrndr-demos/src/demo/kotlin/DemoLineCapJoin.kt

+29-31
Original file line numberDiff line numberDiff line change
@@ -13,42 +13,40 @@ import org.openrndr.shape.Triangle
1313
* a 3x3 grid of triangles and lines.
1414
*/
1515

16-
fun main() {
17-
application {
18-
configure {
19-
width = 720
20-
height = 720
21-
}
16+
fun main() = application {
17+
configure {
18+
width = 720
19+
height = 720
20+
}
2221

23-
program {
24-
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 20.0)
25-
val pointA = Vector2(0.0, 50.0)
26-
val pointB = Vector2(50.0, -20.0)
27-
val pointC = Vector2(-50.0, 0.0)
28-
val triangle = Triangle(pointA, pointB, pointC).contour
22+
program {
23+
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 20.0)
24+
val pointA = Vector2(0.0, 50.0)
25+
val pointB = Vector2(50.0, -20.0)
26+
val pointC = Vector2(-50.0, 0.0)
27+
val triangle = Triangle(pointA, pointB, pointC).contour
2928

30-
extend {
31-
drawer.apply {
32-
fill = ColorRGBa.GRAY
33-
stroke = ColorRGBa.PINK
34-
strokeWeight = 8.0
35-
fontMap = font
36-
LineCap.entries.forEachIndexed { x, cap ->
37-
lineCap = cap
38-
LineJoin.entries.forEachIndexed { y, join ->
39-
lineJoin = join
40-
val pos = IntVector2(x - 1, y - 1).vector2 * 180.0
41-
isolated {
42-
translate(bounds.position(0.46, 0.46) + pos)
43-
text("cap: ${cap.name}", -30.5, 80.5)
44-
text("join: ${join.name}", -30.5, 100.5)
45-
contour(triangle)
46-
lineSegment(pointA - pointC, pointB - pointC)
47-
}
29+
extend {
30+
drawer.apply {
31+
fill = ColorRGBa.GRAY
32+
stroke = ColorRGBa.PINK
33+
strokeWeight = 8.0
34+
fontMap = font
35+
LineCap.entries.forEachIndexed { x, cap ->
36+
lineCap = cap
37+
LineJoin.entries.forEachIndexed { y, join ->
38+
lineJoin = join
39+
val pos = IntVector2(x - 1, y - 1).vector2 * 180.0
40+
isolated {
41+
translate(bounds.position(0.46, 0.46) + pos)
42+
text("cap: ${cap.name}", -30.5, 80.5)
43+
text("join: ${join.name}", -30.5, 100.5)
44+
contour(triangle)
45+
lineSegment(pointA - pointC, pointB - pointC)
4846
}
4947
}
5048
}
5149
}
5250
}
5351
}
54-
}
52+
}

orx-composition/src/jvmDemo/kotlin/DemoCompositionDrawer01.kt

+24-28
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,37 @@ import org.openrndr.application
22
import org.openrndr.color.ColorRGBa
33
import org.openrndr.extra.composition.composition
44
import org.openrndr.extra.composition.drawComposition
5-
import org.openrndr.extra.svg.saveToFile
65
import org.openrndr.extra.svg.toSVG
76
import org.openrndr.math.Vector2
8-
import java.io.File
97

10-
fun main() {
11-
application {
12-
program {
13-
val composition = drawComposition {
14-
val layer = group {
15-
fill = ColorRGBa.PINK
16-
stroke = ColorRGBa.BLACK
17-
strokeWeight = 10.0
18-
circle(Vector2(width / 2.0, height / 2.0), 100.0)
19-
circle(Vector2(200.0, 200.0), 50.0)
20-
}
21-
// demonstrating how to set custom attributes on the CompositionNode
22-
// these are stored in SVG
23-
//layer.id = "Layer_2"
24-
//layer.attributes["inkscape:label"] = "Layer 1"
25-
//layer.attributes["inkscape:groupmode"] = "layer"
8+
fun main() = application {
9+
program {
10+
val composition = drawComposition {
11+
val layer = group {
12+
fill = ColorRGBa.PINK
13+
stroke = ColorRGBa.BLACK
14+
strokeWeight = 10.0
15+
circle(Vector2(width / 2.0, height / 2.0), 100.0)
16+
circle(Vector2(200.0, 200.0), 50.0)
2617
}
18+
// demonstrating how to set custom attributes on the CompositionNode
19+
// these are stored in SVG
20+
//layer.id = "Layer_2"
21+
//layer.attributes["inkscape:label"] = "Layer 1"
22+
//layer.attributes["inkscape:groupmode"] = "layer"
23+
}
2724

28-
// print the svg to the console
29-
println(composition.toSVG())
25+
// print the svg to the console
26+
println(composition.toSVG())
3027

31-
// save svg to a File
32-
//composition.saveToFile(File("/path/to/design.svg"))
28+
// save svg to a File
29+
//composition.saveToFile(File("/path/to/design.svg"))
3330

34-
extend {
35-
drawer.clear(ColorRGBa.WHITE)
31+
extend {
32+
drawer.clear(ColorRGBa.WHITE)
3633

37-
// draw the composition to the screen
38-
drawer.composition(composition)
39-
}
34+
// draw the composition to the screen
35+
drawer.composition(composition)
4036
}
4137
}
42-
}
38+
}

orx-composition/src/jvmDemo/kotlin/DemoCompositionDrawer02.kt

+13-15
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,21 @@ import org.openrndr.extra.composition.ClipMode
44
import org.openrndr.extra.composition.composition
55
import org.openrndr.extra.composition.drawComposition
66

7-
fun main() {
8-
application {
9-
program {
10-
val cd = drawComposition {
11-
fill = null
12-
circle(width / 2.0, height / 2.0, 100.0)
7+
fun main() = application {
8+
program {
9+
val cd = drawComposition {
10+
fill = null
11+
circle(width / 2.0, height / 2.0, 100.0)
1312

14-
fill = ColorRGBa.BLACK
15-
clipMode = ClipMode.REVERSE_DIFFERENCE
16-
circle(width / 2.0 + 50.0, height / 2.0, 100.0)
17-
}
13+
fill = ColorRGBa.BLACK
14+
clipMode = ClipMode.REVERSE_DIFFERENCE
15+
circle(width / 2.0 + 50.0, height / 2.0, 100.0)
16+
}
1817

1918

20-
extend {
21-
drawer.clear(ColorRGBa.PINK)
22-
drawer.composition(cd)
23-
}
19+
extend {
20+
drawer.clear(ColorRGBa.PINK)
21+
drawer.composition(cd)
2422
}
2523
}
26-
}
24+
}

orx-composition/src/jvmDemo/kotlin/DemoCompositionDrawer03.kt

+14-17
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,22 @@ import org.openrndr.extra.composition.ClipMode
44
import org.openrndr.extra.composition.composition
55
import org.openrndr.extra.composition.drawComposition
66

7-
fun main() {
8-
application {
9-
program {
10-
val cd = drawComposition {
11-
fill = null
12-
clipMode = ClipMode.REVERSE_DIFFERENCE
7+
fun main() = application {
8+
program {
9+
val cd = drawComposition {
10+
fill = null
11+
clipMode = ClipMode.REVERSE_DIFFERENCE
1312

14-
circle(width / 2.0-50.0, height / 2.0, 100.0)
15-
circle(width / 2.0+50.0, height / 2.0, 100.0)
16-
17-
fill = ColorRGBa.BLACK
18-
circle(width / 2.0, height / 2.0, 100.0)
19-
}
13+
circle(width / 2.0 - 50.0, height / 2.0, 100.0)
14+
circle(width / 2.0 + 50.0, height / 2.0, 100.0)
2015

16+
fill = ColorRGBa.BLACK
17+
circle(width / 2.0, height / 2.0, 100.0)
18+
}
2119

22-
extend {
23-
drawer.clear(ColorRGBa.PINK)
24-
drawer.composition(cd)
25-
}
20+
extend {
21+
drawer.clear(ColorRGBa.PINK)
22+
drawer.composition(cd)
2623
}
2724
}
28-
}
25+
}

orx-compositor/README.md

+25-27
Original file line numberDiff line numberDiff line change
@@ -201,38 +201,36 @@ import org.openrndr.extra.fx.edges.EdgesWork
201201
import org.openrndr.extra.gui.GUI
202202
import org.openrndr.math.Vector2
203203

204-
fun main() {
205-
application {
206-
configure {
207-
width = 768
208-
height = 768
209-
}
210-
program {
211-
val w2 = width / 2.0
212-
val h2 = height / 2.0
204+
fun main() = application {
205+
configure {
206+
width = 768
207+
height = 768
208+
}
209+
program {
210+
val w2 = width / 2.0
211+
val h2 = height / 2.0
212+
213+
val c = compose {
214+
draw {
215+
drawer.fill = ColorRGBa.PINK
216+
drawer.circle(width / 2.0, height / 2.0, 10.0)
217+
}
218+
219+
layer {
220+
blend(Add())
213221

214-
val c = compose {
215222
draw {
216-
drawer.fill = ColorRGBa.PINK
217-
drawer.circle(width / 2.0, height / 2.0, 10.0)
223+
drawer.circle(width / 2.0, height / 2.0, 100.0)
218224
}
219-
220-
layer {
221-
blend(Add())
222-
223-
draw {
224-
drawer.circle(width / 2.0, height / 2.0, 100.0)
225-
}
226-
post(ApproximateGaussianBlur()) {
227-
window = 10
228-
sigma = Math.cos(seconds * 10.0) * 10.0 + 10.0
229-
}
225+
post(ApproximateGaussianBlur()) {
226+
window = 10
227+
sigma = Math.cos(seconds * 10.0) * 10.0 + 10.0
230228
}
231229
}
232-
extend(gui)
233-
extend {
234-
c.draw(drawer)
235-
}
230+
}
231+
extend(gui)
232+
extend {
233+
c.draw(drawer)
236234
}
237235
}
238236
}

0 commit comments

Comments
 (0)