From 97ecb7ca1469bc71d3eb3adb23ffc2b7740ce5f4 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Fri, 3 Feb 2023 07:12:53 +0100 Subject: [PATCH] [orx-marching-squares] Update README.md --- orx-marching-squares/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/orx-marching-squares/README.md b/orx-marching-squares/README.md index 088204b0..5c2529b8 100644 --- a/orx-marching-squares/README.md +++ b/orx-marching-squares/README.md @@ -8,16 +8,16 @@ Tools for extracting contours from functions ```kotlin fun f(v: Vector2) = v.distanceTo(drawer.bounds.center) - 200.0 -val segments = findContours(::f, drawer.bounds, 16.0) -drawer.lineSegments(segments) +val contours = findContours(::f, drawer.bounds, 16.0) +drawer.contours(contours) ``` With a small adjustment to the given function one can use `findContours` to find iso contours. The trick is to add a cosine over the distance function. ```kotlin fun f(v: Vector2) = cos((v.distanceTo(drawer.bounds.center) / 100.0) * 2 * PI) -val segments = findContours(::f, drawer.bounds.offsetEdges(32.0), 16.0) -drawer.lineSegments(segments) +val contours = findContours(::f, drawer.bounds.offsetEdges(32.0), 16.0) +drawer.contours(contours) ``` ## Demos