[openrndr-demos] Add rectangle batch demos
This commit is contained in:
@@ -16,7 +16,7 @@ buildscript {
|
|||||||
apply plugin: 'org.jetbrains.dokka'
|
apply plugin: 'org.jetbrains.dokka'
|
||||||
|
|
||||||
project.ext {
|
project.ext {
|
||||||
openrndrVersion = openrndrUseSnapshot? "0.4.0-SNAPSHOT" : "0.3.44-rc.4"
|
openrndrVersion = openrndrUseSnapshot? "0.4.0-SNAPSHOT" : "0.3.44-rc.5"
|
||||||
kotlinVersion = "1.3.72"
|
kotlinVersion = "1.3.72"
|
||||||
spekVersion = "2.0.11"
|
spekVersion = "2.0.11"
|
||||||
libfreenectVersion = "0.5.7-1.5.3"
|
libfreenectVersion = "0.5.7-1.5.3"
|
||||||
|
|||||||
@@ -1,36 +1,36 @@
|
|||||||
import org.openrndr.application
|
import org.openrndr.application
|
||||||
import org.openrndr.color.ColorRGBa
|
import org.openrndr.color.ColorRGBa
|
||||||
import org.openrndr.math.Vector2
|
import org.openrndr.math.Vector2
|
||||||
import org.openrndr.shape.CompositionDrawer
|
import org.openrndr.shape.drawComposition
|
||||||
|
import org.openrndr.svg.svgNamespaceInkscape
|
||||||
|
import org.openrndr.svg.toSVG
|
||||||
import org.openrndr.svg.writeSVG
|
import org.openrndr.svg.writeSVG
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
application {
|
application {
|
||||||
program {
|
program {
|
||||||
|
|
||||||
extend {
|
extend {
|
||||||
|
|
||||||
drawer.clear(ColorRGBa.WHITE)
|
drawer.clear(ColorRGBa.WHITE)
|
||||||
|
|
||||||
val cd = CompositionDrawer()
|
val composition = drawComposition {
|
||||||
val layer = cd.group {
|
val layer = group {
|
||||||
fill = ColorRGBa.PINK
|
fill = ColorRGBa.PINK
|
||||||
stroke = ColorRGBa.BLACK
|
stroke = ColorRGBa.BLACK
|
||||||
strokeWeight = 10.0
|
strokeWeight = 10.0
|
||||||
circle(Vector2(width/2.0, height/2.0), 100.0)
|
circle(Vector2(width / 2.0, height / 2.0), 100.0)
|
||||||
circle(Vector2(200.0, 200.0), 50.0)
|
circle(Vector2(200.0, 200.0), 50.0)
|
||||||
}
|
}
|
||||||
// demonstrating how to set custom attributes on the CompositionNode
|
// demonstrating how to set custom attributes on the CompositionNode
|
||||||
// these are stored in SVG
|
// these are stored in SVG
|
||||||
layer.id = "Layer_2"
|
layer.id = "Layer_2"
|
||||||
layer.attributes["openrndr:custom"] = "5"
|
layer.attributes["inkscape:label"] = "Layer 1"
|
||||||
|
layer.attributes["inkscape:groupmode"] = "layer"
|
||||||
|
}
|
||||||
// draw the composition to the screen
|
// draw the composition to the screen
|
||||||
drawer.composition(cd.composition)
|
drawer.composition(composition)
|
||||||
|
|
||||||
// print the svg to the console
|
// print the svg to the console
|
||||||
println(writeSVG(cd.composition))
|
println(composition.toSVG(namespaces = listOf(svgNamespaceInkscape)))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,8 @@ import org.openrndr.color.ColorRGBa
|
|||||||
import org.openrndr.draw.*
|
import org.openrndr.draw.*
|
||||||
import org.openrndr.extensions.Screenshots
|
import org.openrndr.extensions.Screenshots
|
||||||
|
|
||||||
|
|
||||||
fun main() = application {
|
fun main() = application {
|
||||||
program {
|
program {
|
||||||
|
|
||||||
val screenshots = extend(Screenshots()) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
val volumeTexture = VolumeTexture.create(128,128,32)
|
val volumeTexture = VolumeTexture.create(128,128,32)
|
||||||
val rt = renderTarget(128, 128) {
|
val rt = renderTarget(128, 128) {
|
||||||
volumeTexture(volumeTexture, 0)
|
volumeTexture(volumeTexture, 0)
|
||||||
@@ -18,9 +12,6 @@ fun main() = application {
|
|||||||
|
|
||||||
val cb = colorBuffer(128, 128)
|
val cb = colorBuffer(128, 128)
|
||||||
extend {
|
extend {
|
||||||
|
|
||||||
screenshots.afterScreenshot
|
|
||||||
|
|
||||||
drawer.isolatedWithTarget(rt) {
|
drawer.isolatedWithTarget(rt) {
|
||||||
drawer.ortho(rt)
|
drawer.ortho(rt)
|
||||||
drawer.clear(ColorRGBa.PINK)
|
drawer.clear(ColorRGBa.PINK)
|
||||||
@@ -28,6 +19,5 @@ fun main() = application {
|
|||||||
volumeTexture.copyTo(cb, 0)
|
volumeTexture.copyTo(cb, 0)
|
||||||
drawer.image(cb)
|
drawer.image(cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
16
openrndr-demos/src/demo/kotlin/DrawerRectangleBatch01.kt
Normal file
16
openrndr-demos/src/demo/kotlin/DrawerRectangleBatch01.kt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// A single rectangle
|
||||||
|
|
||||||
|
import org.openrndr.application
|
||||||
|
import org.openrndr.color.ColorRGBa
|
||||||
|
|
||||||
|
fun main() = application {
|
||||||
|
program {
|
||||||
|
extend {
|
||||||
|
drawer.clear(ColorRGBa.GRAY)
|
||||||
|
drawer.fill = ColorRGBa.PINK
|
||||||
|
drawer.stroke = ColorRGBa.WHITE
|
||||||
|
drawer.strokeWeight = 2.0
|
||||||
|
drawer.rectangle(100.0, 100.0, 50.0, 50.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
openrndr-demos/src/demo/kotlin/DrawerRectangleBatch02.kt
Normal file
29
openrndr-demos/src/demo/kotlin/DrawerRectangleBatch02.kt
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// Stored rectangle batches
|
||||||
|
import org.openrndr.application
|
||||||
|
import org.openrndr.color.ColorRGBa
|
||||||
|
import org.openrndr.draw.rectangleBatch
|
||||||
|
|
||||||
|
fun main() = application {
|
||||||
|
program {
|
||||||
|
val batch = drawer.rectangleBatch {
|
||||||
|
fill = ColorRGBa.PINK
|
||||||
|
stroke = ColorRGBa.WHITE
|
||||||
|
for (i in 0 until 1000) {
|
||||||
|
strokeWeight = Math.random() * 5.0 + 1.0
|
||||||
|
val rwidth = Math.random() * 40.0 + 4.0
|
||||||
|
val rheight = Math.random() * 40.0 + 4.0
|
||||||
|
val x = Math.random() * width
|
||||||
|
val y = Math.random() * height
|
||||||
|
rectangle(x, y, rwidth, rheight, Math.random() * 360.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extend {
|
||||||
|
drawer.clear(ColorRGBa.GRAY)
|
||||||
|
drawer.fill = ColorRGBa.PINK
|
||||||
|
drawer.stroke = ColorRGBa.WHITE
|
||||||
|
drawer.strokeWeight = 2.0
|
||||||
|
drawer.rectangles(batch)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
openrndr-demos/src/demo/kotlin/DrawerRectangleBatch03.kt
Normal file
23
openrndr-demos/src/demo/kotlin/DrawerRectangleBatch03.kt
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
// Dynamic rectangle batches
|
||||||
|
|
||||||
|
import org.openrndr.application
|
||||||
|
import org.openrndr.color.ColorRGBa
|
||||||
|
|
||||||
|
fun main() = application {
|
||||||
|
program {
|
||||||
|
extend {
|
||||||
|
drawer.clear(ColorRGBa.GRAY)
|
||||||
|
drawer.fill = ColorRGBa.PINK
|
||||||
|
drawer.stroke = ColorRGBa.WHITE
|
||||||
|
drawer.strokeWeight = 2.0
|
||||||
|
drawer.rectangles {
|
||||||
|
for (y in 0 until height/20) {
|
||||||
|
for (x in 0 until width/20) {
|
||||||
|
rectangle(x * 20.0, y * 20.0, 10.0, 15.0, (x + y) * 10.0 + seconds*90.0)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user