From 420bf723e7f328444b97d98c93fa0b5025c53057 Mon Sep 17 00:00:00 2001 From: Abe Pazos Date: Thu, 28 Aug 2025 23:42:49 +0200 Subject: [PATCH] collectScreenshots: drop @see... lines otherwise images are duplicated in README.md --- buildSrc/src/main/kotlin/CollectScreenShots.kt | 14 +++++++++----- .../jvmDemo/kotlin/adjust/DemoAdjustContour01.kt | 8 ++++++++ .../jvmDemo/kotlin/adjust/DemoAdjustContour02.kt | 6 ++++-- .../jvmDemo/kotlin/adjust/DemoAdjustContour03.kt | 15 ++++++++++++++- .../jvmDemo/kotlin/adjust/DemoAdjustContour04.kt | 9 +++++++++ 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/buildSrc/src/main/kotlin/CollectScreenShots.kt b/buildSrc/src/main/kotlin/CollectScreenShots.kt index 5efd8741..7eb17dbb 100644 --- a/buildSrc/src/main/kotlin/CollectScreenShots.kt +++ b/buildSrc/src/main/kotlin/CollectScreenShots.kt @@ -43,7 +43,7 @@ abstract class CollectScreenshotsTask @Inject constructor() : DefaultTask() { "preload class not found: '${preloadClass.absolutePath}'" } - // Execute demos + // Execute demos and produce PNG files inputChanges.getFileChanges(inputDir).forEach { change -> if (change.fileType == FileType.DIRECTORY) return@forEach if (change.file.extension == "class") { @@ -98,7 +98,7 @@ abstract class CollectScreenshotsTask @Inject constructor() : DefaultTask() { } } - // List found PNG images. + // List produced PNG images. // Only executed if there are changes in the inputDir. val demoImageBaseNames = outputDir.get().asFile.listFiles { file: File -> file.extension == "png" @@ -135,10 +135,14 @@ abstract class CollectScreenshotsTask @Inject constructor() : DefaultTask() { val main = codeLines.indexOfFirst { it.startsWith("fun main") } if ((start < end) && (end < main)) { - codeLines.subList(start + 1, end).joinToString("\n") { - it.trimStart(' ', '*') + codeLines.subList(start + 1, end).joinToString("\n") { line -> + val trimmed = line.trimStart(' ', '*') + if(trimmed.startsWith("@see")) "" else trimmed } - } else "" + } else { + println("/** comment */ missing in $projectPath/$ktFilePath") + "" + } } else "" readmeLines.add( diff --git a/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour01.kt b/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour01.kt index 4c0fdce7..97555a60 100644 --- a/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour01.kt +++ b/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour01.kt @@ -8,6 +8,14 @@ import org.openrndr.shape.Circle import kotlin.math.cos import kotlin.math.sin +/** + * Demonstrates how to use `adjustContour` to select and modify three vertices + * in a circular contour. In OPENRNDR circles contain 4 cubic bézier + * segments connecting 4 vertices. + * + * On every animation frame the circular contour is created and transformed + * using sines, cosines and the variable `seconds` for an animated effect. + */ fun main() = application { configure { width = 800 diff --git a/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour02.kt b/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour02.kt index b5042357..5e2b494c 100644 --- a/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour02.kt +++ b/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour02.kt @@ -8,6 +8,10 @@ import org.openrndr.shape.Circle import kotlin.math.cos import kotlin.math.sin +/** + * Demonstrates how to use `adjustContour` to select and remove vertex 0 + * from a circular contour, then select and animate the position and scale the new vertex 0. + */ fun main() = application { configure { width = 800 @@ -22,8 +26,6 @@ fun main() = application { selectVertex(0) vertex.moveBy(Vector2(cos(seconds) * 40.0, sin(seconds * 0.43) * 40.0)) vertex.scale(cos(seconds * 2.0) * 2.0) - - } drawer.stroke = ColorRGBa.RED drawer.contour(contour) diff --git a/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour03.kt b/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour03.kt index 891d4691..c4f5d070 100644 --- a/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour03.kt +++ b/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour03.kt @@ -7,6 +7,18 @@ import org.openrndr.math.Vector2 import kotlin.math.cos import kotlin.math.sin +/** + * Demonstrates how to select and alter the edges of a rectangle. + * + * The rectangle is a scaled-down version window bounds. + * + * By default, the edges of a rectangular contour are linear, so the `edge.toCubic()` method + * is called to make it possible to bend them. + * + * Then various edges are selected one by one and transformed over time using operations like + * scale, rotate, splitAt and moveBy. + * + */ fun main() = application { configure { width = 800 @@ -23,13 +35,14 @@ fun main() = application { selectEdge(0) edge.scale(0.5, 0.5) edge.rotate(cos(seconds * 0.5) * 30.0) + selectEdge(1) edge.toCubic() edge.splitAt(0.5) edge.moveBy(Vector2(cos(seconds * 10.0) * 40.0, 0.0)) + //edge.next?.select() selectEdge(3) - edge.moveBy(Vector2(0.0, sin(seconds * 10.0) * 40.0)) diff --git a/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour04.kt b/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour04.kt index 3660d3f3..fc44503d 100644 --- a/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour04.kt +++ b/orx-shapes/src/jvmDemo/kotlin/adjust/DemoAdjustContour04.kt @@ -6,6 +6,15 @@ import org.openrndr.extra.shapes.adjust.adjustContour import org.openrndr.shape.Circle import kotlin.math.cos +/** + * Demonstrates an `adjustContour` animated effect where edge 0 of a contour + * is replaced by a point sampled on that edge. The specific edge point oscillates between + * 0.0 (at the start) and 1.0 (at the end) using a cosine and the `seconds` variable. + * + * The base contour used for the effect alternates every second + * between a rectangular and a circular contour. + * + */ fun main() = application { configure { width = 800