23internal sealed class ObliqueRightCoordinates : ISceneLayerCoordinates
32 public Point GetAnchorPixelAtSceneLayerCoordinates(SceneLayer sceneLayer, PointF layerPoint)
41 float x = -sceneLayer.OriginPx.X
42 + layerPoint.X * faceWidth
43 + layerPoint.Y * skewX;
45 float y = -sceneLayer.OriginPx.Y
59 public PointF GetSceneLayerCoordinatesAtPixel(SceneLayer sceneLayer, PointF pixelPt)
68 float row = (pixelPt.Y + sceneLayer.
OriginPx.Y) / H;
69 float col = (pixelPt.X + sceneLayer.OriginPx.X - row * skewX) / faceWidth;
71 return new PointF(col, row);
81 public List<SceneLayerTile> GetSceneLayerTilesInPixelRange(
82 SceneLayer sceneLayer,
83 Rectangle worldPixelRange,
86 var result =
new List<SceneLayerTile>();
87 var candidateRange = TileBounds.GetTransformedTileCandidateRange(sceneLayer, worldPixelRange, includeOverhang);
89 var upperLeft = GetSceneLayerCoordinatesAtPixel(
91 new PointF(candidateRange.Left, candidateRange.Top));
93 var upperRight = GetSceneLayerCoordinatesAtPixel(
95 new PointF(candidateRange.Right, candidateRange.Top));
97 var lowerLeft = GetSceneLayerCoordinatesAtPixel(
99 new PointF(candidateRange.Left, candidateRange.Bottom));
101 var lowerRight = GetSceneLayerCoordinatesAtPixel(
103 new PointF(candidateRange.Right, candidateRange.Bottom));
105 int minX = (int)Math.Floor(
114 int maxX = (int)Math.Ceiling(
123 int minY = (int)Math.Floor(
132 int maxY = (int)Math.Ceiling(
141 for (
int y = minY; y <= maxY; y++)
143 for (
int x = minX; x <= maxX; x++)
145 var tile = sceneLayer[x, y];
150 var tileRange = GetPixelRangeForTile(tile, includeOverhang);
152 if (tileRange.IntersectsWith(worldPixelRange))
166 public Rectangle GetPixelRangeForTile(Tile tile,
bool includeOverhang)
168 var anchor = GetAnchorPixelAtSceneLayerCoordinates(
170 tile.SceneLayerCoordinates);
175 tile.SceneLayer.TileWidth,
176 tile.SceneLayer.TileHeight);
178 return TileBounds.ApplyTileGeometry(baseRect, tile, includeOverhang);
187 public Rectangle GetPixelRangeForTileList(List<Tile> tileList,
bool includeOverhang)
191 foreach (var tile
in tileList)
193 var tileRange = GetPixelRangeForTile(tile, includeOverhang);
195 result = result.IsEmpty
210 public SceneLayerTile GetAdjacentSceneLayerTile(
211 SceneLayerTile layerPoint,
218 return direction
switch
220 CardinalDirections.N => sceneLayer.ResolveWrappedTile(x, y - 1),
221 CardinalDirections.NE => sceneLayer.ResolveWrappedTile(x + 1, y - 1),
222 CardinalDirections.E => sceneLayer.ResolveWrappedTile(x + 1, y),
223 CardinalDirections.SE => sceneLayer.ResolveWrappedTile(x + 1, y + 1),
224 CardinalDirections.S => sceneLayer.ResolveWrappedTile(x, y + 1),
225 CardinalDirections.SW => sceneLayer.ResolveWrappedTile(x - 1, y + 1),
226 CardinalDirections.W => sceneLayer.ResolveWrappedTile(x - 1, y),
227 CardinalDirections.NW => sceneLayer.ResolveWrappedTile(x - 1, y - 1),
238 public Point[] GetPolygonPts(Tile tile,
bool includeOverhang)
247 var anchor = GetAnchorPixelAtSceneLayerCoordinates(
249 tile.SceneLayerCoordinates);
251 var overhang = includeOverhang
258 anchor.X - overhang.Left,
259 anchor.Y - overhang.Top),
262 anchor.X + faceWidth + overhang.Right,
263 anchor.Y - overhang.Top),
266 anchor.X +
W + overhang.Right,
267 anchor.Y + H + overhang.Bottom),
270 anchor.X + skewX - overhang.Left,
271 anchor.Y + H + overhang.Bottom)
282 public PointF FindEquivalentSceneLayerCoordinates(
287 float modX = valColRow.X % (xUpperBound + 1);
288 float modY = valColRow.Y % (yUpperBound + 1);
291 modX += xUpperBound + 1;
294 modY += yUpperBound + 1;
296 return new PointF(modX, modY);
299 private static void GetGeometry(
300 SceneLayer sceneLayer,
312 faceWidth = width - skewX;
Point GridCoordinatesAbs
Gets the absolute grid coordinates of this tile within its parent scene layer as integer values.
override SceneLayer SceneLayer
Gets the parent scene layer that contains this tile.
Point OriginPx
Gets or sets the world-space pixel origin of this layer's (0,0) tile position.
int TileHeight
Gets or sets the height of each tile in this layer, measured in pixels.
int TileWidth
Gets or sets the width of each tile in this layer, measured in pixels.
CardinalDirections
Represents the eight cardinal and intercardinal directions of the compass.
@ Rectangle
Particles are spawned uniformly within a rectangular area. This is the default distribution.
record struct Spacing([property:JsonProperty("left")] int Left, [property:JsonProperty("top")] int Top, [property:JsonProperty("right")] int Right, [property:JsonProperty("bottom")] int Bottom)
Represents dimensions in pixels when spacing Tilesheets.