Demos: ensure all use fun main() = application {
- Adjust some demo window sizes. - Replace Random.double by Double.uniform - Tweak some demos so screenshots look more interesting
This commit is contained in:
@@ -4,21 +4,19 @@ import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.shapes.primitives.Arc
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
val a = Arc(drawer.bounds.center, 100.0, 0.0 + seconds * 36.0, -180.0 + seconds * 36.0)
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.contour(a.contour)
|
||||
drawer.circle(a.position(0.0), 5.0)
|
||||
drawer.circle(a.position(0.5), 5.0)
|
||||
drawer.circle(a.position(1.0), 5.0)
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
val a = Arc(drawer.bounds.center, 100.0, 0.0 + seconds * 36.0, -180.0 + seconds * 36.0)
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.contour(a.contour)
|
||||
drawer.circle(a.position(0.0), 5.0)
|
||||
drawer.circle(a.position(0.5), 5.0)
|
||||
drawer.circle(a.position(1.0), 5.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,29 +6,27 @@ import org.openrndr.extra.shapes.primitives.Net
|
||||
import org.openrndr.shape.Circle
|
||||
import kotlin.math.sin
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
val a = drawer.bounds.position(0.7, 0.5)
|
||||
val b = drawer.bounds.position(0.3, 0.5)
|
||||
val c = Circle(
|
||||
drawer.bounds.position(
|
||||
sin(seconds) * 0.35 + 0.5,
|
||||
sin(seconds * 2) * 0.25 + 0.5
|
||||
), 50.0
|
||||
)
|
||||
val net = Net(a, b, c)
|
||||
drawer.circle(a, 10.0)
|
||||
drawer.circle(b, 10.0)
|
||||
drawer.circle(c)
|
||||
fun main() = application {
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
val a = drawer.bounds.position(0.7, 0.5)
|
||||
val b = drawer.bounds.position(0.3, 0.5)
|
||||
val c = Circle(
|
||||
drawer.bounds.position(
|
||||
sin(seconds) * 0.35 + 0.5,
|
||||
sin(seconds * 2) * 0.25 + 0.5
|
||||
), 50.0
|
||||
)
|
||||
val net = Net(a, b, c)
|
||||
drawer.circle(a, 10.0)
|
||||
drawer.circle(b, 10.0)
|
||||
drawer.circle(c)
|
||||
|
||||
drawer.strokeWeight = 2.0
|
||||
drawer.contour(net.contour)
|
||||
}
|
||||
drawer.strokeWeight = 2.0
|
||||
drawer.contour(net.contour)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,23 +6,21 @@ import org.openrndr.extra.shapes.primitives.Pulley
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.shape.Circle
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
val pulley = Pulley(
|
||||
Circle(drawer.bounds.center - Vector2(100.0, 100.0), 150.0),
|
||||
Circle(drawer.bounds.center + Vector2(150.0, 150.0), 75.0)
|
||||
)
|
||||
drawer.contour(pulley.contour)
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
val pulley = Pulley(
|
||||
Circle(drawer.bounds.center - Vector2(100.0, 100.0), 150.0),
|
||||
Circle(drawer.bounds.center + Vector2(150.0, 150.0), 75.0)
|
||||
)
|
||||
drawer.contour(pulley.contour)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,25 +4,23 @@ import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.shapes.primitives.grid
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.fill = ColorRGBa.WHITE.opacify(0.25)
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.fill = ColorRGBa.WHITE.opacify(0.25)
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
|
||||
// Notice the negative gutter in this grid. It creates an
|
||||
// overlap between the resulting rectangles.
|
||||
val grid = drawer.bounds.grid(8, 4, 20.0, 20.0, -20.0, -20.0)
|
||||
for (cell in grid.flatten()) {
|
||||
drawer.rectangle(cell)
|
||||
drawer.lineSegment(cell.position(0.0, 0.0), cell.position(1.0, 1.0))
|
||||
}
|
||||
// Notice the negative gutter in this grid. It creates an
|
||||
// overlap between the resulting rectangles.
|
||||
val grid = drawer.bounds.grid(8, 4, 20.0, 20.0, -20.0, -20.0)
|
||||
for (cell in grid.flatten()) {
|
||||
drawer.rectangle(cell)
|
||||
drawer.lineSegment(cell.position(0.0, 0.0), cell.position(1.0, 1.0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,35 +5,35 @@ import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.noise.Random
|
||||
import org.openrndr.extra.shapes.primitives.grid
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
// Try changing the resolution. The design will use the available space.
|
||||
configure {
|
||||
width = 800
|
||||
height = 400
|
||||
}
|
||||
program {
|
||||
// By specifying the cell size we make sure the design will
|
||||
// contain squares, independently of the window size and its
|
||||
// aspect ratio.
|
||||
val grid = drawer.bounds.grid(50.0, 50.0,
|
||||
20.0, 20.0, 20.0, 20.0).flatten()
|
||||
fun main() = application {
|
||||
// Try changing the resolution. The design will use the available space.
|
||||
configure {
|
||||
width = 800
|
||||
height = 400
|
||||
}
|
||||
program {
|
||||
// By specifying the cell size we make sure the design will
|
||||
// contain squares, independently of the window size and its
|
||||
// aspect ratio.
|
||||
val grid = drawer.bounds.grid(
|
||||
50.0, 50.0,
|
||||
20.0, 20.0, 20.0, 20.0
|
||||
).flatten()
|
||||
|
||||
val grid2 = grid.map { rect ->
|
||||
// Each of these inner grids will occupy the available space
|
||||
// in the parent grid cells. Notice how we don't specify cell
|
||||
// sizes here but counts instead (between 1 and 3 columns and
|
||||
// rows)
|
||||
val count = Random.int(1, 4)
|
||||
rect.grid(count, count, 5.0, 5.0, 5.0, 5.0).flatten()
|
||||
}.flatten().filter { Random.bool(0.5)}
|
||||
val grid2 = grid.map { rect ->
|
||||
// Each of these inner grids will occupy the available space
|
||||
// in the parent grid cells. Notice how we don't specify cell
|
||||
// sizes here but counts instead (between 1 and 3 columns and
|
||||
// rows)
|
||||
val count = Random.int(1, 4)
|
||||
rect.grid(count, count, 5.0, 5.0, 5.0, 5.0).flatten()
|
||||
}.flatten().filter { Random.bool(0.5) }
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.rectangles(grid)
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
drawer.rectangles(grid2)
|
||||
}
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.rectangles(grid)
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
drawer.rectangles(grid2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,33 +8,31 @@ import org.openrndr.extra.shapes.primitives.intersection
|
||||
* Demonstrate rectangle-rectangle intersection
|
||||
* @see <img src="https://raw.githubusercontent.com/openrndr/orx/media/orx-shapes/images/primitives-DemoRectangleIntersection01Kt.png">
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val h = drawer.bounds.offsetEdges(-100.0, -10.0)
|
||||
val v = drawer.bounds.offsetEdges(-10.0, -100.0)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val h = drawer.bounds.offsetEdges(-100.0, -10.0)
|
||||
val v = drawer.bounds.offsetEdges(-10.0, -100.0)
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
|
||||
/**
|
||||
* Find intersection
|
||||
*/
|
||||
val i = h.intersection(v)
|
||||
drawer.fill = ColorRGBa.RED
|
||||
drawer.rectangle(h)
|
||||
/**
|
||||
* Find intersection
|
||||
*/
|
||||
val i = h.intersection(v)
|
||||
drawer.fill = ColorRGBa.RED
|
||||
drawer.rectangle(h)
|
||||
|
||||
drawer.fill = ColorRGBa.BLUE
|
||||
drawer.rectangle(v)
|
||||
drawer.fill = ColorRGBa.BLUE
|
||||
drawer.rectangle(v)
|
||||
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.rectangle(i)
|
||||
}
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.rectangle(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,24 +8,22 @@ import org.openrndr.math.Vector2
|
||||
import org.openrndr.shape.Circle
|
||||
import kotlin.random.Random
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val points = drawer.bounds.scatter(40.0, distanceToEdge = 150.0, random = Random(0))
|
||||
val tears = points.map {
|
||||
Tear(it - Vector2(0.0, 20.0), Circle(it + Vector2(0.0, 20.0), 20.0))
|
||||
}
|
||||
program {
|
||||
val points = drawer.bounds.scatter(40.0, distanceToEdge = 150.0, random = Random(0))
|
||||
val tears = points.map {
|
||||
Tear(it - Vector2(0.0, 20.0), Circle(it + Vector2(0.0, 20.0), 20.0))
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.contours(tears.map { it.contour })
|
||||
}
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.contours(tears.map { it.contour })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user