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:
@@ -8,28 +8,26 @@ import org.openrndr.shape.Circle
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour = Circle(drawer.bounds.center, 300.0).contour
|
||||
contour = adjustContour(contour) {
|
||||
selectVertex(0)
|
||||
vertex.moveBy(Vector2(cos(seconds) * 40.0, sin(seconds * 0.43) * 40.0))
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour = Circle(drawer.bounds.center, 300.0).contour
|
||||
contour = adjustContour(contour) {
|
||||
selectVertex(0)
|
||||
vertex.moveBy(Vector2(cos(seconds) * 40.0, sin(seconds * 0.43) * 40.0))
|
||||
|
||||
selectVertex(2)
|
||||
vertex.rotate(seconds * 45.0)
|
||||
selectVertex(2)
|
||||
vertex.rotate(seconds * 45.0)
|
||||
|
||||
selectVertex(1)
|
||||
vertex.scale(cos(seconds*0.943)*2.0)
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
selectVertex(1)
|
||||
vertex.scale(cos(seconds * 0.943) * 2.0)
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,27 +8,25 @@ import org.openrndr.shape.Circle
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour = Circle(drawer.bounds.center, 300.0).contour
|
||||
contour = adjustContour(contour) {
|
||||
selectVertex(0)
|
||||
vertex.remove()
|
||||
selectVertex(0)
|
||||
vertex.moveBy(Vector2(cos(seconds) * 40.0, sin(seconds * 0.43) * 40.0))
|
||||
vertex.scale(cos(seconds*2.0)*2.0)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour = Circle(drawer.bounds.center, 300.0).contour
|
||||
contour = adjustContour(contour) {
|
||||
selectVertex(0)
|
||||
vertex.remove()
|
||||
selectVertex(0)
|
||||
vertex.moveBy(Vector2(cos(seconds) * 40.0, sin(seconds * 0.43) * 40.0))
|
||||
vertex.scale(cos(seconds * 2.0) * 2.0)
|
||||
|
||||
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,37 +7,35 @@ import org.openrndr.math.Vector2
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour = drawer.bounds.scaledBy(0.5, 0.5, 0.5).contour
|
||||
contour = adjustContour(contour) {
|
||||
for (i in 0 until 4) {
|
||||
selectEdge(i)
|
||||
edge.toCubic()
|
||||
}
|
||||
selectEdge(0)
|
||||
edge.scale(0.5, 0.5)
|
||||
edge.rotate(cos(seconds*0.5)*30.0)
|
||||
selectEdge(1)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour = drawer.bounds.scaledBy(0.5, 0.5, 0.5).contour
|
||||
contour = adjustContour(contour) {
|
||||
for (i in 0 until 4) {
|
||||
selectEdge(i)
|
||||
edge.toCubic()
|
||||
edge.splitAt(0.5)
|
||||
edge.moveBy(Vector2(cos(seconds*10.0) * 40.0, 0.0))
|
||||
//edge.next?.select()
|
||||
selectEdge(3)
|
||||
|
||||
edge.moveBy(Vector2(0.0, sin(seconds*10.0) * 40.0))
|
||||
|
||||
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
selectEdge(0)
|
||||
edge.scale(0.5, 0.5)
|
||||
edge.rotate(cos(seconds * 0.5) * 30.0)
|
||||
selectEdge(1)
|
||||
edge.toCubic()
|
||||
edge.splitAt(0.5)
|
||||
edge.moveBy(Vector2(cos(seconds * 10.0) * 40.0, 0.0))
|
||||
//edge.next?.select()
|
||||
selectEdge(3)
|
||||
|
||||
edge.moveBy(Vector2(0.0, sin(seconds * 10.0) * 40.0))
|
||||
|
||||
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,26 +6,24 @@ import org.openrndr.extra.shapes.adjust.adjustContour
|
||||
import org.openrndr.shape.Circle
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour = if (seconds.mod(2.0) < 1.0) {
|
||||
drawer.bounds.scaledBy(0.5, 0.5, 0.5).contour
|
||||
} else {
|
||||
Circle(drawer.bounds.center, 300.0).contour
|
||||
}
|
||||
contour = adjustContour(contour) {
|
||||
selectEdge(0)
|
||||
edge.replaceWith(cos(seconds) * 0.5 + 0.5)
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour = if (seconds.mod(2.0) < 1.0) {
|
||||
drawer.bounds.scaledBy(0.5, 0.5, 0.5).contour
|
||||
} else {
|
||||
Circle(drawer.bounds.center, 300.0).contour
|
||||
}
|
||||
contour = adjustContour(contour) {
|
||||
selectEdge(0)
|
||||
edge.replaceWith(cos(seconds) * 0.5 + 0.5)
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,31 +6,29 @@ import org.openrndr.extra.shapes.adjust.adjustContour
|
||||
import org.openrndr.shape.Circle
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour =
|
||||
Circle(drawer.bounds.center, 300.0).contour
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour =
|
||||
Circle(drawer.bounds.center, 300.0).contour
|
||||
|
||||
contour = adjustContour(contour) {
|
||||
selectEdges(0, 1, 2, 3)
|
||||
edges.forEachIndexed { index, it ->
|
||||
if (index == seconds.mod(4.0).toInt()) {
|
||||
it.replaceWith(0.5)
|
||||
} else {
|
||||
val v = cos(seconds) * 0.15 + 0.25
|
||||
it.sub(0.5 - v, 0.5 + v)
|
||||
}
|
||||
contour = adjustContour(contour) {
|
||||
selectEdges(0, 1, 2, 3)
|
||||
edges.forEachIndexed { index, it ->
|
||||
if (index == seconds.mod(4.0).toInt()) {
|
||||
it.replaceWith(0.5)
|
||||
} else {
|
||||
val v = cos(seconds) * 0.15 + 0.25
|
||||
it.sub(0.5 - v, 0.5 + v)
|
||||
}
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,38 +6,36 @@ import org.openrndr.extra.shapes.adjust.adjustContour
|
||||
import org.openrndr.shape.Circle
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour =
|
||||
Circle(drawer.bounds.center, 300.0).contour
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour =
|
||||
Circle(drawer.bounds.center, 300.0).contour
|
||||
|
||||
contour = adjustContour(contour) {
|
||||
parameters.clearSelectedVertices = true
|
||||
parameters.selectInsertedVertices = true
|
||||
contour = adjustContour(contour) {
|
||||
parameters.clearSelectedVertices = true
|
||||
parameters.selectInsertedVertices = true
|
||||
|
||||
|
||||
for (i in 0 until 4) {
|
||||
val splitT = cos(seconds + i * Math.PI*0.5)*0.2+0.5
|
||||
selectEdges { it -> true }
|
||||
for (e in edges) {
|
||||
e.splitAt(splitT)
|
||||
}
|
||||
// as a resut of the clearSelectedVertices and selectInsertedVertices settings
|
||||
// the vertex selection is set to the newly inserted vertices
|
||||
for ((index, v) in vertices.withIndex()) {
|
||||
v.scale(cos(seconds + i + index) * 0.5 * (1.0 / (1.0 + i)) + 1.0, drawer.bounds.center)
|
||||
}
|
||||
for (i in 0 until 4) {
|
||||
val splitT = cos(seconds + i * Math.PI * 0.5) * 0.2 + 0.5
|
||||
selectEdges { it -> true }
|
||||
for (e in edges) {
|
||||
e.splitAt(splitT)
|
||||
}
|
||||
// as a resut of the clearSelectedVertices and selectInsertedVertices settings
|
||||
// the vertex selection is set to the newly inserted vertices
|
||||
for ((index, v) in vertices.withIndex()) {
|
||||
v.scale(cos(seconds + i + index) * 0.5 * (1.0 / (1.0 + i)) + 1.0, drawer.bounds.center)
|
||||
}
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,36 +7,34 @@ import org.openrndr.math.Vector2
|
||||
import org.openrndr.shape.contour
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour = contour {
|
||||
moveTo(drawer.bounds.center - Vector2(300.0, 0.0))
|
||||
lineTo(drawer.bounds.center + Vector2(300.0, 0.0))
|
||||
}
|
||||
|
||||
contour = adjustContour(contour) {
|
||||
selectEdge(0)
|
||||
edge.splitIn(128)
|
||||
val tr = cos(seconds) * 0.5 + 0.5
|
||||
|
||||
selectVertices { i, v -> v.t >= tr }
|
||||
val anchor = contour.position(tr)
|
||||
|
||||
for (v in vertices) {
|
||||
v.rotate((v.t - tr) * 2000.0, anchor)
|
||||
v.scale(0.05, anchor)
|
||||
}
|
||||
}
|
||||
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour = contour {
|
||||
moveTo(drawer.bounds.center - Vector2(300.0, 0.0))
|
||||
lineTo(drawer.bounds.center + Vector2(300.0, 0.0))
|
||||
}
|
||||
|
||||
contour = adjustContour(contour) {
|
||||
selectEdge(0)
|
||||
edge.splitIn(128)
|
||||
val tr = cos(seconds) * 0.5 + 0.5
|
||||
|
||||
selectVertices { i, v -> v.t >= tr }
|
||||
val anchor = contour.position(tr)
|
||||
|
||||
for (v in vertices) {
|
||||
v.rotate((v.t - tr) * 2000.0, anchor)
|
||||
v.scale(0.05, anchor)
|
||||
}
|
||||
}
|
||||
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//package adjust
|
||||
package adjust
|
||||
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
@@ -6,46 +6,44 @@ import org.openrndr.extra.shapes.adjust.adjustContour
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.shape.contour
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour = contour {
|
||||
moveTo(drawer.bounds.position(0.5, 0.1) - Vector2(300.0, 0.0))
|
||||
lineTo(drawer.bounds.position(0.5, 0.1) + Vector2(300.0, 0.0))
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
var contour = contour {
|
||||
moveTo(drawer.bounds.position(0.5, 0.1) - Vector2(300.0, 0.0))
|
||||
lineTo(drawer.bounds.position(0.5, 0.1) + Vector2(300.0, 0.0))
|
||||
}
|
||||
|
||||
contour = adjustContour(contour) {
|
||||
selectVertex(0)
|
||||
vertex.moveControlOutBy(Vector2(0.0, 100.0))
|
||||
contour = adjustContour(contour) {
|
||||
selectVertex(0)
|
||||
vertex.moveControlOutBy(Vector2(0.0, 100.0))
|
||||
|
||||
selectVertex(1)
|
||||
vertex.moveControlInBy(Vector2(0.0, -100.0))
|
||||
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
|
||||
|
||||
contour = contour {
|
||||
moveTo(drawer.bounds.position(0.5, 0.2) - Vector2(300.0, 0.0))
|
||||
lineTo(drawer.bounds.position(0.5, 0.2) + Vector2(300.0, 0.0))
|
||||
}
|
||||
|
||||
contour = adjustContour(contour) {
|
||||
selectEdge(0)
|
||||
edge.moveControl0By(Vector2(0.0, 100.0))
|
||||
edge.moveControl1By(Vector2(0.0, -100.0))
|
||||
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
selectVertex(1)
|
||||
vertex.moveControlInBy(Vector2(0.0, -100.0))
|
||||
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
|
||||
|
||||
contour = contour {
|
||||
moveTo(drawer.bounds.position(0.5, 0.2) - Vector2(300.0, 0.0))
|
||||
lineTo(drawer.bounds.position(0.5, 0.2) + Vector2(300.0, 0.0))
|
||||
}
|
||||
|
||||
contour = adjustContour(contour) {
|
||||
selectEdge(0)
|
||||
edge.moveControl0By(Vector2(0.0, 100.0))
|
||||
edge.moveControl1By(Vector2(0.0, -100.0))
|
||||
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(contour)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,52 +9,50 @@ import org.openrndr.extra.shapes.tunni.tunniLine
|
||||
import org.openrndr.extra.shapes.tunni.tunniPoint
|
||||
import kotlin.math.sqrt
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
var contour = drawer.bounds.offsetEdges(-200.0).contour
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
var contour = drawer.bounds.offsetEdges(-200.0).contour
|
||||
|
||||
drawer.fill = null
|
||||
drawer.fill = null
|
||||
|
||||
contour = adjustContour(contour) {
|
||||
selectVertices(0, 1)
|
||||
for (v in vertices) {
|
||||
v.averageTangents()
|
||||
v.scale(sqrt(2.0))
|
||||
v.rotate(45.0)
|
||||
}
|
||||
|
||||
selectVertices(2)
|
||||
for (v in vertices) {
|
||||
v.switchTangents()
|
||||
}
|
||||
contour = adjustContour(contour) {
|
||||
selectVertices(0, 1)
|
||||
for (v in vertices) {
|
||||
v.averageTangents()
|
||||
v.scale(sqrt(2.0))
|
||||
v.rotate(45.0)
|
||||
}
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
drawer.contour(contour)
|
||||
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
|
||||
for (s in contour.segments) {
|
||||
drawer.lineSegment(s.start, s.cubic.control[0])
|
||||
drawer.lineSegment(s.end, s.cubic.control[1])
|
||||
selectVertices(2)
|
||||
for (v in vertices) {
|
||||
v.switchTangents()
|
||||
}
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
drawer.stroke = null
|
||||
drawer.circles(contour.segments.map { it.start }, 5.0)
|
||||
}
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
drawer.contour(contour)
|
||||
|
||||
drawer.stroke = ColorRGBa.GRAY
|
||||
for (s in contour.segments) {
|
||||
drawer.lineSegment(s.tunniLine)
|
||||
drawer.fill = ColorRGBa.CYAN
|
||||
drawer.circle(s.tunniPoint, 5.0)
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
|
||||
for (s in contour.segments) {
|
||||
drawer.lineSegment(s.start, s.cubic.control[0])
|
||||
drawer.lineSegment(s.end, s.cubic.control[1])
|
||||
}
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
drawer.stroke = null
|
||||
drawer.circles(contour.segments.map { it.start }, 5.0)
|
||||
|
||||
drawer.stroke = ColorRGBa.GRAY
|
||||
for (s in contour.segments) {
|
||||
drawer.lineSegment(s.tunniLine)
|
||||
drawer.fill = ColorRGBa.CYAN
|
||||
drawer.circle(s.tunniPoint, 5.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,91 +12,89 @@ import org.openrndr.math.Vector2
|
||||
import org.openrndr.shape.Segment2D
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
|
||||
var res = drawer.bounds.offsetEdges(-200.0).contour
|
||||
var selectedSegments = emptyList<Segment2D>()
|
||||
var selectedPoints = emptyList<Vector2>()
|
||||
var res = drawer.bounds.offsetEdges(-200.0).contour
|
||||
var selectedSegments = emptyList<Segment2D>()
|
||||
var selectedPoints = emptyList<Vector2>()
|
||||
|
||||
val contourSeq = adjustContourSequence(res) {
|
||||
val contourSeq = adjustContourSequence(res) {
|
||||
|
||||
sequence {
|
||||
for (i in 0 until 1000) {
|
||||
selectEdges()
|
||||
selectVertices((i*7).mod(4))
|
||||
for (v in vertices) {
|
||||
for (j in 0 until 30) {
|
||||
v.rotate(45.0/30.0)
|
||||
yield(status)
|
||||
}
|
||||
}
|
||||
|
||||
selectVertices((i*3).mod(4))
|
||||
for (v in vertices) {
|
||||
yield(status)
|
||||
|
||||
}
|
||||
|
||||
|
||||
selectVertices()
|
||||
selectEdges(i.mod(4))
|
||||
sequence {
|
||||
for (i in 0 until 1000) {
|
||||
selectEdges()
|
||||
selectVertices((i * 7).mod(4))
|
||||
for (v in vertices) {
|
||||
for (j in 0 until 30) {
|
||||
for (e in edges) {
|
||||
e.withTunniLine(e.tunniLine.position(0.5) + e.tunniLine.normal * cos(i.toDouble() + e.segmentIndex()) * 50.0/30.0)
|
||||
yield(status)
|
||||
}
|
||||
v.rotate(45.0 / 30.0)
|
||||
yield(status)
|
||||
}
|
||||
}
|
||||
|
||||
selectVertices((i * 3).mod(4))
|
||||
for (v in vertices) {
|
||||
yield(status)
|
||||
|
||||
}
|
||||
|
||||
|
||||
selectVertices()
|
||||
selectEdges(i.mod(4))
|
||||
for (j in 0 until 30) {
|
||||
for (e in edges) {
|
||||
e.withTunniLine(e.tunniLine.position(0.5) + e.tunniLine.normal * cos(i.toDouble() + e.segmentIndex()) * 50.0 / 30.0)
|
||||
yield(status)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
launch {
|
||||
for (i in contourSeq) {
|
||||
res = i.contour
|
||||
selectedPoints = i.selectedPoints
|
||||
selectedSegments = i.selectedSegments
|
||||
yield()
|
||||
}
|
||||
launch {
|
||||
for (i in contourSeq) {
|
||||
res = i.contour
|
||||
selectedPoints = i.selectedPoints
|
||||
selectedSegments = i.selectedSegments
|
||||
yield()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
drawer.contour(res)
|
||||
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
|
||||
for (s in res.segments) {
|
||||
drawer.lineSegment(s.start, s.cubic.control[0])
|
||||
drawer.lineSegment(s.end, s.cubic.control[1])
|
||||
}
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
drawer.stroke = null
|
||||
drawer.circles(res.segments.map { it.start }, 5.0)
|
||||
|
||||
drawer.stroke = ColorRGBa.GRAY
|
||||
for (s in res.segments) {
|
||||
drawer.lineSegment(s.tunniLine)
|
||||
drawer.fill = ColorRGBa.CYAN
|
||||
drawer.circle(s.tunniPoint, 5.0)
|
||||
}
|
||||
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
drawer.contour(res)
|
||||
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
|
||||
for (s in res.segments) {
|
||||
drawer.lineSegment(s.start, s.cubic.control[0])
|
||||
drawer.lineSegment(s.end, s.cubic.control[1])
|
||||
}
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
drawer.stroke = null
|
||||
drawer.circles(res.segments.map { it.start }, 5.0)
|
||||
|
||||
drawer.stroke = ColorRGBa.GRAY
|
||||
for (s in res.segments) {
|
||||
drawer.lineSegment(s.tunniLine)
|
||||
drawer.fill = ColorRGBa.CYAN
|
||||
drawer.circle(s.tunniPoint, 5.0)
|
||||
}
|
||||
|
||||
drawer.stroke = ColorRGBa.MAGENTA
|
||||
drawer.strokeWeight = 3.0
|
||||
for (s in selectedSegments) {
|
||||
drawer.segment(s)
|
||||
}
|
||||
for (p in selectedPoints) {
|
||||
drawer.circle(p, 5.0)
|
||||
}
|
||||
drawer.stroke = ColorRGBa.MAGENTA
|
||||
drawer.strokeWeight = 3.0
|
||||
for (s in selectedSegments) {
|
||||
drawer.segment(s)
|
||||
}
|
||||
for (p in selectedPoints) {
|
||||
drawer.circle(p, 5.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,33 +12,34 @@ import org.openrndr.shape.Circle
|
||||
import kotlin.math.sqrt
|
||||
import kotlin.random.Random
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
val circles = listOf(
|
||||
Circle(drawer.bounds.center -Vector2(50.0, 0.0), 50.0),
|
||||
Circle(drawer.bounds.center + Vector2(50.0, 0.0), 50.0),
|
||||
Circle(drawer.bounds.center + Vector2(0.0, 50.0), 50.0),
|
||||
Circle(drawer.bounds.center - Vector2(0.0, 50.0), 50.0),
|
||||
Circle(drawer.bounds.center -Vector2(50.0, 0.0), sqrt(50.0*50.0+50.0*50.0)-49.9),
|
||||
Circle(drawer.bounds.center +Vector2(50.0, 0.0), sqrt(50.0*50.0+50.0*50.0)-49.9),
|
||||
Circle(drawer.bounds.center -Vector2(0.0, 50.0), sqrt(50.0*50.0+50.0*50.0)-49.9),
|
||||
Circle(drawer.bounds.center +Vector2(0.0, 50.0), sqrt(50.0*50.0+50.0*50.0)-49.9),
|
||||
).shuffled()
|
||||
fun main() = application {
|
||||
program {
|
||||
val circles = listOf(
|
||||
Circle(drawer.bounds.center - Vector2(50.0, 0.0), 50.0),
|
||||
Circle(drawer.bounds.center + Vector2(50.0, 0.0), 50.0),
|
||||
Circle(drawer.bounds.center + Vector2(0.0, 50.0), 50.0),
|
||||
Circle(drawer.bounds.center - Vector2(0.0, 50.0), 50.0),
|
||||
Circle(drawer.bounds.center - Vector2(50.0, 0.0), sqrt(50.0 * 50.0 + 50.0 * 50.0) - 49.9),
|
||||
Circle(drawer.bounds.center + Vector2(50.0, 0.0), sqrt(50.0 * 50.0 + 50.0 * 50.0) - 49.9),
|
||||
Circle(drawer.bounds.center - Vector2(0.0, 50.0), sqrt(50.0 * 50.0 + 50.0 * 50.0) - 49.9),
|
||||
Circle(drawer.bounds.center + Vector2(0.0, 50.0), sqrt(50.0 * 50.0 + 50.0 * 50.0) - 49.9),
|
||||
).shuffled()
|
||||
|
||||
val arr = Arrangement(circles)
|
||||
val arr = Arrangement(circles)
|
||||
|
||||
extend {
|
||||
val r = Random(100)
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
for (f in arr.boundedFaces) {
|
||||
drawer.fill =
|
||||
extend {
|
||||
val r = Random(100)
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
for (f in arr.boundedFaces) {
|
||||
drawer.fill =
|
||||
|
||||
rgb(Double.uniform(0.0, 1.0, r), Double.uniform(0.0, 1.0, r), Double.uniform(0.0, 1.0, r)).saturate<OKHSV>(0.25)
|
||||
drawer.contour(f.contour)
|
||||
}
|
||||
rgb(
|
||||
Double.uniform(0.0, 1.0, r),
|
||||
Double.uniform(0.0, 1.0, r),
|
||||
Double.uniform(0.0, 1.0, r)
|
||||
).saturate<OKHSV>(0.25)
|
||||
drawer.contour(f.contour)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,42 +15,40 @@ import org.openrndr.shape.ShapeContour
|
||||
* The created contours are horizontal and vertical in "bezier-patch space" but
|
||||
* are rendered deformed following the shape of the bezier patch.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
// helper to get screen locations using normalized uv values
|
||||
fun pos(u: Double, v: Double) = drawer.bounds.position(u, v)
|
||||
val c0 = LineSegment(pos(0.1, 0.1), pos(0.9, 0.1))
|
||||
val c1 = LineSegment(pos(0.4, 0.3), pos(0.6, 0.4))
|
||||
val c2 = LineSegment(pos(0.4, 0.7), pos(0.6, 0.6))
|
||||
val c3 = LineSegment(pos(0.1, 0.9), pos(0.9, 0.9))
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
// helper to get screen locations using normalized uv values
|
||||
fun pos(u: Double, v: Double) = drawer.bounds.position(u, v)
|
||||
val c0 = LineSegment(pos(0.1, 0.1), pos(0.9, 0.1))
|
||||
val c1 = LineSegment(pos(0.4, 0.3), pos(0.6, 0.4))
|
||||
val c2 = LineSegment(pos(0.4, 0.7), pos(0.6, 0.6))
|
||||
val c3 = LineSegment(pos(0.1, 0.9), pos(0.9, 0.9))
|
||||
|
||||
val bp = bezierPatch(c0.segment, c1.segment, c2.segment, c3.segment)
|
||||
val bpSub = bp.sub(0.1, 0.1, 0.6,0.6)
|
||||
val bp = bezierPatch(c0.segment, c1.segment, c2.segment, c3.segment)
|
||||
val bpSub = bp.sub(0.1, 0.1, 0.6, 0.6)
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
|
||||
// Show the line segments that form the bezier patch
|
||||
drawer.stroke = ColorRGBa.YELLOW
|
||||
drawer.strokeWeight = 5.0
|
||||
drawer.lineSegments(listOf(c0, c1, c2, c3))
|
||||
// Show the line segments that form the bezier patch
|
||||
drawer.stroke = ColorRGBa.YELLOW
|
||||
drawer.strokeWeight = 5.0
|
||||
drawer.lineSegments(listOf(c0, c1, c2, c3))
|
||||
|
||||
drawer.strokeWeight = 1.0
|
||||
for (i in 0..50) {
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
drawer.contour(bp.horizontal(i / 50.0))
|
||||
drawer.contour(bp.vertical(i / 50.0))
|
||||
drawer.strokeWeight = 1.0
|
||||
for (i in 0..50) {
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
drawer.contour(bp.horizontal(i / 50.0))
|
||||
drawer.contour(bp.vertical(i / 50.0))
|
||||
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(bpSub.horizontal(i / 50.0))
|
||||
drawer.contour(bpSub.vertical(i / 50.0))
|
||||
}
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(bpSub.horizontal(i / 50.0))
|
||||
drawer.contour(bpSub.vertical(i / 50.0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,25 +15,23 @@ import org.openrndr.shape.ShapeContour
|
||||
* but one can manually create any other 4-segment closed contour
|
||||
* to use in bezier patches.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
val c = Circle(width / 2.0, height / 2.0, 350.0).contour
|
||||
val bp = bezierPatch(c)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
val c = Circle(width / 2.0, height / 2.0, 350.0).contour
|
||||
val bp = bezierPatch(c)
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
|
||||
for (i in 0..10) {
|
||||
drawer.contour(bp.horizontal(i / 10.0))
|
||||
drawer.contour(bp.vertical(i / 10.0))
|
||||
}
|
||||
for (i in 0..10) {
|
||||
drawer.contour(bp.horizontal(i / 10.0))
|
||||
drawer.contour(bp.vertical(i / 10.0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,44 +15,42 @@ import org.openrndr.shape.ShapeContour
|
||||
* In this case the contours are regular stars and the bezier patch
|
||||
* is created using a circular contour with the required 4 segments.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
val bp = bezierPatch(
|
||||
Circle(width / 2.0, height / 2.0, 350.0).contour
|
||||
)
|
||||
val star = regularStarRounded(
|
||||
7, 30.0, 40.0,
|
||||
0.5, 0.5
|
||||
)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
val bp = bezierPatch(
|
||||
Circle(width / 2.0, height / 2.0, 350.0).contour
|
||||
)
|
||||
val star = regularStarRounded(
|
||||
7, 30.0, 40.0,
|
||||
0.5, 0.5
|
||||
)
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
|
||||
// draw grid
|
||||
for (i in 0..50) {
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
drawer.contour(bp.horizontal(i / 50.0))
|
||||
drawer.contour(bp.vertical(i / 50.0))
|
||||
}
|
||||
// draw grid
|
||||
for (i in 0..50) {
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
drawer.contour(bp.horizontal(i / 50.0))
|
||||
drawer.contour(bp.vertical(i / 50.0))
|
||||
}
|
||||
|
||||
// draw stars
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
for (j in 1 until 10) {
|
||||
for (i in 1 until 10) {
|
||||
val starMoved = star.transform(
|
||||
transform {
|
||||
translate(j * width / 10.0, i * height / 10.0)
|
||||
}
|
||||
)
|
||||
drawer.contour(bp.distort(starMoved, drawer.bounds))
|
||||
}
|
||||
// draw stars
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
for (j in 1 until 10) {
|
||||
for (i in 1 until 10) {
|
||||
val starMoved = star.transform(
|
||||
transform {
|
||||
translate(j * width / 10.0, i * height / 10.0)
|
||||
}
|
||||
)
|
||||
drawer.contour(bp.distort(starMoved, drawer.bounds))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,35 +12,33 @@ import org.openrndr.shape.Circle
|
||||
* You can think of bezierPatch.position() as requesting points
|
||||
* in a wavy flag (the bezier patch) using normalized uv coordinates.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
val bp = bezierPatch(
|
||||
Circle(drawer.bounds.center, 350.0).contour
|
||||
//Rectangle.fromCenter(drawer.bounds.center, 550.0).contour
|
||||
)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
val bp = bezierPatch(
|
||||
Circle(drawer.bounds.center, 350.0).contour
|
||||
//Rectangle.fromCenter(drawer.bounds.center, 550.0).contour
|
||||
)
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
|
||||
for (j in 1 until 50 step 2) {
|
||||
for (i in 1 until 50 step 2) {
|
||||
val u = i / 50.0
|
||||
val v = j / 50.0
|
||||
val pos = bp.position(u, v)
|
||||
val grad = bp.gradient(u, v).normalized * 10.0
|
||||
val perpendicular = grad.perpendicular()
|
||||
drawer.lineSegment(pos - grad, pos + grad)
|
||||
drawer.lineSegment(pos - perpendicular, pos + perpendicular)
|
||||
//drawer.circle(pos + grad, 3.0)
|
||||
}
|
||||
for (j in 1 until 50 step 2) {
|
||||
for (i in 1 until 50 step 2) {
|
||||
val u = i / 50.0
|
||||
val v = j / 50.0
|
||||
val pos = bp.position(u, v)
|
||||
val grad = bp.gradient(u, v).normalized * 10.0
|
||||
val perpendicular = grad.perpendicular()
|
||||
drawer.lineSegment(pos - grad, pos + grad)
|
||||
drawer.lineSegment(pos - perpendicular, pos + perpendicular)
|
||||
//drawer.circle(pos + grad, 3.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package bezierpatch
|
||||
import org.openrndr.WindowMultisample
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.shapes.bezierpatches.bezierPatch
|
||||
import org.openrndr.extra.camera.Orbital
|
||||
import org.openrndr.extra.shapes.bezierpatches.bezierPatch
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.shape.Segment3D
|
||||
|
||||
@@ -19,56 +19,54 @@ import org.openrndr.shape.Segment3D
|
||||
* The created contours are horizontal and vertical in "bezier-patch space" but
|
||||
* are rendered deformed following the shape of the bezier patch.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
val c0 = Segment3D(Vector3(-5.0, 0.0, -9.0), Vector3(5.0, 0.0, -9.0))
|
||||
val c1 = Segment3D(Vector3(-5.0, -5.0, -3.0), Vector3(5.0, -5.0, -3.0))
|
||||
val c2 = Segment3D(Vector3(-5.0, 5.0, 3.0), Vector3(5.0, 5.0, 3.0))
|
||||
val c3 = Segment3D(Vector3(-5.0, 0.0, 9.0), Vector3(5.0, 0.0, 9.0))
|
||||
|
||||
val col = listOf(ColorRGBa.PINK, ColorRGBa.RED, ColorRGBa.BLUE, ColorRGBa.PINK)
|
||||
val cols = listOf(col, col, col, col)
|
||||
val bp = bezierPatch(c0, c1, c2, c3).withColors(cols)
|
||||
val bpSub = bp.sub(0.1, 0.1, 0.6, 0.6)
|
||||
|
||||
val cam = Orbital()
|
||||
extend(cam) {
|
||||
eye = Vector3(x = 9.9, y = 12.8, z = 6.9)
|
||||
lookAt = Vector3(x = 1.6, y = -1.9, z = 1.2)
|
||||
}
|
||||
program {
|
||||
val c0 = Segment3D(Vector3(-5.0, 0.0, -9.0), Vector3(5.0, 0.0, -9.0))
|
||||
val c1 = Segment3D(Vector3(-5.0, -5.0, -3.0), Vector3(5.0, -5.0, -3.0))
|
||||
val c2 = Segment3D(Vector3(-5.0, 5.0, 3.0), Vector3(5.0, 5.0, 3.0))
|
||||
val c3 = Segment3D(Vector3(-5.0, 0.0, 9.0), Vector3(5.0, 0.0, 9.0))
|
||||
|
||||
val col = listOf(ColorRGBa.PINK, ColorRGBa.RED, ColorRGBa.BLUE, ColorRGBa.PINK)
|
||||
val cols = listOf(col, col, col, col)
|
||||
val bp = bezierPatch(c0, c1, c2, c3).withColors(cols)
|
||||
val bpSub = bp.sub(0.1, 0.1, 0.6, 0.6)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
|
||||
val cam = Orbital()
|
||||
extend(cam){
|
||||
eye = Vector3(x=9.9, y=12.8, z=6.9)
|
||||
lookAt = Vector3(x=1.6, y=-1.9, z=1.2)
|
||||
drawer.translate(-5.0, 0.0, 0.0)
|
||||
// Show the segments that form the bezier patch
|
||||
drawer.stroke = ColorRGBa.YELLOW
|
||||
drawer.strokeWeight = 50.0
|
||||
drawer.segments(listOf(c0, c1, c2, c3))
|
||||
|
||||
// Show the grid
|
||||
drawer.strokeWeight = 1.0
|
||||
val n = 10
|
||||
for (i in 0..n) {
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
drawer.lineStrip(bp.horizontal(i / n.toDouble()).adaptivePositions(0.01))
|
||||
drawer.lineStrip(bp.vertical(i / n.toDouble()).adaptivePositions(0.01))
|
||||
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.lineStrip(bpSub.horizontal(i / n.toDouble()).adaptivePositions(0.01))
|
||||
drawer.lineStrip(bpSub.vertical(i / n.toDouble()).adaptivePositions(0.01))
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
|
||||
drawer.translate(-5.0, 0.0, 0.0)
|
||||
// Show the segments that form the bezier patch
|
||||
drawer.stroke = ColorRGBa.YELLOW
|
||||
drawer.strokeWeight = 50.0
|
||||
drawer.segments(listOf(c0, c1, c2, c3))
|
||||
|
||||
// Show the grid
|
||||
drawer.strokeWeight = 1.0
|
||||
val n = 10
|
||||
for (i in 0..n) {
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
drawer.lineStrip(bp.horizontal(i / n.toDouble()).adaptivePositions(0.01))
|
||||
drawer.lineStrip(bp.vertical(i / n.toDouble()).adaptivePositions(0.01))
|
||||
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.lineStrip(bpSub.horizontal(i / n.toDouble()).adaptivePositions(0.01))
|
||||
drawer.lineStrip(bpSub.vertical(i / n.toDouble()).adaptivePositions(0.01))
|
||||
}
|
||||
|
||||
// Draw the colored Bezier surface
|
||||
drawer.translate(10.0, 0.0, 0.0)
|
||||
drawer.bezierPatch(bp)
|
||||
}
|
||||
// Draw the colored Bezier surface
|
||||
drawer.translate(10.0, 0.0, 0.0)
|
||||
drawer.bezierPatch(bp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,33 +5,31 @@ import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.shapes.bezierpatches.bezierPatch
|
||||
import org.openrndr.shape.Circle
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
val bp = bezierPatch(
|
||||
Circle(width/2.0, height/2.0, 200.0).contour
|
||||
).withColors(
|
||||
listOf(
|
||||
fun main() = application {
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
val bp = bezierPatch(
|
||||
Circle(width / 2.0, height / 2.0, 200.0).contour
|
||||
).withColors(
|
||||
listOf(
|
||||
listOf(ColorRGBa.PINK, ColorRGBa.RED, ColorRGBa.BLACK, ColorRGBa.BLUE),
|
||||
listOf(ColorRGBa.RED, ColorRGBa.BLACK, ColorRGBa.BLUE, ColorRGBa.GREEN),
|
||||
listOf(ColorRGBa.PINK, ColorRGBa.RED, ColorRGBa.WHITE, ColorRGBa.GREEN),
|
||||
listOf(ColorRGBa.BLACK, ColorRGBa.WHITE, ColorRGBa.BLACK, ColorRGBa.BLUE),
|
||||
)
|
||||
listOf(ColorRGBa.RED, ColorRGBa.BLACK, ColorRGBa.BLUE, ColorRGBa.GREEN),
|
||||
listOf(ColorRGBa.PINK, ColorRGBa.RED, ColorRGBa.WHITE, ColorRGBa.GREEN),
|
||||
listOf(ColorRGBa.BLACK, ColorRGBa.WHITE, ColorRGBa.BLACK, ColorRGBa.BLUE),
|
||||
)
|
||||
)
|
||||
|
||||
drawer.bezierPatch(bp)
|
||||
drawer.bezierPatch(bp)
|
||||
|
||||
drawer.fill = null
|
||||
drawer.contour(bp.contour)
|
||||
for (i in 0 until 10) {
|
||||
drawer.contour(bp.horizontal(i/9.0))
|
||||
}
|
||||
for (i in 0 until 10) {
|
||||
drawer.contour(bp.vertical(i/9.0))
|
||||
}
|
||||
drawer.fill = null
|
||||
drawer.contour(bp.contour)
|
||||
for (i in 0 until 10) {
|
||||
drawer.contour(bp.horizontal(i / 9.0))
|
||||
}
|
||||
for (i in 0 until 10) {
|
||||
drawer.contour(bp.vertical(i / 9.0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,43 +7,61 @@ import org.openrndr.extra.color.spaces.toOKLABa
|
||||
import org.openrndr.extra.shapes.bezierpatches.bezierPatch
|
||||
import org.openrndr.shape.Circle
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
val bp2 = bezierPatch(
|
||||
Circle(width/2.0 - 180.0, height/2.0, 170.0).contour
|
||||
).withColors(
|
||||
listOf(
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
val bp2 = bezierPatch(
|
||||
Circle(width / 2.0 - 180.0, height / 2.0, 170.0).contour
|
||||
).withColors(
|
||||
listOf(
|
||||
listOf(ColorRGBa.PINK, ColorRGBa.PINK, ColorRGBa.PINK, ColorRGBa.PINK),
|
||||
listOf(ColorRGBa.RED, ColorRGBa.RED, ColorRGBa.RED, ColorRGBa.RED),
|
||||
listOf(ColorRGBa.BLUE, ColorRGBa.BLUE, ColorRGBa.BLUE, ColorRGBa.BLUE),
|
||||
listOf(ColorRGBa.WHITE, ColorRGBa.WHITE, ColorRGBa.WHITE, ColorRGBa.WHITE),
|
||||
)
|
||||
listOf(ColorRGBa.RED, ColorRGBa.RED, ColorRGBa.RED, ColorRGBa.RED),
|
||||
listOf(ColorRGBa.BLUE, ColorRGBa.BLUE, ColorRGBa.BLUE, ColorRGBa.BLUE),
|
||||
listOf(ColorRGBa.WHITE, ColorRGBa.WHITE, ColorRGBa.WHITE, ColorRGBa.WHITE),
|
||||
)
|
||||
drawer.bezierPatch(bp2)
|
||||
val bp3 = bezierPatch(
|
||||
Circle(width/2.0 + 180.0, height/2.0, 170.0).contour
|
||||
).withColors(
|
||||
)
|
||||
drawer.bezierPatch(bp2)
|
||||
val bp3 = bezierPatch(
|
||||
Circle(width / 2.0 + 180.0, height / 2.0, 170.0).contour
|
||||
).withColors(
|
||||
listOf(
|
||||
listOf(
|
||||
listOf(ColorRGBa.PINK.toOKLABa(), ColorRGBa.PINK.toOKLABa(), ColorRGBa.PINK.toOKLABa(), ColorRGBa.PINK.toOKLABa()),
|
||||
listOf(ColorRGBa.RED.toOKLABa(), ColorRGBa.RED.toOKLABa(), ColorRGBa.RED.toOKLABa(), ColorRGBa.RED.toOKLABa()),
|
||||
listOf(ColorRGBa.BLUE.toOKLABa(), ColorRGBa.BLUE.toOKLABa(), ColorRGBa.BLUE.toOKLABa(), ColorRGBa.BLUE.toOKLABa()),
|
||||
listOf(ColorRGBa.WHITE.toOKLABa(), ColorRGBa.WHITE.toOKLABa(), ColorRGBa.WHITE.toOKLABa(), ColorRGBa.WHITE.toOKLABa()),
|
||||
)
|
||||
ColorRGBa.PINK.toOKLABa(),
|
||||
ColorRGBa.PINK.toOKLABa(),
|
||||
ColorRGBa.PINK.toOKLABa(),
|
||||
ColorRGBa.PINK.toOKLABa()
|
||||
),
|
||||
listOf(
|
||||
ColorRGBa.RED.toOKLABa(),
|
||||
ColorRGBa.RED.toOKLABa(),
|
||||
ColorRGBa.RED.toOKLABa(),
|
||||
ColorRGBa.RED.toOKLABa()
|
||||
),
|
||||
listOf(
|
||||
ColorRGBa.BLUE.toOKLABa(),
|
||||
ColorRGBa.BLUE.toOKLABa(),
|
||||
ColorRGBa.BLUE.toOKLABa(),
|
||||
ColorRGBa.BLUE.toOKLABa()
|
||||
),
|
||||
listOf(
|
||||
ColorRGBa.WHITE.toOKLABa(),
|
||||
ColorRGBa.WHITE.toOKLABa(),
|
||||
ColorRGBa.WHITE.toOKLABa(),
|
||||
ColorRGBa.WHITE.toOKLABa()
|
||||
),
|
||||
)
|
||||
drawer.bezierPatch(bp3)
|
||||
)
|
||||
drawer.bezierPatch(bp3)
|
||||
|
||||
drawer.fill = ColorRGBa.WHITE
|
||||
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
|
||||
drawer.text("RGB", width/2.0 - 180.0, height/2.0 + 200.0)
|
||||
drawer.text("OKLab", width/2.0 + 180.0, height/2.0 + 200.0)
|
||||
}
|
||||
drawer.fill = ColorRGBa.WHITE
|
||||
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
|
||||
drawer.text("RGB", width / 2.0 - 180.0, height / 2.0 + 200.0)
|
||||
drawer.text("OKLab", width / 2.0 + 180.0, height / 2.0 + 200.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,49 +13,67 @@ import org.openrndr.shape.Circle
|
||||
import org.openrndr.shape.Rectangle
|
||||
import kotlin.math.min
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
val colors = listOf(
|
||||
listOf(ColorRGBa.PINK.toOKLABa(), ColorRGBa.PINK.toOKLABa(), ColorRGBa.PINK.toOKLABa(), ColorRGBa.PINK.toOKLABa()),
|
||||
listOf(ColorRGBa.RED.toOKLABa(), ColorRGBa.RED.toOKLABa(), ColorRGBa.RED.toOKLABa(), ColorRGBa.RED.toOKLABa()),
|
||||
listOf(ColorRGBa.BLUE.toOKLABa(), ColorRGBa.BLUE.toOKLABa(), ColorRGBa.BLUE.toOKLABa(), ColorRGBa.BLUE.toOKLABa()),
|
||||
listOf(ColorRGBa.WHITE.toOKLABa(), ColorRGBa.WHITE.toOKLABa(), ColorRGBa.WHITE.toOKLABa(), ColorRGBa.WHITE.toOKLABa()),
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
val colors = listOf(
|
||||
listOf(
|
||||
ColorRGBa.PINK.toOKLABa(),
|
||||
ColorRGBa.PINK.toOKLABa(),
|
||||
ColorRGBa.PINK.toOKLABa(),
|
||||
ColorRGBa.PINK.toOKLABa()
|
||||
),
|
||||
listOf(
|
||||
ColorRGBa.RED.toOKLABa(),
|
||||
ColorRGBa.RED.toOKLABa(),
|
||||
ColorRGBa.RED.toOKLABa(),
|
||||
ColorRGBa.RED.toOKLABa()
|
||||
),
|
||||
listOf(
|
||||
ColorRGBa.BLUE.toOKLABa(),
|
||||
ColorRGBa.BLUE.toOKLABa(),
|
||||
ColorRGBa.BLUE.toOKLABa(),
|
||||
ColorRGBa.BLUE.toOKLABa()
|
||||
),
|
||||
listOf(
|
||||
ColorRGBa.WHITE.toOKLABa(),
|
||||
ColorRGBa.WHITE.toOKLABa(),
|
||||
ColorRGBa.WHITE.toOKLABa(),
|
||||
ColorRGBa.WHITE.toOKLABa()
|
||||
),
|
||||
)
|
||||
|
||||
val grid = drawer.bounds.grid(4, 4, marginX = 20.0, marginY = 20.0, gutterX = 10.0, gutterY = 10.0)
|
||||
|
||||
val cellWidth = grid[0][0].width
|
||||
val cellHeight = grid[0][0].height
|
||||
|
||||
val a = bezierPatch(Rectangle.fromCenter(Vector2(0.0, 0.0), cellWidth, cellHeight).contour)
|
||||
.withColors(colors)
|
||||
|
||||
val b = bezierPatch(
|
||||
Circle(0.0, 0.0, min(cellWidth, cellHeight) / 2.0).contour.transform(
|
||||
buildTransform {
|
||||
rotate(Vector3.UNIT_Z, 45.0)
|
||||
}
|
||||
)
|
||||
).withColors(colors)
|
||||
|
||||
val grid = drawer.bounds.grid(4,4, marginX = 20.0, marginY = 20.0, gutterX = 10.0, gutterY = 10.0)
|
||||
|
||||
val cellWidth = grid[0][0].width
|
||||
val cellHeight = grid[0][0].height
|
||||
|
||||
val a = bezierPatch(Rectangle.fromCenter(Vector2(0.0, 0.0), cellWidth, cellHeight).contour)
|
||||
.withColors(colors)
|
||||
|
||||
val b = bezierPatch(
|
||||
Circle(0.0, 0.0, min(cellWidth, cellHeight) / 2.0).contour.transform(
|
||||
buildTransform {
|
||||
rotate(Vector3.UNIT_Z, 45.0)
|
||||
}
|
||||
)
|
||||
).withColors(colors)
|
||||
|
||||
for (y in grid.indices) {
|
||||
for (x in grid[y].indices) {
|
||||
val f = (y * grid[y].size + x).toDouble() / (grid.size * grid[y].size - 1.0)
|
||||
val blend = a * (1.0 - f) + b * f
|
||||
drawer.isolated {
|
||||
drawer.translate(grid[y][x].center)
|
||||
drawer.bezierPatch(blend)
|
||||
}
|
||||
for (y in grid.indices) {
|
||||
for (x in grid[y].indices) {
|
||||
val f = (y * grid[y].size + x).toDouble() / (grid.size * grid[y].size - 1.0)
|
||||
val blend = a * (1.0 - f) + b * f
|
||||
drawer.isolated {
|
||||
drawer.translate(grid[y][x].center)
|
||||
drawer.bezierPatch(blend)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,23 +15,21 @@ import org.openrndr.shape.ShapeContour
|
||||
* but one can manually create any other 4-segment closed contour
|
||||
* to use in bezier patches.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
val c0 = Circle(width / 3.0, height / 2.0, 150.0).contour
|
||||
val bp0 = bezierPatch(c0)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
val c0 = Circle(width / 3.0, height / 2.0, 150.0).contour
|
||||
val bp0 = bezierPatch(c0)
|
||||
|
||||
val c1 = Circle(2.0*width / 3.0, height / 2.0, 150.0).contour
|
||||
val bp1 = bezierPatch(c1)
|
||||
val c1 = Circle(2.0 * width / 3.0, height / 2.0, 150.0).contour
|
||||
val bp1 = bezierPatch(c1)
|
||||
|
||||
|
||||
extend {
|
||||
drawer.bezierPatches(listOf(bp0, bp1))
|
||||
}
|
||||
extend {
|
||||
drawer.bezierPatches(listOf(bp0, bp1))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,28 +10,25 @@ import org.openrndr.shape.Circle
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
|
||||
|
||||
/**
|
||||
* Demonstration of uniform contour blending
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val a = Circle(Vector2.ZERO, 90.0).contour
|
||||
val b = regularStar(5, 30.0, 90.0, center = Vector2.ZERO, phase = 180.0)
|
||||
val blend = a.blend(b)
|
||||
extend {
|
||||
drawer.bounds.grid(3, 3).flatten().forEachIndexed { index, it ->
|
||||
drawer.isolated {
|
||||
drawer.translate(it.center)
|
||||
drawer.contour(blend.mix(cos(index * PI * 2.0 / 9.0 + seconds) * 0.5 + 0.5))
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val a = Circle(Vector2.ZERO, 90.0).contour
|
||||
val b = regularStar(5, 30.0, 90.0, center = Vector2.ZERO, phase = 180.0)
|
||||
val blend = a.blend(b)
|
||||
extend {
|
||||
drawer.bounds.grid(3, 3).flatten().forEachIndexed { index, it ->
|
||||
drawer.isolated {
|
||||
drawer.translate(it.center)
|
||||
drawer.contour(blend.mix(cos(index * PI * 2.0 / 9.0 + seconds) * 0.5 + 0.5))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,26 +14,24 @@ import kotlin.math.cos
|
||||
/**
|
||||
* Demonstration of non-uniform contour blending
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val a = Circle(Vector2.ZERO, 90.0).contour
|
||||
val b = regularStar(5, 30.0, 90.0, center = Vector2.ZERO, phase = 180.0)
|
||||
val blend = a.blend(b)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
drawer.bounds.grid(3, 3).flatten().forEachIndexed { index, it ->
|
||||
drawer.isolated {
|
||||
drawer.translate(it.center)
|
||||
drawer.contour(blend.mix { t -> cos(t * PI * 2.0 + index * PI * 2.0 / 9.0 + seconds) * 0.5 + 0.5 })
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val a = Circle(Vector2.ZERO, 90.0).contour
|
||||
val b = regularStar(5, 30.0, 90.0, center = Vector2.ZERO, phase = 180.0)
|
||||
val blend = a.blend(b)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
drawer.bounds.grid(3, 3).flatten().forEachIndexed { index, it ->
|
||||
drawer.isolated {
|
||||
drawer.translate(it.center)
|
||||
drawer.contour(blend.mix { t -> cos(t * PI * 2.0 + index * PI * 2.0 / 9.0 + seconds) * 0.5 + 0.5 })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,53 +15,50 @@ import org.openrndr.math.Vector3
|
||||
import org.openrndr.shape.path3D
|
||||
import kotlin.random.Random
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(4)
|
||||
}
|
||||
program {
|
||||
val random = Random(0)
|
||||
val cylinder = cylinderMesh(radius = 0.5, length = 0.1)
|
||||
val p = path3D {
|
||||
moveTo(0.0, 0.0, 0.0)
|
||||
curveTo(
|
||||
Vector3.uniformRing(0.1, 1.0, random = random)*10.0,
|
||||
Vector3.uniformRing(0.1, 1.0, random = random)*10.0,
|
||||
Vector3.uniformRing(0.1, 1.0, random = random)*10.0
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(4)
|
||||
}
|
||||
program {
|
||||
val random = Random(0)
|
||||
val cylinder = cylinderMesh(radius = 0.5, length = 0.1)
|
||||
val p = path3D {
|
||||
moveTo(0.0, 0.0, 0.0)
|
||||
curveTo(
|
||||
Vector3.uniformRing(0.1, 1.0, random = random) * 10.0,
|
||||
Vector3.uniformRing(0.1, 1.0, random = random) * 10.0,
|
||||
Vector3.uniformRing(0.1, 1.0, random = random) * 10.0
|
||||
)
|
||||
for (i in 0 until 10) {
|
||||
continueTo(
|
||||
Vector3.uniformRing(0.1, 1.0, random = random) * 10.0,
|
||||
Vector3.uniformRing(0.1, 1.0, random = random) * 10.0
|
||||
)
|
||||
for (i in 0 until 10) {
|
||||
continueTo(
|
||||
Vector3.uniformRing(0.1, 1.0, random = random)*10.0,
|
||||
Vector3.uniformRing(0.1, 1.0, random = random)*10.0
|
||||
)
|
||||
}
|
||||
}
|
||||
val pr = p.rectified(0.01, 100.0)
|
||||
}
|
||||
val pr = p.rectified(0.01, 100.0)
|
||||
|
||||
|
||||
val frames = pr.frames((0 until 100).map { it / 100.0}, Vector3.UNIT_Y, analyticalDirections = false)
|
||||
extend(Orbital())
|
||||
extend {
|
||||
drawer.shadeStyle = shadeStyle {
|
||||
fragmentTransform = """
|
||||
val frames = pr.frames((0 until 100).map { it / 100.0 }, Vector3.UNIT_Y, analyticalDirections = false)
|
||||
extend(Orbital())
|
||||
extend {
|
||||
drawer.shadeStyle = shadeStyle {
|
||||
fragmentTransform = """
|
||||
x_fill.rgb = vec3(abs(v_viewNormal.z)*0.9+ 0.1);
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.path(p)
|
||||
|
||||
for (frame in frames) {
|
||||
drawer.isolated {
|
||||
drawer.model = frame
|
||||
drawer.vertexBuffer(cylinder, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.path(p)
|
||||
|
||||
for (frame in frames) {
|
||||
drawer.isolated {
|
||||
drawer.model = frame
|
||||
drawer.vertexBuffer(cylinder, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,20 +6,18 @@ import org.openrndr.extra.noise.uniform
|
||||
import org.openrndr.extra.shapes.ordering.hilbertOrder
|
||||
import kotlin.random.Random
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val points = drawer.bounds.offsetEdges(-20.0).uniform(40, Random(0))
|
||||
val sortedPoints = points.hilbertOrder(bits = 16, scale = 1.0)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.lineStrip(sortedPoints)
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val points = drawer.bounds.offsetEdges(-20.0).uniform(40, Random(0))
|
||||
val sortedPoints = points.hilbertOrder(bits = 16, scale = 1.0)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.lineStrip(sortedPoints)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,26 +4,23 @@ import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.noise.uniform
|
||||
import org.openrndr.extra.shapes.ordering.hilbertOrder
|
||||
import org.openrndr.extra.shapes.ordering.mortonOrder
|
||||
import kotlin.random.Random
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val points = drawer.bounds.offsetEdges(-20.0).uniform(400, Random(0))
|
||||
val sortedPoints0 = points.hilbertOrder(bits = 16, scale = 1.0)
|
||||
val sortedPoints1 = points.map { it.xy0 }.hilbertOrder(bits = 10, scale = 1.0).map { it.xy }
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.lineStrip(sortedPoints0)
|
||||
drawer.stroke = ColorRGBa.BLUE
|
||||
drawer.lineStrip(sortedPoints1)
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val points = drawer.bounds.offsetEdges(-20.0).uniform(400, Random(0))
|
||||
val sortedPoints0 = points.hilbertOrder(bits = 16, scale = 1.0)
|
||||
val sortedPoints1 = points.map { it.xy0 }.hilbertOrder(bits = 10, scale = 1.0).map { it.xy }
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.lineStrip(sortedPoints0)
|
||||
drawer.stroke = ColorRGBa.BLUE
|
||||
drawer.lineStrip(sortedPoints1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,38 +4,31 @@ import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.LineJoin
|
||||
import org.openrndr.extra.camera.Orbital
|
||||
import org.openrndr.extra.noise.uniformRing
|
||||
import org.openrndr.extra.shapes.path3d.projectToContour
|
||||
import org.openrndr.math.Spherical
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.shape.path3D
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
fun main() = application {
|
||||
program {
|
||||
val path = path3D {
|
||||
var p = Vector3(6.0, 0.0, 0.0)
|
||||
moveTo(p)
|
||||
for (i in 0 until 100) {
|
||||
p = Spherical((i % 6) * 45.0, (i % 4 + 1) * 30.0 + i * 0.1, 6.0).cartesian
|
||||
arcTo(5.0, cursor.atan2(p), false, false, p)
|
||||
}
|
||||
}
|
||||
program {
|
||||
val path = path3D {
|
||||
var p = Vector3(1.0, 0.0, 0.0)
|
||||
moveTo(p * 6.0)
|
||||
for (i in 0 until 400) {
|
||||
p += Vector3.uniformRing(0.2, 0.5)
|
||||
p = p.normalized
|
||||
arcTo(5.0, cursor.atan2(p * 6.0), false, false, p * 6.0)
|
||||
}
|
||||
}
|
||||
extend(Orbital())
|
||||
extend {
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.path(path)
|
||||
val c = path.projectToContour(drawer.projection, drawer.view, width, height)
|
||||
drawer.defaults()
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.lineJoin = LineJoin.ROUND
|
||||
drawer.strokeWeight = 2.0
|
||||
drawer.contour(c)
|
||||
}
|
||||
extend(Orbital())
|
||||
extend {
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.path(path)
|
||||
val c = path.projectToContour(drawer.projection, drawer.view, width, height)
|
||||
drawer.defaults()
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.lineJoin = LineJoin.ROUND
|
||||
drawer.strokeWeight = 2.0
|
||||
drawer.contour(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,26 +7,24 @@ import org.openrndr.extra.shapes.hobbycurve.hobbyCurve
|
||||
import org.openrndr.extra.shapes.rectify.rectified
|
||||
import kotlin.random.Random
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val points = drawer.bounds.scatter(50.0, distanceToEdge = 100.0, random = Random(0))
|
||||
val curve = hobbyCurve(points)
|
||||
val rectified = curve.rectified()
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.contour(curve)
|
||||
drawer.fill = ColorRGBa.RED
|
||||
drawer.circle(curve.position(seconds*0.05), 10.0)
|
||||
drawer.fill = ColorRGBa.GREEN
|
||||
drawer.circle(rectified.position(seconds*0.05), 10.0)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val points = drawer.bounds.scatter(50.0, distanceToEdge = 100.0, random = Random(0))
|
||||
val curve = hobbyCurve(points)
|
||||
val rectified = curve.rectified()
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.contour(curve)
|
||||
drawer.fill = ColorRGBa.RED
|
||||
drawer.circle(curve.position(seconds * 0.05), 10.0)
|
||||
drawer.fill = ColorRGBa.GREEN
|
||||
drawer.circle(rectified.position(seconds * 0.05), 10.0)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,29 +7,27 @@ import org.openrndr.extra.shapes.hobbycurve.hobbyCurve
|
||||
import org.openrndr.extra.shapes.rectify.rectified
|
||||
import kotlin.random.Random
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val points = drawer.bounds.scatter(80.0, distanceToEdge = 100.0, random = Random(0))
|
||||
val curve = hobbyCurve(points, closed = true)
|
||||
val rectified = curve.rectified()
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.GRAY
|
||||
drawer.contour(curve)
|
||||
drawer.strokeWeight = 4.0
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val points = drawer.bounds.scatter(80.0, distanceToEdge = 100.0, random = Random(0))
|
||||
val curve = hobbyCurve(points, closed = true)
|
||||
val rectified = curve.rectified()
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.GRAY
|
||||
drawer.contour(curve)
|
||||
drawer.strokeWeight = 4.0
|
||||
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(curve.sub(seconds*0.1, seconds*0.1+0.01))
|
||||
drawer.stroke = ColorRGBa.RED
|
||||
drawer.contour(curve.sub(seconds * 0.1, seconds * 0.1 + 0.01))
|
||||
|
||||
drawer.stroke = ColorRGBa.GREEN
|
||||
drawer.contour(rectified.sub(seconds*0.1, seconds*0.1+0.01))
|
||||
}
|
||||
drawer.stroke = ColorRGBa.GREEN
|
||||
drawer.contour(rectified.sub(seconds * 0.1, seconds * 0.1 + 0.01))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,28 +7,26 @@ import org.openrndr.extra.shapes.hobbycurve.hobbyCurve
|
||||
import org.openrndr.extra.shapes.rectify.rectified
|
||||
import kotlin.random.Random
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val points = drawer.bounds.scatter(80.0, distanceToEdge = 100.0, random = Random(0))
|
||||
val curve = hobbyCurve(points, closed = true)
|
||||
val rectified = curve.rectified()
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.GRAY
|
||||
drawer.contour(curve)
|
||||
|
||||
val points = (0 until 100).map {
|
||||
rectified.position(it/100.0)
|
||||
}
|
||||
drawer.circles(points, 5.0)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val points = drawer.bounds.scatter(80.0, distanceToEdge = 100.0, random = Random(0))
|
||||
val curve = hobbyCurve(points, closed = true)
|
||||
val rectified = curve.rectified()
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.GRAY
|
||||
drawer.contour(curve)
|
||||
|
||||
val points = (0 until 100).map {
|
||||
rectified.position(it / 100.0)
|
||||
}
|
||||
drawer.circles(points, 5.0)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,38 +12,35 @@ import org.openrndr.extra.shapes.rectify.rectified
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.shape.path3D
|
||||
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(4)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(4)
|
||||
}
|
||||
program {
|
||||
val p = path3D {
|
||||
moveTo(0.0, 0.0, 0.0)
|
||||
for (i in 0 until 10) {
|
||||
curveTo(
|
||||
Vector3.uniformRing(0.1, 1.0) * 10.0,
|
||||
Vector3.uniformRing(0.1, 1.0) * 10.0,
|
||||
Vector3.uniformRing(0.1, 1.0) * 10.0
|
||||
)
|
||||
}
|
||||
}
|
||||
program {
|
||||
val p = path3D {
|
||||
moveTo(0.0, 0.0, 0.0)
|
||||
for (i in 0 until 10) {
|
||||
curveTo(
|
||||
Vector3.uniformRing(0.1, 1.0)*10.0,
|
||||
Vector3.uniformRing(0.1, 1.0)*10.0,
|
||||
Vector3.uniformRing(0.1, 1.0)*10.0
|
||||
)
|
||||
val pr = p.rectified(0.01, 100.0)
|
||||
val sphere = sphereMesh(radius = 0.1)
|
||||
extend(Orbital())
|
||||
extend {
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
for (i in 0 until 500) {
|
||||
drawer.isolated {
|
||||
drawer.translate(pr.position(i / 499.0))
|
||||
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
val pr = p.rectified(0.01, 100.0)
|
||||
val sphere = sphereMesh(radius = 0.1)
|
||||
extend(Orbital())
|
||||
extend {
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
for (i in 0 until 500) {
|
||||
drawer.isolated {
|
||||
drawer.translate(pr.position(i/499.0))
|
||||
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
drawer.path(p)
|
||||
}
|
||||
drawer.path(p)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,26 +6,23 @@ import org.openrndr.draw.font.loadFace
|
||||
import org.openrndr.extra.shapes.bounds.bounds
|
||||
import org.openrndr.extra.shapes.text.shapesFromText
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val face =
|
||||
loadFace("https://github.com/IBM/plex/raw/master/packages/plex-mono/fonts/complete/otf/IBMPlexMono-Bold.otf")
|
||||
val shapes = shapesFromText(face, "SUCH\nVECTOR\nSUCH\nTEXT", 150.0)
|
||||
|
||||
val face =
|
||||
loadFace("https://github.com/IBM/plex/raw/master/packages/plex-mono/fonts/complete/otf/IBMPlexMono-Bold.otf")
|
||||
val shapes = shapesFromText(face, "SUCH\nVECTOR\nSUCH\nTEXT", 150.0)
|
||||
|
||||
val bounds = shapes.bounds
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.translate(-bounds.corner)
|
||||
drawer.translate((width - bounds.width) / 2.0, (height - bounds.height) / 2.0)
|
||||
drawer.shapes(shapes)
|
||||
}
|
||||
val bounds = shapes.bounds
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.translate(-bounds.corner)
|
||||
drawer.translate((width - bounds.width) / 2.0, (height - bounds.height) / 2.0)
|
||||
drawer.shapes(shapes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,24 +8,22 @@ import org.openrndr.extra.shapes.tunni.withTunniLine
|
||||
import org.openrndr.shape.Circle
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
extend {
|
||||
val c = Circle(drawer.bounds.center, 200.0).contour
|
||||
val c2 = adjustContour(c) {
|
||||
selectEdges { it -> true }
|
||||
for (e in edges) {
|
||||
val tl = e.tunniLine
|
||||
e.withTunniLine(tl.position(0.5) + tl.normal * cos(seconds)*200.0)
|
||||
}
|
||||
fun main() = application {
|
||||
program {
|
||||
extend {
|
||||
val c = Circle(drawer.bounds.center, 200.0).contour
|
||||
val c2 = adjustContour(c) {
|
||||
selectEdges { it -> true }
|
||||
for (e in edges) {
|
||||
val tl = e.tunniLine
|
||||
e.withTunniLine(tl.position(0.5) + tl.normal * cos(seconds) * 200.0)
|
||||
}
|
||||
for (s in c2.segments) {
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.lineSegment(s.tunniLine)
|
||||
}
|
||||
drawer.contour(c2)
|
||||
}
|
||||
for (s in c2.segments) {
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.lineSegment(s.tunniLine)
|
||||
}
|
||||
drawer.contour(c2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,26 +8,24 @@ import org.openrndr.extra.shapes.tunni.withTunniLine
|
||||
import org.openrndr.shape.Circle
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
val c = Circle(drawer.bounds.center, 200.0).contour
|
||||
fun main() = application {
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
val c = Circle(drawer.bounds.center, 200.0).contour
|
||||
|
||||
drawer.fill = null
|
||||
for (s in c.segments) {
|
||||
val tp = s.tunniPoint
|
||||
drawer.circle(tp, 10.0)
|
||||
val sc = s.cubic
|
||||
drawer.lineSegment(sc.control[0], sc.control[1])
|
||||
//drawer.segment(s.withTunniPoint(tp + (mouse.position - drawer.bounds.center)/2.0))
|
||||
drawer.segment(s.withTunniLine(s.tunniLine.position(0.5) + s.tunniLine.normal * cos(seconds) * 40.0))
|
||||
drawer.fill = null
|
||||
for (s in c.segments) {
|
||||
val tp = s.tunniPoint
|
||||
drawer.circle(tp, 10.0)
|
||||
val sc = s.cubic
|
||||
drawer.lineSegment(sc.control[0], sc.control[1])
|
||||
//drawer.segment(s.withTunniPoint(tp + (mouse.position - drawer.bounds.center)/2.0))
|
||||
drawer.segment(s.withTunniLine(s.tunniLine.position(0.5) + s.tunniLine.normal * cos(seconds) * 40.0))
|
||||
|
||||
}
|
||||
drawer.contour(c)
|
||||
}
|
||||
drawer.contour(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user