diff --git a/build.gradle b/build.gradle index c27806a4..64306256 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ def openrndrUseSnapshot = false apply plugin: 'org.jetbrains.dokka' project.ext { - openrndrVersion = openrndrUseSnapshot? "0.4.0-SNAPSHOT" : "0.3.45-rc.5" + openrndrVersion = openrndrUseSnapshot? "0.4.0-SNAPSHOT" : "0.3.45-rc.6" kotlinVersion = "1.4.0" spekVersion = "2.0.12" libfreenectVersion = "0.5.7-1.5.4" diff --git a/openrndr-demos/src/demo/kotlin/DemoAnimation01.kt b/openrndr-demos/src/demo/kotlin/DemoAnimation01.kt new file mode 100644 index 00000000..eb93afb4 --- /dev/null +++ b/openrndr-demos/src/demo/kotlin/DemoAnimation01.kt @@ -0,0 +1,30 @@ +import org.openrndr.animatable.Animatable +import org.openrndr.animatable.easing.Easing +import org.openrndr.application +import org.openrndr.math.Vector2 +import org.openrndr.shape.contour + +fun main() = application { + program { + class A: Animatable() { + var x = 0.0 + var y = Vector2(200.0, 200.0) + } + + val a = A() + a.apply { + ::y.animate(Vector2.ZERO, 10000, Easing.CubicInOut) + ::x.animate(100.0, 5000).completed.listen { + println("hello world") + ::x.animate(1.0, 5000).completed.listen { + println("we meet again") + } + } + } + + extend { + a.updateAnimation() + drawer.circle(a.y, 10.0) + } + } +} \ No newline at end of file diff --git a/openrndr-demos/src/demo/kotlin/DemoAnimation02.kt b/openrndr-demos/src/demo/kotlin/DemoAnimation02.kt new file mode 100644 index 00000000..55ae183b --- /dev/null +++ b/openrndr-demos/src/demo/kotlin/DemoAnimation02.kt @@ -0,0 +1,25 @@ +import org.openrndr.animatable.Animatable +import org.openrndr.animatable.easing.Easing +import org.openrndr.application +import org.openrndr.math.Vector2 +import org.openrndr.shape.contour + +fun main() = application { + program { + val a = object { + var x = 0.0 + } + + animate { + updateAnimation() + a::x.animate(1000.0, 5000, Easing.CubicInOut) + a::x.complete() + a::x.animate(0.0, 5000, Easing.CubicInOut) + + } + extend { + drawer.circle(a.x, height/2.0, 40.0) + } + + } +} \ No newline at end of file diff --git a/openrndr-demos/src/demo/kotlin/DemoCompositionDrawer02.kt b/openrndr-demos/src/demo/kotlin/DemoCompositionDrawer02.kt new file mode 100644 index 00000000..7f0f4544 --- /dev/null +++ b/openrndr-demos/src/demo/kotlin/DemoCompositionDrawer02.kt @@ -0,0 +1,25 @@ +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.shape.ClipMode +import org.openrndr.shape.drawComposition + +fun main() { + application { + program { + val cd = drawComposition { + fill = null + circle(width / 2.0, height / 2.0, 100.0) + + fill = ColorRGBa.BLACK + clipMode = ClipMode.REVERSE_DIFFERENCE + circle(width / 2.0 + 50.0, height / 2.0, 100.0) + } + + + extend { + drawer.clear(ColorRGBa.PINK) + drawer.composition(cd) + } + } + } +} \ No newline at end of file diff --git a/openrndr-demos/src/demo/kotlin/DemoCompositionDrawer03.kt b/openrndr-demos/src/demo/kotlin/DemoCompositionDrawer03.kt new file mode 100644 index 00000000..dc482c4d --- /dev/null +++ b/openrndr-demos/src/demo/kotlin/DemoCompositionDrawer03.kt @@ -0,0 +1,27 @@ +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.shape.ClipMode +import org.openrndr.shape.drawComposition + +fun main() { + application { + program { + val cd = drawComposition { + fill = null + clipMode = ClipMode.REVERSE_DIFFERENCE + + circle(width / 2.0-50.0, height / 2.0, 100.0) + circle(width / 2.0+50.0, height / 2.0, 100.0) + + fill = ColorRGBa.BLACK + circle(width / 2.0, height / 2.0, 100.0) + } + + + extend { + drawer.clear(ColorRGBa.PINK) + drawer.composition(cd) + } + } + } +} \ No newline at end of file diff --git a/openrndr-demos/src/demo/kotlin/DemoContour03.kt b/openrndr-demos/src/demo/kotlin/DemoContour03.kt new file mode 100644 index 00000000..cd9fb510 --- /dev/null +++ b/openrndr-demos/src/demo/kotlin/DemoContour03.kt @@ -0,0 +1,45 @@ +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.draw.isolated +import org.openrndr.shape.Circle +import org.openrndr.shape.Rectangle + +fun main() { + application { + configure { + width = 720 + height = 720 + } + + program { + + val cs = Rectangle(0.0, 0.0, 200.0, 200.0).contour + val cc = Circle(100.0, 0.0, 100.0).contour + + extend { + drawer.fill = ColorRGBa.GRAY + drawer.stroke = ColorRGBa.PINK + drawer.isolated { + drawer.contour(cs) + drawer.translate(300.0, 0.0) + + // this should create a contour similar to the input contour + drawer.contour(cs.sampleEquidistant(4)) + drawer.contour(cs.sampleEquidistant(3)) + } + + drawer.isolated { + drawer.translate(.0, 400.0) + drawer.contour(cc) + drawer.translate(300.0, 0.0) + + drawer.contour(cc) + // this should draw a hexagon + drawer.contour(cc.sampleEquidistant(6)) + // this should draw a triangle + drawer.contour(cc.sampleEquidistant(3)) + } + } + } + } +} \ No newline at end of file diff --git a/openrndr-demos/src/demo/kotlin/DemoContourIntersections03.kt b/openrndr-demos/src/demo/kotlin/DemoContourIntersections03.kt index eab7e384..28df18fa 100644 --- a/openrndr-demos/src/demo/kotlin/DemoContourIntersections03.kt +++ b/openrndr-demos/src/demo/kotlin/DemoContourIntersections03.kt @@ -26,9 +26,9 @@ fun main() = application { translate(width * 0.5, height * 0.5) fill = null stroke = ColorRGBa.BLACK - lineJoin = LineJoin.ROUND contour(contour) fill = ColorRGBa.PINK.opacify(0.3) + circles(ints.map { it.position }, 10.0) } } diff --git a/openrndr-demos/src/demo/kotlin/DemoMouseCursor01.kt b/openrndr-demos/src/demo/kotlin/DemoMouseCursor01.kt new file mode 100644 index 00000000..3e36347d --- /dev/null +++ b/openrndr-demos/src/demo/kotlin/DemoMouseCursor01.kt @@ -0,0 +1,21 @@ +import org.openrndr.CursorType +import org.openrndr.application + +fun main() { + application { + program { + keyboard.character.listen { + if (it.character == 'c') { + mouse.cursorVisible = !mouse.cursorVisible + } + } + extend { + if (mouse.position.x < width/2.0) { + mouse.cursorType = CursorType.ARROW_CURSOR + } else { + mouse.cursorType = CursorType.HAND_CURSOR + } + } + } + } +} \ No newline at end of file