Skip to content

Commit

Permalink
#194 More Convertion of EGridFlatGui to projection.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich2 committed Dec 7, 2022
1 parent c227544 commit d732af6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Tiling/src/egrid/EGridFlatGui.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ case class EGridFlatGui(canv: CanvasPlatform, scen: EScenFlat, viewIn: HGView) e
def terrPolys: RArr[PolygonFill] = terrs.projRowsCombinePolygons.map { pt => pt.a1.fill(pt.a2.colour) }
//debvar(terrPolys.length)

def tiles: RArr[PolygonCompound] = gridSys.map{ hc => hc.hVertPolygon.toPolygon(gridSys.flatHCoordToPt2(_)).fillActive(terrs(hc).colour.modAlpha(128), hc) }
//def tiles: RArr[PolygonCompound] = gridSys.map{ hc => hc.hVertPolygon.toPolygon(gridSys.flatHCoordToPt2(_)).fillActive(terrs(hc).colour.modAlpha(128), hc) }
// def sides: GraphicElems = sTerrs.truesMap{hs => Rectangle.fromAxisRatio(hs.lineSegDepr, 0.3).fill(Colour.DarkBlue) }
def sides2: GraphicElems = sTerrs.projTruesMap(proj){hs => Rectangle.fromAxisRatio(proj.lineSeg(hs), 0.3).fill(Colour.DarkBlue) }
def sides2: GraphicElems = sTerrs.projTruesLineSegMap(proj){ls => Rectangle.fromAxisRatio(ls, 0.3).fill(Colour.DarkBlue) }

def tileStrs: RArr[PolygonCompound] = gridSys.map{ hc =>
hc.hVertPolygon.toPolygon(gridSys.flatHCoordToPt2(_)).fillTextActive(terrs(hc).colour.modAlpha(128), hc, hc.rcStr32 --- hc.rcStr, 12, terrs(hc).contrastBW)
Expand Down
17 changes: 15 additions & 2 deletions Tiling/src/prid/phex/HSideLayer.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Copyright 2018-22 Richard Oliver. Licensed under Apache Licence version 2.0. */
package ostrat; package prid; package phex
import geom._

class HSideLayer[A <: AnyRef](val unsafeArr: Array[A])

Expand Down Expand Up @@ -37,8 +38,8 @@ final class HSideBoolLayer(val unsafeArray: Array[Boolean]) extends AnyVal with

def trueHSides(implicit gridSys: HGridSys): HSideArr = truesMap(hs => hs)

def projTruesMap[B, ArrB <: Arr[B]](proj: HSysProjection)(f: HSide => B)(implicit build: ArrMapBuilder[B, ArrB]): ArrB = {
var i = 0
def projTruesMap[B, ArrB <: Arr[B]](proj: HSysProjection)(f: HSide => B)(implicit build: ArrMapBuilder[B, ArrB]): ArrB =
{ var i = 0
val buff = build.newBuff()
proj.gChild.sidesForeach { hs =>
if (unsafeArray(i))
Expand All @@ -48,6 +49,18 @@ final class HSideBoolLayer(val unsafeArray: Array[Boolean]) extends AnyVal with
build.buffToSeqLike(buff)
}

def projTruesLineSegMap[B, ArrB <: Arr[B]](proj: HSysProjection)(f: LineSeg => B)(implicit build: ArrMapBuilder[B, ArrB]): ArrB =
{
var i = 0
val buff = build.newBuff()
proj.gChild.sidesForeach { hs =>
if (unsafeArray(i))
proj.transOptLineSeg(hs.lineSegHC).foreach(ls => build.buffGrow(buff, f(ls)))
i += 1
}
build.buffToSeqLike(buff)
}

def set(hs: HSide, value: Boolean)(implicit grid: HGridSys): Unit = {
val i = grid.sideArrIndex(hs)
if (i >= unsafeArray.length) deb(s"$hs")
Expand Down

0 comments on commit d732af6

Please sign in to comment.