-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[openrndr-demos] Add rectangle batch demos
- Loading branch information
Showing
6 changed files
with
87 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 18 additions & 18 deletions
36
openrndr-demos/src/demo/kotlin/DemoCompositionDrawer01.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// A single rectangle | ||
|
||
import org.openrndr.application | ||
import org.openrndr.color.ColorRGBa | ||
|
||
fun main() = application { | ||
program { | ||
extend { | ||
drawer.clear(ColorRGBa.GRAY) | ||
drawer.fill = ColorRGBa.PINK | ||
drawer.stroke = ColorRGBa.WHITE | ||
drawer.strokeWeight = 2.0 | ||
drawer.rectangle(100.0, 100.0, 50.0, 50.0) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Stored rectangle batches | ||
import org.openrndr.application | ||
import org.openrndr.color.ColorRGBa | ||
import org.openrndr.draw.rectangleBatch | ||
|
||
fun main() = application { | ||
program { | ||
val batch = drawer.rectangleBatch { | ||
fill = ColorRGBa.PINK | ||
stroke = ColorRGBa.WHITE | ||
for (i in 0 until 1000) { | ||
strokeWeight = Math.random() * 5.0 + 1.0 | ||
val rwidth = Math.random() * 40.0 + 4.0 | ||
val rheight = Math.random() * 40.0 + 4.0 | ||
val x = Math.random() * width | ||
val y = Math.random() * height | ||
rectangle(x, y, rwidth, rheight, Math.random() * 360.0) | ||
} | ||
} | ||
|
||
extend { | ||
drawer.clear(ColorRGBa.GRAY) | ||
drawer.fill = ColorRGBa.PINK | ||
drawer.stroke = ColorRGBa.WHITE | ||
drawer.strokeWeight = 2.0 | ||
drawer.rectangles(batch) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Dynamic rectangle batches | ||
|
||
import org.openrndr.application | ||
import org.openrndr.color.ColorRGBa | ||
|
||
fun main() = application { | ||
program { | ||
extend { | ||
drawer.clear(ColorRGBa.GRAY) | ||
drawer.fill = ColorRGBa.PINK | ||
drawer.stroke = ColorRGBa.WHITE | ||
drawer.strokeWeight = 2.0 | ||
drawer.rectangles { | ||
for (y in 0 until height/20) { | ||
for (x in 0 until width/20) { | ||
rectangle(x * 20.0, y * 20.0, 10.0, 15.0, (x + y) * 10.0 + seconds*90.0) | ||
|
||
} | ||
} | ||
} | ||
} | ||
} | ||
} |