New orx-axidraw (#356)
This commit is contained in:
59
orx-jvm/orx-axidraw/src/demo/kotlin/DemoAxidraw01.kt
Normal file
59
orx-jvm/orx-axidraw/src/demo/kotlin/DemoAxidraw01.kt
Normal file
@@ -0,0 +1,59 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.axidraw.Axidraw
|
||||
import org.openrndr.extra.axidraw.PaperSize
|
||||
import org.openrndr.extra.gui.GUI
|
||||
import org.openrndr.extra.noise.uniform
|
||||
import org.openrndr.extra.parameters.ActionParameter
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.IntParameter
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* Demonstrates:
|
||||
* - how to create an AxiDraw GUI
|
||||
* - how to add a slider and a button to that GUI
|
||||
* - how to include code to generate new random designs that match
|
||||
* the paper size via `axi.bounds`.
|
||||
* - how to display the generated design using `axi.display`.
|
||||
*
|
||||
* Toggle the GUI by pressing F11.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = PaperSize.A5.size.x * 5
|
||||
height = PaperSize.A5.size.y * 5
|
||||
}
|
||||
program {
|
||||
val axi = Axidraw(this, PaperSize.A5)
|
||||
axi.resizeWindow()
|
||||
|
||||
val gui = GUI()
|
||||
gui.add(axi)
|
||||
|
||||
val settings = @Description("Main") object {
|
||||
@IntParameter("count", 1, 50)
|
||||
var count = 20
|
||||
|
||||
@ActionParameter("generate")
|
||||
fun generate() {
|
||||
axi.clear()
|
||||
axi.draw {
|
||||
val l = min(axi.bounds.width, axi.bounds.height) / 2.0
|
||||
repeat(count) {
|
||||
circle(axi.bounds.center, Double.uniform(l / 4.0, l))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
gui.add(settings)
|
||||
|
||||
settings.generate()
|
||||
|
||||
extend(gui)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
axi.display(drawer)
|
||||
}
|
||||
}
|
||||
}
|
||||
45
orx-jvm/orx-axidraw/src/demo/kotlin/DemoAxidraw02.kt
Normal file
45
orx-jvm/orx-axidraw/src/demo/kotlin/DemoAxidraw02.kt
Normal file
@@ -0,0 +1,45 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.axidraw.Axidraw
|
||||
import org.openrndr.extra.axidraw.PaperOrientation
|
||||
import org.openrndr.extra.axidraw.PaperSize
|
||||
import org.openrndr.extra.gui.WindowedGUI
|
||||
import org.openrndr.extra.noise.uniform
|
||||
import org.openrndr.extra.parameters.ActionParameter
|
||||
import org.openrndr.extra.parameters.Description
|
||||
|
||||
/**
|
||||
* Demonstrates:
|
||||
* - How to set the window size based on the chosen paper size.
|
||||
* - How to use a windowed GUI.
|
||||
*
|
||||
*/
|
||||
fun main() = application {
|
||||
program {
|
||||
val axi = Axidraw(this, PaperSize.A5, PaperOrientation.LANDSCAPE)
|
||||
axi.resizeWindow()
|
||||
|
||||
val gui = WindowedGUI()
|
||||
gui.add(axi)
|
||||
|
||||
val settings = @Description("Main") object {
|
||||
|
||||
@ActionParameter("generate")
|
||||
fun generate() {
|
||||
axi.clear()
|
||||
axi.draw {
|
||||
repeat(20) {
|
||||
circle(axi.bounds.center, Double.uniform(50.0, 200.0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
gui.add(settings)
|
||||
|
||||
extend(gui)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
axi.display(drawer)
|
||||
}
|
||||
}
|
||||
}
|
||||
44
orx-jvm/orx-axidraw/src/demo/kotlin/DemoAxidraw03.kt
Normal file
44
orx-jvm/orx-axidraw/src/demo/kotlin/DemoAxidraw03.kt
Normal file
@@ -0,0 +1,44 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.axidraw.Axidraw
|
||||
import org.openrndr.extra.axidraw.PaperOrientation
|
||||
import org.openrndr.extra.axidraw.PaperSize
|
||||
import org.openrndr.extra.axidraw.configure
|
||||
import org.openrndr.extra.gui.WindowedGUI
|
||||
import org.openrndr.extra.noise.uniform
|
||||
import org.openrndr.extra.shapes.primitives.grid
|
||||
|
||||
/**
|
||||
* Demonstrates:
|
||||
* - How to create layers via `group` and give each layer
|
||||
* a unique pen height and pen speed.
|
||||
*
|
||||
*/
|
||||
fun main() = application {
|
||||
program {
|
||||
val axi = Axidraw(this, PaperSize.A5, PaperOrientation.PORTRAIT)
|
||||
axi.resizeWindow(100.0)
|
||||
|
||||
val gui = WindowedGUI()
|
||||
gui.add(axi)
|
||||
|
||||
axi.clear()
|
||||
axi.draw {
|
||||
fill = null
|
||||
axi.bounds.grid(4, 6).flatten().forEach {
|
||||
group {
|
||||
circle(it.center, 50.0)
|
||||
}.configure(
|
||||
penHeight = Int.uniform(30, 60),
|
||||
penSpeed = Int.uniform(20, 50)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extend(gui)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
axi.display(drawer)
|
||||
}
|
||||
}
|
||||
}
|
||||
48
orx-jvm/orx-axidraw/src/demo/kotlin/DemoAxidraw04.kt
Normal file
48
orx-jvm/orx-axidraw/src/demo/kotlin/DemoAxidraw04.kt
Normal file
@@ -0,0 +1,48 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.axidraw.*
|
||||
import org.openrndr.extra.gui.WindowedGUI
|
||||
import org.openrndr.extra.shapes.primitives.grid
|
||||
|
||||
/**
|
||||
* Demonstrates:
|
||||
* - How to create a flattened grid of with 24 items
|
||||
* - How to randomize the order of those items
|
||||
* - How to take chunks of 10 items, then make
|
||||
* a pause to change the pen after plotting each chunk
|
||||
*
|
||||
* Operation: After plotting ten circles, plotting will stop to let you change the pen.
|
||||
* With the second pen installed, click `resume`. It will plot ten circles more.
|
||||
* Change the pen again and click `resume` to plot the remaining 4 circles.
|
||||
* Once done, click `resume` one more time to bring the pen home.
|
||||
*/
|
||||
fun main() = application {
|
||||
program {
|
||||
val axi = Axidraw(this, PaperSize.A5, PaperOrientation.PORTRAIT)
|
||||
axi.resizeWindow(100.0)
|
||||
|
||||
val gui = WindowedGUI()
|
||||
gui.add(axi)
|
||||
|
||||
axi.clear()
|
||||
axi.draw {
|
||||
fill = null
|
||||
axi.bounds.grid(4, 6).flatten()
|
||||
.shuffled().chunked(10).forEach { chunk ->
|
||||
group {
|
||||
chunk.forEach {
|
||||
circle(it.center, 50.0)
|
||||
}
|
||||
}
|
||||
group {
|
||||
}.configure(layerMode = AxiLayerMode.PAUSE)
|
||||
}
|
||||
}
|
||||
|
||||
extend(gui)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
axi.display(drawer)
|
||||
}
|
||||
}
|
||||
}
|
||||
46
orx-jvm/orx-axidraw/src/demo/kotlin/DemoAxidraw05.kt
Normal file
46
orx-jvm/orx-axidraw/src/demo/kotlin/DemoAxidraw05.kt
Normal file
@@ -0,0 +1,46 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.axidraw.Axidraw
|
||||
import org.openrndr.extra.axidraw.PaperOrientation
|
||||
import org.openrndr.extra.axidraw.PaperSize
|
||||
import org.openrndr.extra.gui.WindowedGUI
|
||||
import org.openrndr.extra.shapes.primitives.grid
|
||||
|
||||
/**
|
||||
* Demonstrates:
|
||||
* - How to create a flattened grid of with 24 items
|
||||
* - How to apply random colors from a palette to each item.
|
||||
* - How to use `groupStrokeColors()` to plot a multi-pen design.
|
||||
*
|
||||
*/
|
||||
fun main() = application {
|
||||
program {
|
||||
val axi = Axidraw(this, PaperSize.A5, PaperOrientation.PORTRAIT)
|
||||
axi.resizeWindow(100.0)
|
||||
|
||||
val gui = WindowedGUI()
|
||||
gui.add(axi)
|
||||
|
||||
val palette = listOf(
|
||||
ColorRGBa.RED,
|
||||
ColorRGBa.GREEN,
|
||||
ColorRGBa.BLUE
|
||||
)
|
||||
|
||||
axi.clear()
|
||||
axi.draw {
|
||||
fill = null
|
||||
axi.bounds.grid(4, 6).flatten().forEach {
|
||||
stroke = palette.random()
|
||||
circle(it.center, 50.0)
|
||||
}
|
||||
}
|
||||
axi.groupStrokeColors()
|
||||
|
||||
extend(gui)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
axi.display(drawer)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user