Skip to content

Commit

Permalink
Better patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallisto committed Jul 14, 2024
1 parent ca87034 commit b724582
Show file tree
Hide file tree
Showing 43 changed files with 832 additions and 393 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.scalatest.matchers.*
class TilingCoordsSpec extends AnyFlatSpec with should.Matchers {

"A tiling made of triangles" can "return its coords" in {
tri4x4Reticulate.coords.almostEqualsMap(
p333333_4by4_reticulate.coords.almostEqualsMap(
Map(
1 -> Point(),
2 -> Point(1, 0),
Expand All @@ -40,7 +40,7 @@ class TilingCoordsSpec extends AnyFlatSpec with should.Matchers {
}

"A tiling made of hexagons" can "return its coords" in {
hex4x4Reticulate.coords.almostEqualsMap(
p666_4by4_reticulate.coords.almostEqualsMap(
Map(
1 -> Point(),
2 -> Point(1, 0),
Expand Down Expand Up @@ -96,7 +96,7 @@ class TilingCoordsSpec extends AnyFlatSpec with should.Matchers {
}

it can "be rendered as SVG" in {
prettyPrinter.format(hex4x4Reticulate.toSVG()) shouldBe
prettyPrinter.format(p666_4by4_reticulate.toSVG()) shouldBe
"""<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="-50.0 -25.0 375.0 526.313972" xmlns="http://www.w3.org/2000/svg">
| <g>
| <title>Tiling</title>
Expand Down Expand Up @@ -216,7 +216,7 @@ class TilingCoordsSpec extends AnyFlatSpec with should.Matchers {
}

"A tiling made of squares" can "return its coords" in {
sqr4x4Reticulate.coords.almostEqualsMap(
p4444_4by4_reticulate.coords.almostEqualsMap(
Map(
1 -> Point(),
2 -> Point(1, 0),
Expand Down Expand Up @@ -249,7 +249,7 @@ class TilingCoordsSpec extends AnyFlatSpec with should.Matchers {
}

it can "be rendered as polygons SVG" in {
sqr4x4Reticulate.withPolygons shouldBe
p4444_4by4_reticulate.withPolygons shouldBe
"""<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="-25.0 -225.0 250.0 250.0" xmlns="http://www.w3.org/2000/svg">
| <g>
| <title>Tiling</title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ class TilingGrowthNodeSpec extends AnyFlatSpec with Helper with should.Matchers
}

it can "NOT have a polygon added to a non existing node" in {
Tiling.squareNet(2, 2).unsafe.maybeGrowNode(Node(100), Vertex(Polygon(4)), BEFORE_PERIMETER) shouldBe
Tiling.pattern_4444(2, 2).unsafe.maybeGrowNode(Node(100), Vertex(Polygon(4)), BEFORE_PERIMETER) shouldBe
Left(
"""Tiling can add polygons only to perimeter nodes:
| found unknown node 100.
Expand Down Expand Up @@ -448,7 +448,7 @@ class TilingGrowthNodeSpec extends AnyFlatSpec with Helper with should.Matchers
}

it can "NOT have a polygon added to a non perimeter node" in {
Tiling.squareNet(2, 2).unsafe.maybeGrowNode(Node(5), Vertex(Polygon(4)), BEFORE_PERIMETER) shouldBe
Tiling.pattern_4444(2, 2).unsafe.maybeGrowNode(Node(5), Vertex(Polygon(4)), BEFORE_PERIMETER) shouldBe
Left(
"""Tiling can add polygons only to perimeter nodes:
| found inner node 5.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,21 +208,21 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers
// }

"A sqr4x4Reticulate" can "return the nodes belonging to each different gonality" in {
sqr4x4Reticulate.groupGonals shouldBe
p4444_4by4_reticulate.groupGonals shouldBe
Map(
Vector(4, 4, 4, 4) -> List(14, 9, 13, 17, 12, 7, 18, 8, 19)
).mapKeys(_.map(Node(_)))
}

it can "have its nodes grouped in uniform sets" in {
sqr4x4Reticulate.groupUniforms shouldBe
p4444_4by4_reticulate.groupUniforms shouldBe
Map(
(Vector(4, 4, 4, 4), List()) -> Vector(14, 9, 13, 17, 12, 7, 18, 8, 19)
).mapValues2(_.map(Node(_)))
}

it can "have an uniformity value 1" in {
sqr4x4Reticulate.uniformity shouldBe
p4444_4by4_reticulate.uniformity shouldBe
1
}

Expand Down Expand Up @@ -276,31 +276,31 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers
}

"A triangleTriangleOfSide5" can "have its nodes grouped in uniform sets" in {
triangleTriangleOfSide5.groupUniforms shouldBe
p333333_triangle.groupUniforms shouldBe
Map(
(Vector(3, 3, 3, 3, 3, 3), List()) -> Vector(5, 14, 9, 13, 12, 8)
).mapValues2(_.map(Node(_)))
}

it can "have uniformity value 1" in {
triangleTriangleOfSide5.uniformity shouldBe
p333333_triangle.uniformity shouldBe
1
}

"A hexTrianguloidOfSide4" can "have its nodes grouped in uniform sets" in {
hexTrianguloidOfSide4.groupUniforms shouldBe
p666_triangle.groupUniforms shouldBe
Map(
(Vector(6, 6, 6), List()) -> Vector(14, 13, 22, 12, 16, 23, 15, 28, 21)
).mapValues2(_.map(Node(_)))
}

it can "have uniformity value 1" in {
hexTrianguloidOfSide4.uniformity shouldBe
p666_triangle.uniformity shouldBe
1
}

"A uniform3gonal2" can "have its nodes grouped in uniform sets" in {
uniform3gonal2.groupUniforms shouldBe
"A tiling with pattern [2x(3₆);(3₄.6)]" can "have its nodes grouped in uniform sets" in {
p2x333333_33336.groupUniforms shouldBe
Map(
(Vector(3, 3, 3, 3, 3, 3), List(0)) -> Vector(51, 55, 50, 53, 56, 57, 54),
(Vector(3, 3, 3, 3, 6), List()) -> Vector(14, 33, 13, 35, 15, 24, 37, 34, 17, 22, 27, 26, 23),
Expand All @@ -309,12 +309,12 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers
}

it can "have uniformity value 3" in {
uniform3gonal2.uniformity shouldBe
p2x333333_33336.uniformity shouldBe
3
}

"A 5-uniform 3-Archimedean tiling" can "have its nodes grouped in uniform sets" in {
uniform5gonal3.groupUniforms shouldBe
"A tiling with pattern [2x(3₆);2x(3₄.6);(3.3.6.6)]" can "have its nodes grouped in uniform sets" in {
p2x333333_2x33336_3366.groupUniforms shouldBe
Map(
(Vector(3, 3, 3, 3, 3, 3), List(0)) -> Vector(101, 106, 102, 113, 108, 104),
(Vector(3, 3, 3, 3, 6), List(1)) -> Vector(37, 78, 33, 48, 23, 47, 34, 64),
Expand All @@ -325,7 +325,7 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers
}

it can "have uniformity value 5 and gonality value 3" in {
(uniform5gonal3.gonality, uniform5gonal3.uniformity) shouldBe
(p2x333333_2x33336_3366.gonality, p2x333333_2x33336_3366.uniformity) shouldBe
(3, 5)
}

Expand All @@ -344,7 +344,7 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers
}

"A 7 uniform tiling [(3₆);2x(3₂.6₂);4x(6₃)]" can "have its nodes grouped in uniform sets" in {
uniform7gonal3.groupUniforms shouldBe
p333333_2x3366_4x666.groupUniforms shouldBe
Map(
(Vector(6, 6, 6), List(1)) -> Vector(111, 159, 33, 75, 123, 69, 138, 84, 61, 137, 97, 112, 48, 83, 76, 98, 47, 62),
(Vector(3, 3, 6, 6), List(1)) -> Vector(110, 92, 153, 78, 64, 49, 81, 67, 154, 139, 82, 77, 96, 63, 95),
Expand All @@ -357,7 +357,7 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers
}

it can "have them grouped by vertex" in {
uniform7gonal3.groupUniformsNestedComplete shouldBe
p333333_2x3366_4x666.groupUniformsNestedComplete shouldBe
Map(
Vector(3, 3, 6, 6) -> List(
(List(0), Vector(170, 142, 52, 93, 65, 156, 169, 141, 66, 155, 108, 3, 80, 18, 51, 4, 79, 94)),
Expand All @@ -376,7 +376,7 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers
}

it can "have uniformity value 7 and gonality value 3" in {
(uniform7gonal3.gonality, uniform7gonal3.uniformity) shouldBe
(p333333_2x3366_4x666.gonality, p333333_2x3366_4x666.uniformity) shouldBe
(3, 7)
}

Expand Down Expand Up @@ -547,14 +547,14 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers

"A 3-uniform 2-Archimedean tiling [2x(3₆);(3₄.6)]" can "be described" in {
val t: Tiling =
uniform3gonal2
p2x333333_33336
(t.gonality, t.uniformity) shouldBe
(2, 3)
}

"A 4-uniform 4-Archimedean tiling [(3₆);(3₄.6);(3₂.6₂);(6₃)]" can "be described" in {
val t: Tiling =
uniform4gonal4
p333333_33336_3366_666
(t.gonality, t.uniformity) shouldBe
(4, 4)
}
Expand Down Expand Up @@ -785,7 +785,7 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers
}

"Another smaller tiling [(3.4.6.4)]" can "be examined for outer polygon strips from perimeter node 22" in {
triSqrHexHexoid.outerOrderedStripFromSingle(Node(22)) shouldBe
p3464.outerOrderedStripFromSingle(Node(22)) shouldBe
List(
(List(6), false),
(List(4), false),
Expand All @@ -797,7 +797,7 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers
}

val matrix: Map[Node, List[(List[Int], Boolean)]] =
triSqrHexHexoid.outerOrderedStripFrom(triSqrHexHexoid.graphEdges.nodes.diff(triSqrHexHexoid.perimeter.toRingNodes))
p3464.outerOrderedStripFrom(p3464.graphEdges.nodes.diff(p3464.perimeter.toRingNodes))

it can "be examined for outer polygon strips from all nodes" in {
matrix shouldBe
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.scala_tessella.tessella
package conversion

import Outliers.sqr3x3Growth
import Outliers.p4444_3by3_grown
import SVG.*

import org.scalatest.*
Expand All @@ -12,7 +12,7 @@ class SVGAnimationSpec extends AnyFlatSpec with Helper with should.Matchers {

"A tiling" can "be converted to an animation showing the nodes growth" in {
prettyPrinter.format(
sqr3x3Growth.toSVG(
p4444_3by3_grown.toSVG(
labelledNodes = LabelledNodes.NONE,
showGrowth = true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package conversion

import SVG.*
import SVGExtra.*
import Outliers.hexTrianguloidOfSide4
import Outliers.p666_triangle

import org.scalatest.*
import org.scalatest.flatspec.*
Expand All @@ -13,7 +13,7 @@ class SVGExtraSpec extends AnyFlatSpec with Helper with should.Matchers {

"A tiling" can "be concentric" in {
prettyPrinter.format(
hexTrianguloidOfSide4.toNestedPerimetersSVG()
p666_triangle.toNestedPerimetersSVG()
) shouldBe
"""<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="-50.0 -25.0 375.0 396.410162" xmlns="http://www.w3.org/2000/svg">
| <g style="stroke:purple;stroke-width:5;fill:none">
Expand Down
16 changes: 8 additions & 8 deletions src/main/paradox/regular.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ can be created.
### Fast reticulate method

```scala
Tiling.triangleNet(4, 4)
Tiling.pattern_333333(4, 4)
```
```raw
<div style="width: 420px;">
Expand All @@ -22,7 +22,7 @@ Tiling.triangleNet(4, 4)
```

```scala
Tiling.triangleTriangle(4)
Tiling.pattern_333333_triangle(4)
```
```raw
<div style="width: 420px;">
Expand All @@ -37,7 +37,7 @@ Tiling.triangleTriangle(4)
### Slow growth method

```scala
TilingGrowth.growFullVertex(FullVertex.s("(3₆)"), 60) // same as Tiling.triangularHex(3)
TilingGrowth.growFullVertex(FullVertex.s("(3₆)"), 60) // same as Tiling.pattern_333333(3)
```
```raw
<div style="width: 600px;">
Expand All @@ -54,7 +54,7 @@ TilingGrowth.growFullVertex(FullVertex.s("(3₆)"), 60) // same as Tiling.triang
### Fast reticulate method

```scala
Tiling.squareNet(4, 4)
Tiling.pattern_4444(4, 4)
```
```raw
<div style="width: 440px;">
Expand All @@ -69,7 +69,7 @@ Tiling.squareNet(4, 4)
### Slow growth method

```scala
TilingGrowth.growFullVertex(FullVertex.s("(4₄)"), 9) // same as Tiling.squareNet(3)
TilingGrowth.growFullVertex(FullVertex.s("(4₄)"), 9) // same as Tiling.pattern_4444(3)
```
```raw
<div style="width: 360px;">
Expand All @@ -86,7 +86,7 @@ TilingGrowth.growFullVertex(FullVertex.s("(4₄)"), 9) // same as Tiling.squareN
### Fast reticulate methods

```scala
Tiling.hexagonNet(4, 4)
Tiling.pattern_666(4, 4)
```
```raw
<div style="width: 640px;">
Expand All @@ -99,7 +99,7 @@ Tiling.hexagonNet(4, 4)
```

```scala
Tiling.hexTrianguloid(4)
Tiling.pattern_666_trianguloid(4)
```
```raw
<div style="width: 640px;">
Expand All @@ -114,7 +114,7 @@ Tiling.hexTrianguloid(4)
### Slow growth method

```scala
TilingGrowth.growFullVertex(FullVertex.s("(6₃)"), 19) // same as Tiling.hexagonalHexoid(3)
TilingGrowth.growFullVertex(FullVertex.s("(6₃)"), 19) // same as Tiling.pattern_666(3)
```
```raw
<div style="width: 800px;">
Expand Down
Loading

0 comments on commit b724582

Please sign in to comment.