/// <summary> /// Renders this world to the current context. /// </summary> public void Render(Rectangle Bounds, double Extent) { ZoneIndex bl = _GetZone(Bounds.BottomLeft); ZoneIndex tr = _GetZone(Bounds.TopRight); bl.X -= 1; tr.X += 1; bl.Y -= 1; tr.Y += 1; int zonecount = (tr.X - bl.X) * (tr.Y - bl.Y); Render r; Atlas.Begin(out r); List<Stone> selected = new List<Stone>(); if (zonecount < this._Zones.Count) { for (int x = bl.X; x <= tr.X; x++) for (int y = bl.Y; y <= tr.Y; y++) { List<Stone> zone; if (this._Zones.TryGetValue(new ZoneIndex(x, y), out zone)) this._DrawZone(r, zone, Extent, selected); } } else { foreach (var kvp in this._Zones) { ZoneIndex index = kvp.Key; int x = index.X; int y = index.Y; if (x >= bl.X && x <= tr.X && y >= bl.Y && y <= tr.Y) this._DrawZone(r, kvp.Value, Extent, selected); } } foreach (Stone stone in selected) Atlas.DrawStone(r, stone, Extent); Atlas.End(r); }
/// <summary> /// Applies this transform to a bounding rectangle. /// </summary> public Rectangle Project(Rectangle Source) { Vector tl = this.Project(Source.TopLeft); Vector tr = this.Project(Source.TopRight); Vector bl = this.Project(Source.BottomLeft); Vector br = this.Project(Source.BottomRight); return new Rectangle( Math.Min(tl.X, Math.Min(tr.X, Math.Min(bl.X, br.X))), Math.Max(tl.Y, Math.Max(tr.Y, Math.Max(bl.Y, br.Y))), Math.Max(tl.X, Math.Max(tr.X, Math.Max(bl.X, br.X))), Math.Min(tl.Y, Math.Min(tr.Y, Math.Min(bl.Y, br.Y)))); }