Skip to content

Commit

Permalink
position start triangle better
Browse files Browse the repository at this point in the history
  • Loading branch information
cormullion committed May 12, 2024
1 parent 553d524 commit 4c0ee03
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/tiles-grids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,9 @@ function Base.iterate(eqt::EquilateralTriangleGrid)
cellnumber = (eqt.currentrow - 1) * eqt.nrows + eqt.currentcol
h = (sqrt(3) * eqt.side) / 2
pointup = (isodd(eqt.currentrow) && isodd(eqt.currentcol)) || (iseven(eqt.currentrow) && iseven(eqt.currentcol)) ? eqt.up : !eqt.up
# this triangle
cpt_c = Point(eqt.startpoint.x + (eqt.side / 2 * eqt.currentcol), eqt.startpoint.y + (h * eqt.currentrow))
# the first triangle
cpt_c = Point(eqt.startpoint.x - eqt.side/2 + (eqt.side / 2 * eqt.currentcol),
eqt.startpoint.y -h + (h * eqt.currentrow))
pts_c = _equilateral_triangle(cpt_c, eqt.side, pointup ? :up : :down)
# next one
cpt_n = Point(eqt.startpoint.x + (eqt.side / 2 * eqt.currentcol), eqt.startpoint.y + (h * eqt.currentrow))
Expand All @@ -651,7 +652,8 @@ function Base.iterate(eqt::EquilateralTriangleGrid, state)
end
h = (sqrt(3) * eqt.side) / 2
pointup = (isodd(eqt.currentrow) && isodd(eqt.currentcol)) || (iseven(eqt.currentrow) && iseven(eqt.currentcol)) ? eqt.up : !eqt.up
cpt_c = Point(eqt.startpoint.x + (eqt.side / 2 * eqt.currentcol), eqt.startpoint.y + (h * eqt.currentrow))
cpt_c = Point(eqt.startpoint.x - eqt.side / 2 + (eqt.side / 2 * eqt.currentcol),
eqt.startpoint.y - h + (h * eqt.currentrow))
pts_c = _equilateral_triangle(cpt_c, eqt.side, pointup ? :up : :down)
cpt_n = Point(eqt.startpoint.x + (eqt.side / 2 * eqt.currentcol), eqt.startpoint.y + (h * eqt.currentrow))
pts_n = _equilateral_triangle(cpt_n, eqt.side, pointup ? :down : :up)
Expand Down

0 comments on commit 4c0ee03

Please sign in to comment.