diff --git a/orx-shapes/build.gradle b/orx-shapes/build.gradle new file mode 100644 index 00000000..dec3965b --- /dev/null +++ b/orx-shapes/build.gradle @@ -0,0 +1,17 @@ +sourceSets { + demo { + java { + srcDirs = ["src/demo/kotlin"] + compileClasspath += main.getCompileClasspath() + runtimeClasspath += main.getRuntimeClasspath() + } + } +} + +dependencies { + demoImplementation("org.openrndr:openrndr-core:$openrndrVersion") + demoImplementation("org.openrndr:openrndr-extensions:$openrndrVersion") + demoRuntimeOnly("org.openrndr:openrndr-gl3:$openrndrVersion") + demoRuntimeOnly("org.openrndr:openrndr-gl3-natives-$openrndrOS:$openrndrVersion") + demoImplementation(sourceSets.getByName("main").output) +} \ No newline at end of file diff --git a/orx-shapes/src/demo/kotlin/DemoRegularPolygon.kt b/orx-shapes/src/demo/kotlin/DemoRegularPolygon.kt new file mode 100644 index 00000000..7570bed4 --- /dev/null +++ b/orx-shapes/src/demo/kotlin/DemoRegularPolygon.kt @@ -0,0 +1,29 @@ +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.extensions.SingleScreenshot +import org.openrndr.extra.shapes.RoundedRectangle +import org.openrndr.extra.shapes.regularPolygon +import org.openrndr.extra.shapes.regularStar +import kotlin.math.cos +import kotlin.math.sin + +fun main() = application { + program { + // -- this block is for automation purposes only + if (System.getProperty("takeScreenshot") == "true") { + extend(SingleScreenshot()) { + this.outputFile = System.getProperty("screenshotPath") + } + } + extend { + drawer.fill = ColorRGBa.PINK + drawer.stroke = ColorRGBa.WHITE + val radius0 = cos(seconds) * 50.0 + 130.0 + val star = regularPolygon(6, radius = radius0) + + drawer.translate(width/2.0, height / 2.0) + drawer.rotate(seconds * 45.0) + drawer.contour(star) + } + } +} \ No newline at end of file diff --git a/orx-shapes/src/demo/kotlin/DemoRegularStar.kt b/orx-shapes/src/demo/kotlin/DemoRegularStar.kt new file mode 100644 index 00000000..532ac043 --- /dev/null +++ b/orx-shapes/src/demo/kotlin/DemoRegularStar.kt @@ -0,0 +1,30 @@ +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.extensions.SingleScreenshot +import org.openrndr.extra.shapes.RoundedRectangle +import org.openrndr.extra.shapes.regularStar +import kotlin.math.cos +import kotlin.math.sin + +fun main() = application { + program { + // -- this block is for automation purposes only + if (System.getProperty("takeScreenshot") == "true") { + extend(SingleScreenshot()) { + this.outputFile = System.getProperty("screenshotPath") + } + } + extend { + drawer.fill = ColorRGBa.PINK + drawer.stroke = ColorRGBa.WHITE + val radius0 = cos(seconds) * 50.0 + 130.0 + val radius1 = sin(seconds) * 50.0 + 130.0 + + val star = regularStar(5, radius0, radius1) + + drawer.translate(width/2.0, height / 2.0) + drawer.rotate(seconds * 45.0) + drawer.contour(star) + } + } +} \ No newline at end of file diff --git a/orx-shapes/src/demo/kotlin/DemoRoundedRectangle.kt b/orx-shapes/src/demo/kotlin/DemoRoundedRectangle.kt new file mode 100644 index 00000000..56419b6a --- /dev/null +++ b/orx-shapes/src/demo/kotlin/DemoRoundedRectangle.kt @@ -0,0 +1,23 @@ +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.extensions.SingleScreenshot +import org.openrndr.extra.shapes.RoundedRectangle +import kotlin.math.cos + +fun main() = application { + program { + // -- this block is for automation purposes only + if (System.getProperty("takeScreenshot") == "true") { + extend(SingleScreenshot()) { + this.outputFile = System.getProperty("screenshotPath") + } + } + extend { + drawer.fill = ColorRGBa.WHITE + drawer.stroke = ColorRGBa.PINK + val radius = cos(seconds) * 20.0 + 20.0 + val rectangle = RoundedRectangle(50.0, 50.0, width - 100.0, height - 100.0, radius) + drawer.contour(rectangle.contour) + } + } +} \ No newline at end of file