diff --git a/build.gradle b/build.gradle index c61734ca..ab94c926 100644 --- a/build.gradle +++ b/build.gradle @@ -15,8 +15,8 @@ buildscript { apply plugin: 'org.jetbrains.dokka' project.ext { - openrndrVersion = "0.3.40" - kotlinVersion = "1.3.70" + openrndrVersion = "0.3.41-rc.1" + kotlinVersion = "1.3.71" spekVersion = "2.0.10" libfreenectVersion = "0.5.7-1.5.2" gsonVersion = "2.8.6" diff --git a/orx-mesh-generators/src/main/kotlin/Cap.kt b/orx-mesh-generators/src/main/kotlin/Cap.kt index 994d2ccc..9a17cc5f 100644 --- a/orx-mesh-generators/src/main/kotlin/Cap.kt +++ b/orx-mesh-generators/src/main/kotlin/Cap.kt @@ -13,7 +13,7 @@ fun generateCap(sides: Int, radius: Double, enveloppe: List = listOf(Ve val normals2D = enveloppe.zipWithNext().map { val d = it.second - it.first - d.normalized.perpendicular + d.normalized.perpendicular() } val basePositions = cleanEnveloppe.map { Vector3(it.x, it.y, 0.0) } @@ -57,7 +57,7 @@ fun generateRevolve(sides: Int, length: Double, enveloppe: List = listO val normals2D = enveloppe.zipWithNext().map { val d = it.second - it.first - d.normalized.perpendicular * Vector2(1.0, -1.0) + d.normalized.perpendicular() * Vector2(1.0, -1.0) } diff --git a/orx-mesh-generators/src/main/kotlin/Cylinder.kt b/orx-mesh-generators/src/main/kotlin/Cylinder.kt index d655666e..551efd24 100644 --- a/orx-mesh-generators/src/main/kotlin/Cylinder.kt +++ b/orx-mesh-generators/src/main/kotlin/Cylinder.kt @@ -28,7 +28,7 @@ fun generateTaperedCylinder(sides: Int, segments: Int, radiusStart: Double, radi val dr = radiusEnd - radiusStart - val baseNormal = Vector2(length, dr).normalized.perpendicular.let { Vector3(x=it.y, y=0.0, z=it.x)} + val baseNormal = Vector2(length, dr).normalized.perpendicular().let { Vector3(x=it.y, y=0.0, z=it.x)} //val baseNormal = Vector3(1.0, 0.0, 0.0) for (segment in 0 until segments) { diff --git a/orx-shapes/src/main/kotlin/RegularPolygon.kt b/orx-shapes/src/main/kotlin/RegularPolygon.kt index 7a4cb383..02132b6a 100644 --- a/orx-shapes/src/main/kotlin/RegularPolygon.kt +++ b/orx-shapes/src/main/kotlin/RegularPolygon.kt @@ -17,7 +17,7 @@ fun regularPolygon(sides: Int, center: Vector2 = Vector2.ZERO, radius: Double = } close() } - return c.reversed + return c } fun regularPolygonRounded(sides: Int, roundFactor: Double = 0.5, center: Vector2 = Vector2.ZERO, radius: Double = 100.0, phase: Double = 0.0): ShapeContour { @@ -55,7 +55,7 @@ fun regularPolygonRounded(sides: Int, roundFactor: Double = 0.5, center: Vector2 } close() } - return c.reversed + return c } fun regularPolygonBeveled(sides: Int, bevelFactor: Double = 0.5, center: Vector2 = Vector2.ZERO, radius: Double = 100.0, phase: Double = 0.0): ShapeContour { @@ -93,5 +93,5 @@ fun regularPolygonBeveled(sides: Int, bevelFactor: Double = 0.5, center: Vector2 } close() } - return c.reversed + return c } diff --git a/orx-shapes/src/test/kotlin/TestChamferCorners.kt b/orx-shapes/src/test/kotlin/TestChamferCorners.kt index eecf3a98..c13f48c0 100644 --- a/orx-shapes/src/test/kotlin/TestChamferCorners.kt +++ b/orx-shapes/src/test/kotlin/TestChamferCorners.kt @@ -49,6 +49,7 @@ object TestChamferCorners : Spek({ cc.position(0.5) `should be near` c.position(0.5) cc.position(1.0) `should be near` c.position(1.0) cc.closed `should be equal to` c.closed + c.winding `should be equal to` cc.winding } } @@ -121,6 +122,8 @@ object TestChamferCorners : Spek({ val cc = c.roundCorners(1.0) + c.winding `should be equal to` cc.winding + c.closed `should be equal to` cc.closed val ccc = cc.roundCorners(1.0) @@ -129,14 +132,14 @@ object TestChamferCorners : Spek({ cc.segments.size `should be equal to` 6 - cc.segments.forEach { - println(it) - } +// cc.segments.forEach { +// println(it) +// } - println("---") - ccc.segments.forEach { - println(it) - } +// println("---") +// ccc.segments.forEach { +// println(it) +// } it("should have 6 sides") { ccc.segments.size `should be equal to` cc.segments.size } diff --git a/orx-shapes/src/test/kotlin/TestRegularPolygon.kt b/orx-shapes/src/test/kotlin/TestRegularPolygon.kt new file mode 100644 index 00000000..24ca290f --- /dev/null +++ b/orx-shapes/src/test/kotlin/TestRegularPolygon.kt @@ -0,0 +1,49 @@ +import org.amshove.kluent.`should be equal to` +import org.openrndr.extra.shapes.regularPolygon +import org.openrndr.extra.shapes.regularPolygonBeveled +import org.openrndr.extra.shapes.regularPolygonRounded +import org.openrndr.shape.Winding +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe + +object TestRegularPolygon : Spek({ + + + describe("a regular polygon with 3 sides") { + val rp = regularPolygon(3) + + it("is closed") { + rp.closed `should be equal to` true + } + + it("has clockwise winding") { + rp.winding `should be equal to` Winding.CLOCKWISE + } + } + + describe("a regular polygon with rounded corners and 3 sides") { + val rp = regularPolygonRounded(3) + + it("is closed") { + rp.closed `should be equal to` true + } + + it("has clockwise winding") { + rp.winding `should be equal to` Winding.CLOCKWISE + } + } + + describe("a regular polygon with beveled corners and 3 sides") { + val rp = regularPolygonBeveled(3) + + it("is closed") { + rp.closed `should be equal to` true + } + + it("has clockwise winding") { + rp.winding `should be equal to` Winding.CLOCKWISE + } + } + + +}) \ No newline at end of file diff --git a/orx-shapes/src/test/kotlin/TestRegularStar.kt b/orx-shapes/src/test/kotlin/TestRegularStar.kt new file mode 100644 index 00000000..2a462d98 --- /dev/null +++ b/orx-shapes/src/test/kotlin/TestRegularStar.kt @@ -0,0 +1,47 @@ +import org.amshove.kluent.`should be equal to` +import org.openrndr.extra.shapes.regularPolygonBeveled +import org.openrndr.extra.shapes.regularPolygonRounded +import org.openrndr.extra.shapes.regularStar +import org.openrndr.extra.shapes.regularStarRounded +import org.openrndr.shape.Winding +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe + +object TestRegularStar : Spek({ + describe("a regular star with 5 points") { + val rs = regularStar(5, 10.0, 20.0) + + it("is closed") { + rs.closed `should be equal to` true + } + + it("has clockwise winding") { + rs.winding `should be equal to` Winding.CLOCKWISE + } + } + + describe("a regular star with rounded corners and 5 points") { + val rs = regularStarRounded(5, 10.0, 20.0, 0.2, 0.2) + + it("is closed") { + rs.closed `should be equal to` true + } + + it("has clockwise winding") { + rs.winding `should be equal to` Winding.CLOCKWISE + } + } + + describe("a regular star with beveled corners and 5 points") { + val rs = regularPolygonBeveled(5, 0.5) + + it("is closed") { + rs.closed `should be equal to` true + } + + it("has clockwise winding") { + rs.winding `should be equal to` Winding.CLOCKWISE + } + } + +}) \ No newline at end of file diff --git a/orx-shapes/src/test/kotlin/TestRoundedRectangle.kt b/orx-shapes/src/test/kotlin/TestRoundedRectangle.kt new file mode 100644 index 00000000..4c7c5ab3 --- /dev/null +++ b/orx-shapes/src/test/kotlin/TestRoundedRectangle.kt @@ -0,0 +1,20 @@ +import org.amshove.kluent.`should be equal to` +import org.openrndr.extra.shapes.* +import org.openrndr.shape.Winding +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe + +object TestRoundedRectangle : Spek({ + describe("a rounded square") { + val rs = RoundedRectangle(100.0, 100.0, 200.0, 200.0, 20.0).contour + + it("is closed") { + rs.closed `should be equal to` true + } + + it("has clockwise winding") { + rs.winding `should be equal to` Winding.CLOCKWISE + } + } + +}) \ No newline at end of file