diff --git a/orx-syphon/README.md b/orx-syphon/README.md index baf9c2de..afbc93cf 100644 --- a/orx-syphon/README.md +++ b/orx-syphon/README.md @@ -1 +1,88 @@ -# orx-syphon \ No newline at end of file +# orx-syphon +`orx-syphon` is an extension to send frames to- and from OPENRNDR and other applications in real time using Syphon for Mac. + +![Example](./preview.gif) + +### Syphon Server +#### Sharing the whole view +```kotlin +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import kotlin.math.sin + + +fun main() = application { + configure { + width = 1000 + height = 1000 + } + + program { + extend(SyphonServer()) + + extend { + drawer.background(ColorRGBa.RED) + drawer.circle(width/2.0, height/2.0, sin(seconds) * width / 2.0) + } + } +} +``` + +#### Sharing a different render target +```kotlin +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.draw.isolatedWithTarget +import org.openrndr.draw.renderTarget +import kotlin.math.* + + +fun main() = application { + configure { + width = 1000 + height = 1000 + } + + program { + val rt = renderTarget(100, 100) { + colorBuffer() + } + + // You can give the server a different name + extend(SyphonServer("Test", rt)) + + extend { + /** + * This is what will be sent to Syphon, and drawn in a small corner of the screen + */ + drawer.isolatedWithTarget(rt) { + drawer.background(ColorRGBa(sin(seconds), cos(seconds / 2.0), 0.5, 1.0)) + } + + drawer.background(ColorRGBa.GRAY) + drawer.circle(width/2.0, height/2.0, sin(seconds) * width / 2.0) + drawer.image(rt.colorBuffer(0)) + } + } +} +``` + +### Syphon Client +```kotlin +fun main() = application { + configure { + width = 1000 + height = 800 + } + + program { + val syphonClient = SyphonClient() + + extend(syphonClient) + extend { + drawer.background(ColorRGBa.BLACK) + drawer.image(syphonClient.buffer) + } + } +} +``` \ No newline at end of file diff --git a/orx-syphon/preview.gif b/orx-syphon/preview.gif new file mode 100644 index 00000000..bb326d2c Binary files /dev/null and b/orx-syphon/preview.gif differ diff --git a/orx-syphon/src/test/kotlin/ServerExampleAlternateRenderTarget.kt b/orx-syphon/src/test/kotlin/ServerExampleAlternateRenderTarget.kt index 9f0de588..54ff4875 100644 --- a/orx-syphon/src/test/kotlin/ServerExampleAlternateRenderTarget.kt +++ b/orx-syphon/src/test/kotlin/ServerExampleAlternateRenderTarget.kt @@ -16,6 +16,7 @@ fun main() = application { colorBuffer() } + // You can give the server a different name extend(SyphonServer("Test", rt)) extend {