-
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.
[orx-noise] Fix bug in List<Triangle>.uniform
- Loading branch information
Showing
2 changed files
with
32 additions
and
1 deletion.
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
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,31 @@ | ||
import org.openrndr.application | ||
import org.openrndr.color.ColorRGBa | ||
import org.openrndr.extra.noise.uniform | ||
import org.openrndr.shape.Triangle | ||
import kotlin.random.Random | ||
|
||
/** | ||
* Demonstrate the generation of uniformly distributed points inside a list of triangles | ||
* @see <img src="https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoTriangleNoise01Kt.png"> | ||
*/ | ||
fun main() { | ||
application { | ||
configure { | ||
width = 720 | ||
height = 720 | ||
} | ||
program { | ||
val r = drawer.bounds.offsetEdges(-100.0) | ||
val triangle = Triangle(r.position(0.5, 0.0), r.position(0.0, 1.0), r.position(1.0, 1.0)) | ||
val pts = listOf(triangle).uniform(1000, Random(0)) | ||
extend { | ||
drawer.clear(ColorRGBa.PINK) | ||
drawer.stroke = null | ||
drawer.contour(triangle.contour) | ||
drawer.fill = ColorRGBa.BLACK | ||
|
||
drawer.circles(pts, 5.0) | ||
} | ||
} | ||
} | ||
} |