add demos to README.md
This commit is contained in:
@@ -75,16 +75,19 @@ The program performs the following steps:
|
|||||||
- Filters the generated points to enforce a minimum distance of 20.0 units between them.
|
- Filters the generated points to enforce a minimum distance of 20.0 units between them.
|
||||||
- Visualizes the filtered points as circles with a radius of 10.0 units on the canvas.
|
- Visualizes the filtered points as circles with a radius of 10.0 units on the canvas.
|
||||||
|
|
||||||
|
The `filter` method is provided by `orx-hash-grid`.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
[source code](src/jvmDemo/kotlin/DemoFilter01.kt)
|
[source code](src/jvmDemo/kotlin/DemoFilter01.kt)
|
||||||
|
|
||||||
### DemoFilter3D01
|
### DemoFilter3D01
|
||||||
|
|
||||||
This demo sets up and renders a 3D visualization of filtered random points displayed as small spheres.
|
Demonstrates how to use a 3D hash-grid `filter` operation to remove points from a random 3D point-collection
|
||||||
|
that are too close to each other. The resulting points are displayed as small spheres.
|
||||||
|
|
||||||
The program performs the following key steps:
|
The program performs the following key steps:
|
||||||
- Generates 10,000 random 3D points within a ring defined by a minimum and maximum radius.
|
- Generates 10,000 random 3D points located between a minimum and maximum radius.
|
||||||
- Filters the points to ensure a minimum distance between any two points using a spatial hash grid.
|
- Filters the points to ensure a minimum distance between any two points using a spatial hash grid.
|
||||||
- Creates a small sphere mesh that will be instanced for each filtered point.
|
- Creates a small sphere mesh that will be instanced for each filtered point.
|
||||||
- Sets up an orbital camera to allow viewing the 3D scene interactively.
|
- Sets up an orbital camera to allow viewing the 3D scene interactively.
|
||||||
@@ -96,13 +99,15 @@ The program performs the following key steps:
|
|||||||
|
|
||||||
### DemoHashGrid01
|
### DemoHashGrid01
|
||||||
|
|
||||||
This demo sets up an interactive graphics application with a configurable
|
This demo creates a `HashGrid` to manage points in a 2D space.
|
||||||
display window and visualization logic. It uses a `HashGrid` to manage points
|
Notice the desired cell size in the HashGrid constructor.
|
||||||
in a 2D space and randomly generates points within the drawable area. These
|
|
||||||
points are then inserted into the grid if they satisfy certain spatial conditions.
|
On every animation frame, it attempts to insert 100 random points into the HashGrid.
|
||||||
|
When a HashGrid cell is free, a point is inserted.
|
||||||
|
|
||||||
The visual output includes:
|
The visual output includes:
|
||||||
- Rectangles representing the bounds of the cells in the grid.
|
- Rectangles representing the bounds of the occupied cells in the grid.
|
||||||
- Circles representing the generated points.
|
- Circles representing the generated random points.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,15 @@ fun main() = application {
|
|||||||
## Demos
|
## Demos
|
||||||
### DemoImageFit01
|
### DemoImageFit01
|
||||||
|
|
||||||
Tests `drawer.imageFit()` with all FitMethods for portrait and landscape images.
|
This program uses `drawer.imageFit()` to draw images using nested grid layout.
|
||||||
|
The main grid features 4 columns for the `Cover`, `Contain`, `Fill` and `None` fit methods,
|
||||||
|
and two rows for portrait and landscape images.
|
||||||
|
Each of those 8 cells feature a 3x3 grid, with cells combining `left`, `center` and `right` alignment
|
||||||
|
with `top`, `center` and `bottom` alignment.
|
||||||
|
|
||||||
|
The image drawn in each cell is a simple image with a white background and two touching circles:
|
||||||
|
a pink one and a gray one. In some of the cells part of this image is cropped out (due to the fit method used).
|
||||||
|
In other cells the image does not fully cover the available area, revealing a dark gray background.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -80,7 +88,15 @@ Tests `drawer.imageFit()` with all FitMethods for portrait and landscape images.
|
|||||||
|
|
||||||
### DemoImageFitSub01
|
### DemoImageFitSub01
|
||||||
|
|
||||||
|
Demonstrates the `imageFitSub()` method, which allows specifying not only a target `Rectangle`,
|
||||||
|
but also a source `Rectangle`, which is used to set the area of the original image we want to fit
|
||||||
|
into the target.
|
||||||
|
|
||||||
|
The program also demonstrates the `Rectangle.uniformSub` method, which returns a random sub-rectangle
|
||||||
|
taking into consideration the minimum and maximum width and height arguments.
|
||||||
|
|
||||||
|
Notice the trick used to generate unique random results changing only once per second by using
|
||||||
|
the current seconds as an integer seed.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user