A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Units: Egypt, Iraq, Syria and Lebanon fly their sourced 1948 flags (Refs #756) (#2067)
Eyal Golan5b27271dd213
diff --git a/changelog.d/arab-state-flags.md b/changelog.d/arab-state-flags.mdnew file mode 100644index 000000000..b01a55cce--- /dev/null+++ b/changelog.d/arab-state-flags.md@@ -0,0 +1,6 @@+- The Egyptian, Iraqi, Syrian and Lebanese tokens fly their national flags as their laws gave them in 1948, in place+ of the neutral pennant: Egypt's green with the white crescent and three stars (Law No. 47 of 1923 and its annex),+ Iraq's bands, red trapezoid and two seven-pointed stars (Organic Law 1925, Art. 4), Syria's green, white and black+ with three red stars (Constitution of 1930, Art. 4) and Lebanon's red, white and red with the cedar (Constitution,+ Art. 5 of 1943; the cedar all green, as the owner chose). The Arab Liberation Army keeps+ the pennant.diff --git a/docs/units.md b/docs/units.mdindex dd8327c3a..4c48042ba 100644--- a/docs/units.md+++ b/docs/units.md@@ -569,9 +569,10 @@ figures tall standing at the base's back edge. `UnitPlinth` and `UnitFlags` drawbefore measuring ours. The figures read darker than their base, as T29's (0.5–0.9 of its luma), at those looks and atgameplay03 (`TheFiguresReadDarkerThanTheirBaseAsT29`, #645: the shirts at 0.9 of #559's paint, read beside the chestbrace, which #559's sample point hit).-- **Flag:** by the unit's `side` in `units_1948.yaml`. Israel's is the only sourced flag; the two Arab forces the map- draws fly the neutral pennant (Q-ART-1, owner, 15 October 2026: "a neutral pennant now, replaced by a sourced emblem- when one is found"): a plain grey triangle, in no side's colours and not white (`UnitFlags.BuildPennant`). The cloth is 0.52 of a figure's height tall and 0.72 wide, on a pole 1.5 tall at 0.9 of the base's+- **Flag:** by the unit's `side` in `units_1948.yaml`. Israel, Transjordan, Egypt, Iraq, Syria and Lebanon fly their+ sourced 1948 flags (below); the Arab Liberation Army, the one force the map draws with no sourced flag, flies the+ neutral pennant (Q-ART-1, owner, 15 October 2026: "a neutral pennant now, replaced by a sourced emblem when one is+ found"; never its dagger emblem, #226 ruling 8): a plain grey triangle, in no side's colours and not white (`UnitFlags.BuildPennant`). Every flag's cloth is 0.72 of a figure's height wide, its height its own law's proportion (Israel's 0.52, the others below; the pennant 0.36 at the pole), on a pole 1.5 tall at 0.9 of the base'sradius, behind the trio and east of the badge (`TheFlagIsAboutHalfAFigureTallOnTheBasesEdge`). The cloth is drawnunlit (white, and a blue standing for the proclamation's "dark sky-blue"), so it reads white under the map's light andgrade as T29's. Owner ruling (2026-10-15): the flag turns about its pole to face the camera (`UnitFlagFacing`), so it@@ -593,8 +594,18 @@ figures tall standing at the base's back edge. `UnitPlinth` and `UnitFlags` drawhttps://en.wikipedia.org/wiki/Flag_of_Israel (checked 2026-10-14), which fits the gazette's own drawing. The samedesign hung at the declaration on 14 May 1948 (https://en.wikipedia.org/wiki/Israeli_Declaration_of_Independence,checked 2026-10-14), so it flies from the game's first day. Pinned by `TheIsraeliFlagFollowsTheSpecification`.- - Egypt, Jordan, Syria, Iraq, Lebanon: no sourced flag yet, so a token of theirs flies none- (`TheFlagIsTheSidesAndOnlyASourcedFlagIsDrawn`).+ - Transjordan (#756): the Organic Law of 16 April 1928, Art. 3. Egypt: Law No. 47 of 1923 and its construction+ annex. Iraq: the Organic Law of 1925, Art. 4. Syria: the Constitution of 1930, Art. 4. Lebanon: the Constitution's+ Art. 5 as amended on 7 December 1943 (owner, 31 October 2026: "we need to have the flags of all arab forces like we+ have for the israeli ones"). Each flies its national flag (no source was found for a field war flag of any of them).+ The citations, what each law leaves open and the drawing each open point follows are in `UnitFlags`' class note; the+ research is `.superpowers/coordination/arab-flags-1948-research.md`. Every flag is 0.72 of a figure long with the+ same top; its height is its law's proportion (2:3 for Egypt and Lebanon, 0.48; 1:2 for Transjordan, Iraq and Syria,+ 0.36). Lebanon's cedar is traced from Wikimedia Commons' public-domain `File:Flag_of_Lebanon.svg` and drawn all+ green, the owner's choice where the sources on its 1948 colour conflict (31 October 2026, "All green+ (Recommended)"; `UnitFlags.LebanonCedarColour`). Pinned by+ `EverySourcedFlagHasItsColoursAndItsLawsProportion` and one test per flag; the local forces have no figure, so no+ token and no flag (`TheFlagIsTheSidesAndOnlyASourcedFlagIsDrawn`).- **The showcase trio** (`?units`, `-units`) stands at the land hex nearest its old spot whose base keeps off therailways and roads, and the kits keep a clearing there in such a run, as they do for a unit in a town(`MapScene.ShowcaseClearing`, `UnitShowcase.Clearing`), so no kit building or route crosses its basediff --git a/unity/Assets/Editor/Generated1948Characters.cs b/unity/Assets/Editor/Generated1948Characters.csindex e72cfb8fd..cd8c9261a 100644--- a/unity/Assets/Editor/Generated1948Characters.cs+++ b/unity/Assets/Editor/Generated1948Characters.cs@@ -284,7 +284,8 @@ namespace Statecraft.Game.EditorTools/// <summary>One editor render of a side's token on a date with every requested model arrived, for a before/after pair/// made on two checkouts: -captureSide ala -captureDate 1948-05-20 -captureOut path.jpg. Same camera as- /// <see cref="CaptureCampaign"/> (24 km, yaw 0, the game's pitch).</summary>+ /// <see cref="CaptureCampaign"/> (24 km, yaw 0, the game's pitch); an optional -captureDistance (metres) looks closer,+ /// as for a close-up of a token's flag.</summary>public static void CaptureToken(){string Arg(string name) { var a = Environment.GetCommandLineArgs(); int i = Array.IndexOf(a, name); return i >= 0 && i + 1 < a.Length ? a[i + 1] : throw new ArgumentException(name + " is required"); }@@ -311,9 +312,12 @@ namespace Statecraft.Game.EditorToolsvar row = map.UnitEntries.First(u => u.Side == side && u.Anchors.Count > 0);var spot = layer.Spots[Statecraft.Game.Map.Units.UnitRoster.AnchorAt(row, state.Date)];rig.LookAt = Statecraft.Game.Map.Units.UnitShowcase.Ground(map, new Vector3((float)spot.X, 0, (float)spot.Z));- rig.Distance = 24000f; rig.Yaw = 0; rig.TopInset = 0; rig.Apply();+ int at = Array.IndexOf(Environment.GetCommandLineArgs(), "-captureDistance");+ rig.Distance = at >= 0 ? float.Parse(Arg("-captureDistance"), System.Globalization.CultureInfo.InvariantCulture) : 24000f;+ rig.Yaw = 0; rig.TopInset = 0; rig.Apply();foreach (var animator in layer.GetComponentsInChildren<Animator>(true)) { animator.cullingMode = AnimatorCullingMode.AlwaysAnimate; animator.Update(0f); }layer.FaceCamera(camera);+ Statecraft.Game.Map.Units.UnitFlagFacing.FaceAll(camera.transform.position); // as a still render must (UnitFlagFacing)RenderMap(camera, output);File.WriteAllText(output + ".txt", $"{side} on {date:yyyy-MM-dd}: row={row.Id}; lookAt={rig.LookAt}; distance={rig.Distance}; pitch={Statecraft.Game.Map.CameraRig.Pitch}; fov={camera.fieldOfView}; legacy roster, rung 5, mobilization 0.8; every requested model answered\n");}diff --git a/unity/Assets/Scripts/Map/Units/UnitFlags.cs b/unity/Assets/Scripts/Map/Units/UnitFlags.csindex d763b148f..f26924a1d 100644--- a/unity/Assets/Scripts/Map/Units/UnitFlags.cs+++ b/unity/Assets/Scripts/Map/Units/UnitFlags.cs@@ -34,12 +34,55 @@ namespace Statecraft.Game.Map.Units/// 15 May 1948 rests on one search snippet [S], and a later, longer triangle is reported [C]. The law names the colours/// only: their values (<see cref="BlackColour"/>, <see cref="GreenColour"/>, <see cref="RedColour"/>) are a choice, as/// are the star's point up (the law fixes the axis, not which end) and the depth of its points.- /// - Egypt, Syria, Iraq, Lebanon: no figure on the map yet, so no flag drawn (#756 follows the same code once they have- /// one). A side the map draws without a sourced flag (the Arab Liberation Army, issue #665) flies a neutral pennant- /// instead (<see cref="BuildPennant"/>):+ /// - Egypt (owner, 31 October 2026: "we need to have the flags of all arab forces like we have for the israeli ones"; the+ /// sources for the four flags below are .superpowers/coordination/arab-flags-1948-research.md, read 2026-10-31): Law+ /// No. 47 of 1923 on the national flag, al-Waqa'i' al-Misriyya No. 118, 13 December 1923, pp. 1-2 (scan at+ /// https://manshurat.org/node/73466): green, a white crescent and three white five-pointed stars, and its annex's+ /// construction: the hoist two thirds of the length; the stars' centres on an equilateral triangle whose side is a+ /// seventh of the length; the side nearest the staff parallel to it, two thirds of the hoist from it; each star an eighth+ /// of the hoist across; the crescent's centre on that side's line; its outer radius a quarter of the hoist; its breadth+ /// at the middle three quarters of a star's diameter (<see cref="BuildEgypt"/>, in the Flaggenbuch 1939's units, 672 by+ /// 1008, which match the annex: https://www.crwflags.com/fotw/flags/eg-kingd.html). The law leaves open, and the+ /// drawing here takes from Wikimedia Commons' File:Flag_of_Egypt_(1922-1958).svg (2012 revision): the crescent's centre+ /// at mid-hoist, its inner circle (centre 485 from the staff, radius 142: the breadth 63 the annex asks), its horns+ /// towards the fly with the stars between them, and the stars' points (one up, one down, one towards the fly). The+ /// annex's model drawing is not in the scan. The green is "Hooker No. 1", a named pigment with no value:+ /// <see cref="GreenColour"/> is a choice. Law 47, Art. 2 lets the War Minister fix a separate army flag; that decision+ /// was not found, so the tokens fly the national flag, the one design with a primary text.+ /// - Iraq: the Organic Law of 21 March 1925 (as amended 29 July 1925), Art. 4, British and Foreign State Papers vol.+ /// CXXIII (https://constitution.org/1-Constitution/cons/iraq/iraqiconst19250321.html): the length twice the width;+ /// three equal bands, black, white and green from the top; at the staff a red trapezoid whose greater base is the+ /// flag's width, its lesser base the white band's and its height a quarter of the length; on it two white+ /// seven-pointed stars, one above the other, parallel to the staff (<see cref="BuildIraq"/>). The law fixes no star size+ /// or centre: they follow the construction on https://www.fotw.info/flags/iq_kingd.html (Heimer, estimated from an+ /// image): each inside a circle a ninth of the length across, centred midway along the perpendiculars from the+ /// trapezoid's inner corners to the staff. One point up and the regular {7/2} depth, as Transjordan's, are a choice.+ /// - Syria: the Constitution of 14 May 1930 (High Commissioner's Decree No. 3111), Art. 4, League of Nations Official+ /// Journal vol. 11 (1930) p. 1113, read as transcribed on Wikimedia Commons' File:Flag_of_Syria_(1930-1958,_1961-1963).svg+ /// (the League's own PDF was not opened): the length twice the height; three equal bands, green, white and black from+ /// the top; three red stars in line on the white (<see cref="BuildSyria"/>). In force in 1948 (restored 1943, revised+ /// 20 March 1948). The law fixes no star size, spacing or orientation, and FOTW reports both orientations: they follow+ /// that Commons drawing (after FOTW): five-pointed, regular, a quarter of the length apart, the middle one at the+ /// centre, each in a circle 0.24 of the height across, one point up (up, as National Geographic 1934 shows them).+ /// - Lebanon: the Constitution of 23 May 1926, Art. 5 as amended by the Constitutional Law of 7 December 1943 (Arabic+ /// text, https://ar.wikisource.org/wiki/دستور_لبنان; English, https://www.wipo.int/wipolex/en/text/565753): red, white,+ /// red, horizontal, the white as broad as both reds together; in the middle of the white a green cedar touching both+ /// reds, and "one third" in size (<see cref="BuildLebanon"/>). Which measure that third applies to is not settled by the+ /// texts, so the cedar's size, a third of the flag's length wide, follows the drawings: a deliberate choice. The 2:3 cloth is practice, not law (Britannica, FOTW). The law gives no outline: the+ /// cedar is traced from Wikimedia Commons' File:Flag_of_Lebanon.svg (public domain; revision of 21 August 2026; itself+ /// traced from the CIA World Factbook), its row-by-row outline simplified to 24 levels, the gaps in its foliage left out.+ /// The cedar's colour in 1948 is in conflict (the 1943 Arabic text and FOTW say green; English Wikipedia says the+ /// article named no colour before 1990 and depictions had a brown trunk): the owner chose all green on 31 October 2026+ /// ("All green (Recommended)"; <see cref="LebanonCedarColour"/>).+ /// - Where a 1948 army flew a separate war flag in the field, no source was found for any of the four, so each flies its+ /// national flag. A side the map draws without a sourced flag (the Arab Liberation Army, issue #665) flies a neutral+ /// pennant instead (<see cref="BuildPennant"/>):/// Q-ART-1, decided by the owner on 15 October 2026 ("2+3"): "a neutral pennant now, replaced by a sourced emblem when/// one is found" (docs/superpowers/plans/2026-10-15-gdd-phase-5.md, PR 17). Never the ALA's dagger emblem (#226,/// ruling 8).+ /// Every flag is <see cref="FlagWidth"/> long on the token, its top at <see cref="FlagTop"/>; its height follows its own+ /// law's proportion, so the 2:3 flags (Egypt, Lebanon) are 0.48 of a figure tall, the 1:2 flags (Transjordan, Iraq,+ /// Syria) 0.36 and Israel's 8:11 0.52./// Proportions on the token follow T29: the cloth about half a figure's height, the pole about one and a half.</summary>public static class UnitFlags{@@ -54,13 +97,17 @@ namespace Statecraft.Game.Map.Unitspublic const float StarOuterCm = 34.5f;const float StripeCm = 5.5f, Layer = 0.02f; // the blue a fiftieth of a figure off the white: enough depth for WebGL at 60 km- /// <summary>The Arab Legion's side (<see cref="UnitFigures.BySide"/>).</summary>- public const string Jordan = "jordan";+ /// <summary>The Arab Legion's side, and the other Arab states' (<see cref="UnitFigures.BySide"/>).</summary>+ public const string Jordan = "jordan", Egypt = "egypt", Iraq = "iraq", Syria = "syria", Lebanon = "lebanon";- static readonly HashSet<string> Sourced = new HashSet<string> { UnitData.Israel, Jordan };+ static readonly HashSet<string> Sourced = new HashSet<string> { UnitData.Israel, Jordan, Egypt, Iraq, Syria, Lebanon };public static bool Has(string? side) => side != null && Sourced.Contains(side);+ /// <summary>Test seam (internal; the tests see it through InternalsVisibleTo): the sides with a sourced flag, so a test+ /// can check each has its own builder and colours without keeping a second list.</summary>+ internal static IReadOnlyCollection<string> SourcedSides => Sourced;+/// <summary>True when <paramref name="side"/>'s tokens fly the neutral pennant: a side the map draws with no sourced flag.</summary>public static bool HasPennant(string? side) => side != null && !Has(side) && UnitFigures.SideFigure(side) != null;@@ -73,9 +120,7 @@ namespace Statecraft.Game.Map.Units/// <summary>The pole and the neutral pennant, one submesh in the units' palette.</summary>public static Mesh BuildPennant(){- var m = new MiniatureMesh();- m.Rod(Vector3.zero, new Vector3(0, PoleHeight, 0), PoleRadius, PoleRadius * 0.8f, P.RifleWood, segments: 8, shade: 0.7f);- m.Ellipsoid(Matrix4x4.TRS(new Vector3(0, PoleHeight + 0.02f, 0), Quaternion.identity, Vector3.one * 0.035f), P.RifleWood, 8, 4, shade: 0.9f);+ var m = Pole();var cloth = new List<Vector2> { new Vector2(FlagLeft, FlagTop - PennantHeight), new Vector2(FlagLeft + FlagWidth, FlagTop - PennantHeight / 2f), new Vector2(FlagLeft, FlagTop) };m.Plate(Plane(0f), cloth, P.HullGrey, shade: 0.9f);return m.Build(PennantMeshName);@@ -87,10 +132,17 @@ namespace Statecraft.Game.Map.Unitspublic static Mesh? Build(string? side){if (!Has(side)) return null;- if (side == Jordan) return BuildTransjordan();- var m = new MiniatureMesh();- m.Rod(Vector3.zero, new Vector3(0, PoleHeight, 0), PoleRadius, PoleRadius * 0.8f, P.RifleWood, segments: 8, shade: 0.7f);- m.Ellipsoid(Matrix4x4.TRS(new Vector3(0, PoleHeight + 0.02f, 0), Quaternion.identity, Vector3.one * 0.035f), P.RifleWood, 8, 4, shade: 0.9f);+ switch (side)+ {+ case Jordan: return BuildTransjordan();+ case Egypt: return BuildEgypt();+ case Iraq: return BuildIraq();+ case Syria: return BuildSyria();+ case Lebanon: return BuildLebanon();+ case UnitData.Israel: break;+ default: throw new InvalidOperationException($"UnitFlags: '{side}' is sourced but has no builder"); // never Israel's flag on another side+ }+ var m = Pole();Vector2 F(float xCm, float yCm) => new Vector2(FlagLeft + xCm * FlagWidth / 220f, FlagBottom + yCm * FlagWidth / 220f);m.Plate(Plane(0f), new List<Vector2> { F(0, 0), F(220, 0), F(220, 160), F(0, 160) }, P.RoundelWhite, shade: 0.9f);foreach (float z in new[] { Layer, -Layer }) // the blue on both faces, a hair off the white@@ -109,16 +161,18 @@ namespace Statecraft.Game.Map.Unitsreturn Split(m.Build(MeshName(side!)), IsraelSlots);}- static readonly int[] IsraelSlots = { P.RoundelWhite, P.RoundelBlue }, TransjordanSlots = { P.PropBlack, P.CamoGreen, P.MarkingRed, P.RoundelWhite };+ /// <summary>Each flag's palette slots, one per cloth colour in <see cref="Colours"/>'s order: a slot only tags a plate's+ /// submesh (<see cref="Split"/>); the cloth's colour is the unlit material's.</summary>+ static readonly int[] IsraelSlots = { P.RoundelWhite, P.RoundelBlue }, TransjordanSlots = { P.PropBlack, P.CamoGreen, P.MarkingRed, P.RoundelWhite },+ EgyptSlots = { P.CamoGreen, P.RoundelWhite }, SyriaSlots = { P.CamoGreen, P.RoundelWhite, P.PropBlack, P.MarkingRed },+ LebanonSlots = { P.MarkingRed, P.RoundelWhite, P.CamoGreen };/// <summary>Transjordan's flag (the class note), in the law's units: the length 2 along +x from the pole, the width 1,/// the cloth's top at <see cref="FlagTop"/>. The bands are cut around the triangle (0,0), (0,1), (1/2,1/2), so the cloth/// is one layer; only the star lies on the red, a hair off it on both faces.</summary>static Mesh BuildTransjordan(){- var m = new MiniatureMesh();- m.Rod(Vector3.zero, new Vector3(0, PoleHeight, 0), PoleRadius, PoleRadius * 0.8f, P.RifleWood, segments: 8, shade: 0.7f);- m.Ellipsoid(Matrix4x4.TRS(new Vector3(0, PoleHeight + 0.02f, 0), Quaternion.identity, Vector3.one * 0.035f), P.RifleWood, 8, 4, shade: 0.9f);+ var m = Pole();float s = FlagWidth / 2f;Vector2 F(float x, float y) => new Vector2(FlagLeft + x * s, FlagTop - s + y * s);const float third = 1f / 3f, twoThirds = 2f / 3f;@@ -131,32 +185,177 @@ namespace Statecraft.Game.Map.Units// The star at the incentre of the triangle (sides 1, sqrt 1/2, sqrt 1/2): (1/(2+2 sqrt 2), 1/2), its inradius from// the hoist; its points on a circle of radius 1/24 (a diameter of a twenty-fourth of the length 2), one point up.// The inner corners at the regular {7/2} star's depth: the law gives none.- float cx = 1f / (2f + 2f * Mathf.Sqrt(2f)), outer = 1f / 24f, inner = outer * Mathf.Cos(2f * Mathf.PI / 7f) / Mathf.Cos(Mathf.PI / 7f);- var star = new List<Vector2> { F(cx, 0.5f) }; // a fan from the centre- for (int i = 0; i <= 14; i++)- {- float a = Mathf.PI / 2f + i * Mathf.PI / 7f, r = i % 2 == 0 ? outer : inner;- star.Add(F(cx + r * Mathf.Cos(a), 0.5f + r * Mathf.Sin(a)));- }+ float cx = 1f / (2f + 2f * Mathf.Sqrt(2f));+ var star = Star(F, cx, 0.5f, 7, 1f / 24f, 90f);foreach (float z in new[] { Layer, -Layer }) m.Plate(Plane(z), star, P.RoundelWhite, shade: 0.9f);return Split(m.Build(MeshName(Jordan)), TransjordanSlots);}+ /// <summary>Iraq's flag (the class note), in the law's units: the length 2 along +x from the pole, the width 1, the+ /// cloth's top at <see cref="FlagTop"/>. Transjordan's cut with the trapezoid (0,0), (0,1), (1/2,2/3), (1/2,1/3) for its+ /// triangle; the two stars at (1/4, 1/3) and (1/4, 2/3), each a ninth of the length across, a hair off the red.</summary>+ static Mesh BuildIraq()+ {+ var m = Pole();+ float s = FlagWidth / 2f;+ Vector2 F(float x, float y) => new Vector2(FlagLeft + x * s, FlagTop - s + y * s);+ const float third = 1f / 3f, twoThirds = 2f / 3f;+ var at = Plane(0f);+ m.Plate(at, new List<Vector2> { F(0, 1), F(2, 1), F(2, twoThirds), F(0.5f, twoThirds) }, P.PropBlack, shade: 0.9f);+ m.Plate(at, new List<Vector2> { F(0.5f, twoThirds), F(2, twoThirds), F(2, third), F(0.5f, third) }, P.RoundelWhite, shade: 0.9f);+ m.Plate(at, new List<Vector2> { F(0, 0), F(0.5f, third), F(2, third), F(2, 0) }, P.CamoGreen, shade: 0.9f);+ m.Plate(at, new List<Vector2> { F(0, 0), F(0, 1), F(0.5f, twoThirds), F(0.5f, third) }, P.MarkingRed, shade: 0.9f);+ foreach (float y in new[] { third, twoThirds })+ {+ var star = Star(F, 0.25f, y, 7, 1f / 9f, 90f);+ foreach (float z in new[] { Layer, -Layer }) m.Plate(Plane(z), star, P.RoundelWhite, shade: 0.9f);+ }+ return Split(m.Build(MeshName(Iraq)), TransjordanSlots);+ }++ /// <summary>Syria's flag (the class note), in the law's units: the length 2, the height 1. Three equal bands; three red+ /// stars on the white, centred at a quarter, a half and three quarters of the length, each in a circle 0.24 across, one+ /// point up, a hair off the white.</summary>+ static Mesh BuildSyria()+ {+ var m = Pole();+ float s = FlagWidth / 2f;+ Vector2 F(float x, float y) => new Vector2(FlagLeft + x * s, FlagTop - s + y * s);+ const float third = 1f / 3f, twoThirds = 2f / 3f;+ var at = Plane(0f);+ m.Plate(at, new List<Vector2> { F(0, 1), F(2, 1), F(2, twoThirds), F(0, twoThirds) }, P.CamoGreen, shade: 0.9f);+ m.Plate(at, new List<Vector2> { F(0, twoThirds), F(2, twoThirds), F(2, third), F(0, third) }, P.RoundelWhite, shade: 0.9f);+ m.Plate(at, new List<Vector2> { F(0, third), F(2, third), F(2, 0), F(0, 0) }, P.PropBlack, shade: 0.9f);+ foreach (float x in new[] { 0.5f, 1f, 1.5f })+ {+ var star = Star(F, x, 0.5f, 5, 0.12f, 90f);+ foreach (float z in new[] { Layer, -Layer }) m.Plate(Plane(z), star, P.MarkingRed, shade: 0.9f);+ }+ return Split(m.Build(MeshName(Syria)), SyriaSlots);+ }++ /// <summary>Egypt's flag (the class note), in the Flaggenbuch's units that match the 1923 annex: 1008 long, 672 high.+ /// The crescent is the outer disc (centre (448, 336), radius 168) less the inner one (<see cref="EgyptInnerCentre"/>,+ /// <see cref="EgyptInnerRadius"/>), drawn as quads between the two arcs; the stars on a triangle of side 144 whose+ /// side nearest the staff stands at x = 448, each 84 across. Crescent and stars lie a hair off the green.</summary>+ static Mesh BuildEgypt()+ {+ var m = Pole();+ float s = FlagWidth / 1008f;+ Vector2 F(float x, float y) => new Vector2(FlagLeft + x * s, FlagTop - 672f * s + y * s);+ m.Plate(Plane(0f), new List<Vector2> { F(0, 0), F(1008, 0), F(1008, 672), F(0, 672) }, P.CamoGreen, shade: 0.9f);+ const float cx = 448f, cy = 336f, outerR = 168f, side = 1008f / 7f, starR = 42f;+ // The horns: where the circles meet, at a from the outer centre along the axis, h off it.+ float d = EgyptInnerCentre - cx, a = (d * d + outerR * outerR - EgyptInnerRadius * EgyptInnerRadius) / (2f * d);+ float h = Mathf.Sqrt(outerR * outerR - a * a), tipOuter = Mathf.Atan2(h, a), tipInner = Mathf.Atan2(h, a - d);+ const int arc = 24;+ Vector2 Outer(int k) { float t = tipOuter + k * (2f * Mathf.PI - 2f * tipOuter) / arc; return F(cx + outerR * Mathf.Cos(t), cy + outerR * Mathf.Sin(t)); }+ Vector2 Inner(int k) { float t = tipInner + k * (2f * Mathf.PI - 2f * tipInner) / arc; return F(EgyptInnerCentre + EgyptInnerRadius * Mathf.Cos(t), cy + EgyptInnerRadius * Mathf.Sin(t)); }+ var stars = new[]+ {+ Star(F, cx, cy + side / 2f, 5, starR, 90f), Star(F, cx, cy - side / 2f, 5, starR, 270f),+ Star(F, cx + side * Mathf.Sqrt(3f) / 2f, cy, 5, starR, 0f),+ };+ foreach (float z in new[] { Layer, -Layer })+ {+ var at = Plane(z);+ for (int k = 0; k < arc; k++) m.Plate(at, new List<Vector2> { Outer(k), Outer(k + 1), Inner(k + 1), Inner(k) }, P.RoundelWhite, shade: 0.9f);+ foreach (var star in stars) m.Plate(at, star, P.RoundelWhite, shade: 0.9f);+ }+ return Split(m.Build(MeshName(Egypt)), EgyptSlots);+ }++ /// <summary>The crescent's inner circle in <see cref="BuildEgypt"/>'s units: not fixed by the 1923 annex (only the+ /// breadth at the middle, 63, is), so taken from the Commons drawing (the class note): 280 + 63 = 485 - 142.</summary>+ public const float EgyptInnerCentre = 485f, EgyptInnerRadius = 142f;++ /// <summary>Lebanon's cedar, traced (the class note) in the flag's units (the length 3 along +x from the pole, the white+ /// band from y = 0 to 1): each row its height and its left and right edge. Consecutive rows bound a convex strip, so the+ /// cedar is drawn as a stack of strips; its width spans x = 1 to 2, a third of the length.</summary>+ public static readonly (float y, float left, float right)[] CedarRows =+ {+ (1.000f, 1.485f, 1.488f), (0.811f, 1.324f, 1.743f), (0.738f, 1.289f, 1.786f), (0.735f, 1.286f, 1.653f),+ (0.632f, 1.154f, 1.790f), (0.586f, 1.257f, 1.867f), (0.574f, 1.249f, 1.881f), (0.558f, 1.236f, 1.768f),+ (0.507f, 1.149f, 1.917f), (0.474f, 1.114f, 1.764f), (0.439f, 1.075f, 1.856f), (0.415f, 1.206f, 1.878f),+ (0.346f, 1.103f, 1.962f), (0.338f, 1.092f, 1.940f), (0.335f, 1.089f, 1.812f), (0.283f, 1.000f, 1.890f),+ (0.261f, 1.031f, 1.931f), (0.260f, 1.182f, 1.933f), (0.199f, 1.068f, 2.000f), (0.194f, 1.081f, 2.000f),+ (0.193f, 1.374f, 2.000f), (0.182f, 1.371f, 1.990f), (0.181f, 1.371f, 1.603f), (0.000f, 1.182f, 1.732f),+ };++ /// <summary>Lebanon's flag (the class note): the length 3, the width 2 (2:3, practice); red bands half a unit broad at+ /// the top and the bottom, the white between them; the cedar (<see cref="CedarRows"/>) on the white, a hair off it.</summary>+ static Mesh BuildLebanon()+ {+ var m = Pole();+ float s = FlagWidth / 3f;+ Vector2 F(float x, float y) => new Vector2(FlagLeft + x * s, FlagTop - 2f * s + y * s);+ var at = Plane(0f);+ m.Plate(at, new List<Vector2> { F(0, 2), F(3, 2), F(3, 1.5f), F(0, 1.5f) }, P.MarkingRed, shade: 0.9f);+ m.Plate(at, new List<Vector2> { F(0, 0.5f), F(3, 0.5f), F(3, 0), F(0, 0) }, P.MarkingRed, shade: 0.9f);+ m.Plate(at, new List<Vector2> { F(0, 1.5f), F(3, 1.5f), F(3, 0.5f), F(0, 0.5f) }, P.RoundelWhite, shade: 0.9f);+ foreach (float z in new[] { Layer, -Layer })+ for (int i = 0; i + 1 < CedarRows.Length; i++)+ {+ var (y0, l0, r0) = CedarRows[i]; var (y1, l1, r1) = CedarRows[i + 1];+ m.Plate(Plane(z), new List<Vector2> { F(l0, 0.5f + y0), F(r0, 0.5f + y0), F(r1, 0.5f + y1), F(l1, 0.5f + y1) }, P.CamoGreen, shade: 0.9f);+ }+ return Split(m.Build(MeshName(Lebanon)), LebanonSlots);+ }++ /// <summary>A flag's pole and its finial, in the palette's wood.</summary>+ static MiniatureMesh Pole()+ {+ var m = new MiniatureMesh();+ m.Rod(Vector3.zero, new Vector3(0, PoleHeight, 0), PoleRadius, PoleRadius * 0.8f, P.RifleWood, segments: 8, shade: 0.7f);+ m.Ellipsoid(Matrix4x4.TRS(new Vector3(0, PoleHeight + 0.02f, 0), Quaternion.identity, Vector3.one * 0.035f), P.RifleWood, 8, 4, shade: 0.9f);+ return m;+ }++ /// <summary>A regular {n/2} star as a fan from its centre (<paramref name="cx"/>, <paramref name="cy"/>) in a flag's own+ /// units (<paramref name="F"/> maps them to the mesh): <paramref name="points"/> points on a circle of radius+ /// <paramref name="outer"/>, one at <paramref name="pointDeg"/> degrees (90 is up); the inner corners at the regular+ /// star's depth, outer x cos(2 pi / n) / cos(pi / n).</summary>+ static List<Vector2> Star(Func<float, float, Vector2> F, float cx, float cy, int points, float outer, float pointDeg)+ {+ float inner = outer * Mathf.Cos(2f * Mathf.PI / points) / Mathf.Cos(Mathf.PI / points);+ var star = new List<Vector2> { F(cx, cy) };+ for (int i = 0; i <= 2 * points; i++)+ {+ float a = pointDeg * Mathf.Deg2Rad + i * Mathf.PI / points, r = i % 2 == 0 ? outer : inner;+ star.Add(F(cx + r * Mathf.Cos(a), cy + r * Mathf.Sin(a)));+ }+ return star;+ }+/// <summary>The cloth's colours, drawn unlit (the selection ring's shader) so the flag reads white and blue under/// the map's light and grade, as T29's (its white 0.83-0.91 luma). The blue stands for the proclamation's "dark/// sky-blue", which gives no value: a choice.</summary>public static readonly Color WhiteColour = new Color(1f, 1f, 1f), BlueColour = new Color(0.0f, 0.22f, 0.62f);/// <summary>Transjordan's black, green and red: the 1928 law names the colours, not their values, so these are a choice- /// (plain, saturated cloth colours that read unlit).</summary>+ /// (plain, saturated cloth colours that read unlit).+ /// Egypt's, Iraq's, Syria's and Lebanon's laws name their colours with no value either (Egypt's green a pigment, "Hooker+ /// No. 1"), so their cloth shares these.</summary>public static readonly Color BlackColour = new Color(0.05f, 0.05f, 0.05f), GreenColour = new Color(0.0f, 0.45f, 0.22f), RedColour = new Color(0.78f, 0.08f, 0.10f);+ /// <summary>The colour of Lebanon's whole cedar: all green, the owner's choice (31 October 2026, "All green+ /// (Recommended)") where the sources conflict (the 1943 Arabic text and FOTW say green; English Wikipedia says no colour+ /// was fixed before 1990 and depictions had a brown trunk; the class note).</summary>+ public static readonly Color LebanonCedarColour = GreenColour;+/// <summary>The cloth's colours of <paramref name="side"/>'s flag, one per submesh after the pole's, in drawing order/// (a later colour lies over an earlier one).</summary>- public static IReadOnlyList<Color> Colours(string side) =>- side == Jordan ? new[] { BlackColour, GreenColour, RedColour, WhiteColour } : new[] { WhiteColour, BlueColour };+ public static IReadOnlyList<Color> Colours(string side) => side switch+ {+ Jordan or Iraq => new[] { BlackColour, GreenColour, RedColour, WhiteColour },+ Egypt => new[] { GreenColour, WhiteColour },+ Syria => new[] { GreenColour, WhiteColour, BlackColour, RedColour },+ Lebanon => new[] { RedColour, WhiteColour, LebanonCedarColour },+ UnitData.Israel => new[] { WhiteColour, BlueColour },+ _ => throw new ArgumentException($"UnitFlags: '{side}' has no sourced flag, so no cloth colours", nameof(side)),+ };/// <summary>The unlit cloth materials for <paramref name="side"/>'s flag, one per <see cref="Colours"/>, each drawn after- /// the one before (the blue over the white, the star over the red).</summary>+ /// the one before (the blue over the white, a star over its field).</summary>public static Material[] ClothMaterials(string side, Material ringTemplate, Func<Material, Material> own){var colours = Colours(side); var mats = new Material[colours.Count];diff --git a/unity/Assets/Tests/EditMode/UnitPlinthTests.cs b/unity/Assets/Tests/EditMode/UnitPlinthTests.csindex 97b229a42..46ece1b89 100644--- a/unity/Assets/Tests/EditMode/UnitPlinthTests.cs+++ b/unity/Assets/Tests/EditMode/UnitPlinthTests.cs@@ -180,25 +180,28 @@ public class UnitPlinthTests// ---- The flag matches the side --------------------------------------------------------------------------------/// <summary>Every row of the unit file names its side, and every formation the map draws is Israel's or a force with a- /// Collection figure (the other Arab forces' rows are data only; owner, 17 October 2026, #740; issue #665); only Israel- /// and the Arab Legion have a flag (built from the 1948 texts), so no flag is invented: a drawn force with none flies the neutral- /// pennant (Q-ART-1, owner, 15 October 2026), in neither side's colours and not white, and no other side flies anything.</summary>+ /// Collection figure (owner, 17 October 2026, #740; issue #665); Israel, Transjordan, Egypt, Iraq, Syria and Lebanon have a+ /// flag (built from their 1948 texts; owner, 31 October 2026: "we need to have the flags of all arab forces like we have+ /// for the israeli ones"), so no flag is invented: a drawn force with none, the ALA's alone, flies the neutral pennant+ /// (Q-ART-1, owner, 15 October 2026), in neither side's colours and not white, and no other side flies anything.</summary>[Test]public void TheFlagIsTheSidesAndOnlyASourcedFlagIsDrawn(){var units = UnitData.Parse(CommittedYaml);Assert.IsTrue(units.Where(UnitRoster.OnMap).All(u => u.Side == UnitData.Israel || UnitFigures.SideFigure(u.Side) != null),"every formation the map draws is Israel's or has its own figure");- Assert.IsTrue(UnitFlags.Has(UnitData.Israel));- Assert.IsFalse(UnitFlags.HasPennant(UnitData.Israel));- Assert.IsTrue(UnitFlags.Has(UnitFlags.Jordan), "the Arab Legion's sourced 1948 flag (owner, 22 October 2026, #756)");- Assert.IsFalse(UnitFlags.HasPennant(UnitFlags.Jordan));- foreach (var side in UnitData.Sides.Where(s => s != UnitData.Israel && s != UnitFlags.Jordan))+ foreach (var side in Flagged)+ {+ Assert.IsTrue(UnitFlags.Has(side), $"{side}: its sourced 1948 flag");+ Assert.IsFalse(UnitFlags.HasPennant(side), $"{side}: a flag, not the pennant");+ }+ foreach (var side in UnitData.Sides.Except(Flagged)){Assert.IsFalse(UnitFlags.Has(side), $"{side}: no sourced, licensed flag in the repo, so none");Assert.IsNull(UnitFlags.Build(side), side);Assert.AreEqual(UnitFigures.SideFigure(side) != null, UnitFlags.HasPennant(side), $"{side}: the pennant only on a drawn force");}+ CollectionAssert.AreEquivalent(new[] { "ala" }, UnitData.Sides.Where(UnitFlags.HasPennant), "only the ALA flies the pennant (never its dagger emblem: #226, ruling 8)");var pennant = UnitFlags.BuildPennant();var slots = pennant.uv.Select(u => Enumerable.Range(0, UnitPalette.Count).Single(s => Mathf.Abs(u.x - UnitPalette.U(s)) < 1e-4f)).Distinct();CollectionAssert.AreEquivalent(new[] { UnitPalette.RifleWood, UnitPalette.HullGrey }, slots, "a wooden pole and a plain grey cloth");@@ -327,6 +330,236 @@ public class UnitPlinthTestsUnityEngine.Object.DestroyImmediate(m);}+ /// <summary>The sides with a sourced flag.</summary>+ static readonly string[] Flagged = { UnitData.Israel, UnitFlags.Jordan, UnitFlags.Egypt, UnitFlags.Iraq, UnitFlags.Syria, UnitFlags.Lebanon };++ /// <summary>The flag sides' keys are the data's own: each Arab flag side is a side the unit file names (<see cref="UnitData.Sides"/>+ /// and a row of the committed units_1948.yaml) and has a figure the map draws (<see cref="UnitFigures.SideFigure"/>), so a+ /// misspelled key fails here. And every side in the class's own sourced set has its own builder and colours: one missing+ /// from <see cref="UnitFlags.Build"/>'s or <see cref="UnitFlags.Colours"/>'s switch throws rather than drawing Israel's flag.</summary>+ [Test]+ public void EveryFlagSideIsADrawnSideWithItsOwnBuilder()+ {+ var rows = UnitData.Parse(CommittedYaml);+ foreach (var side in new[] { UnitFlags.Jordan, UnitFlags.Egypt, UnitFlags.Iraq, UnitFlags.Syria, UnitFlags.Lebanon })+ {+ CollectionAssert.Contains(UnitData.Sides, side, $"{side}: a side the unit file allows");+ Assert.IsTrue(rows.Any(u => u.Side == side), $"{side}: a row of units_1948.yaml");+ Assert.IsNotNull(UnitFigures.SideFigure(side), $"{side}: a figure the map draws");+ }+ CollectionAssert.IsNotEmpty(UnitFlags.SourcedSides);+ CollectionAssert.AreEquivalent(UnitFlags.SourcedSides, UnitData.Sides.Where(UnitFlags.Has), "the sourced set is the data's sides with a flag");+ var names = new HashSet<string>();+ foreach (var side in UnitFlags.SourcedSides)+ {+ var m = UnitFlags.Build(side);+ Assert.IsNotNull(m, side);+ Assert.AreEqual(UnitFlags.MeshName(side), m!.name, $"{side}: built by its own builder");+ Assert.AreEqual(1 + UnitFlags.Colours(side).Count, m.subMeshCount, $"{side}: its own colours");+ names.Add(string.Join(",", UnitFlags.Colours(side)) + "/" + m.vertexCount);+ UnityEngine.Object.DestroyImmediate(m);+ }+ Assert.AreEqual(UnitFlags.SourcedSides.Count, names.Count, "no two sides share one flag's colours and mesh (no fall-through)");+ Assert.Throws<ArgumentException>(() => UnitFlags.Colours("ala"), "a side with no flag has no cloth colours");+ }++ /// <summary>Every sourced flag: the pole, then one non-empty submesh per cloth colour; <see cref="UnitFlags.FlagWidth"/>+ /// long from the pole and topped at <see cref="UnitFlags.FlagTop"/>, its height its law's proportion of that length.</summary>+ [Test]+ public void EverySourcedFlagHasItsColoursAndItsLawsProportion()+ {+ var ratio = new Dictionary<string, float>+ {+ [UnitData.Israel] = 160f / 220f, [UnitFlags.Jordan] = 1f / 2f, [UnitFlags.Iraq] = 1f / 2f, [UnitFlags.Syria] = 1f / 2f,+ [UnitFlags.Egypt] = 2f / 3f, [UnitFlags.Lebanon] = 2f / 3f,+ };+ CollectionAssert.AreEquivalent(Flagged, ratio.Keys);+ foreach (var side in Flagged)+ {+ var m = UnitFlags.Build(side);+ Assert.IsNotNull(m, side);+ Assert.AreEqual(UnitFlags.MeshName(side), m!.name);+ var colours = UnitFlags.Colours(side);+ Assert.AreEqual(1 + colours.Count, m.subMeshCount, $"{side}: the pole, then one submesh per cloth colour");+ Assert.AreEqual(colours.Count, colours.Distinct().Count(), $"{side}: each colour once");+ for (int k = 0; k < m.subMeshCount; k++) Assert.IsNotEmpty(m.GetTriangles(k), $"{side}: submesh {k} drawn");+ var cloth = Enumerable.Range(1, colours.Count).SelectMany(m.GetTriangles).Select(i => m.vertices[i]).ToList();+ Assert.AreEqual(UnitFlags.FlagLeft, cloth.Min(p => p.x), 1e-4f, $"{side}: from the pole");+ Assert.AreEqual(UnitFlags.FlagLeft + UnitFlags.FlagWidth, cloth.Max(p => p.x), 1e-4f, $"{side}: the same length as every flag");+ Assert.AreEqual(UnitFlags.FlagTop, cloth.Max(p => p.y), 1e-4f, $"{side}: the same top as every flag");+ Assert.AreEqual(ratio[side], (cloth.Max(p => p.y) - cloth.Min(p => p.y)) / UnitFlags.FlagWidth, 1e-3f, $"{side}: its law's proportion");+ UnityEngine.Object.DestroyImmediate(m);+ }+ }++ /// <summary>A flag's cloth in its own units (<paramref name="length"/> along +x from the pole, the bottom edge at y = 0),+ /// and one face's area of a submesh: on the cloth's plane, or (<paramref name="layered"/>) on the front layer a hair off it.</summary>+ static (Vector3[] v, Func<int, bool, float> area) InFlagUnits(Mesh m, float length, float hoist)+ {+ float k = length / UnitFlags.FlagWidth, bottom = UnitFlags.FlagTop - UnitFlags.FlagWidth * hoist / length;+ var v = m.vertices.Select(p => new Vector3((p.x - UnitFlags.FlagLeft) * k, (p.y - bottom) * k, p.z)).ToArray();+ float Area(int sub, bool layered)+ {+ var t = m.GetTriangles(sub); float a = 0f;+ for (int i = 0; i < t.Length; i += 3)+ {+ if ((Mathf.Abs(v[t[i]].z) > 1e-4f) != layered || layered && v[t[i]].z < 0f) continue;+ Vector2 p = v[t[i]], q = v[t[i + 1]], r = v[t[i + 2]];+ a += Mathf.Abs((q.x - p.x) * (r.y - p.y) - (r.x - p.x) * (q.y - p.y)) / 2f;+ }+ return a / 2f; // every plate is two-sided+ }+ return (v, Area);+ }++ /// <summary>The points of the star of <paramref name="n"/> points centred at <paramref name="centre"/>, as angles in+ /// degrees, from the layered vertices of submesh <paramref name="sub"/> within <paramref name="radius"/> of it.</summary>+ static List<float> StarPoints(Mesh m, Vector3[] v, int sub, Vector2 centre, float radius)+ {+ var near = m.GetTriangles(sub).Select(i => v[i]).Where(p => Mathf.Abs(p.z) > 1e-4f).Select(p => (Vector2)p - centre).Where(q => q.magnitude <= radius + 1e-3f).ToList();+ Assert.That(near.Max(q => q.magnitude), Is.EqualTo(radius).Within(1e-3f), $"the star at {centre} reaches {radius}");+ return near.Where(q => Mathf.Abs(q.magnitude - radius) < 1e-3f).Select(q => Mathf.Round(Mathf.Repeat(Mathf.Atan2(q.y, q.x) * Mathf.Rad2Deg, 360f) * 10f) / 10f).Distinct().ToList();+ }++ /// <summary>Egypt's flag as Law No. 47 of 1923 and its annex give it (UnitFlags' class note), in the Flaggenbuch's units+ /// that match the annex (1008 by 672): green; the crescent's outer radius a quarter of the hoist (168), its centre on the+ /// line of the two stars nearest the staff, 448 (two thirds of the hoist) from it, its breadth at the middle 63 (three+ /// quarters of a star); three five-pointed stars 84 across (an eighth of the hoist) on an equilateral triangle of side 144+ /// (a seventh of the length). The crescent's area is the outer disc's less its overlap with the inner one.</summary>+ [Test]+ public void EgyptsFlagFollowsTheAnnexToLaw47Of1923()+ {+ var m = UnitFlags.Build(UnitFlags.Egypt)!;+ var colours = UnitFlags.Colours(UnitFlags.Egypt);+ int green = 1 + colours.ToList().IndexOf(UnitFlags.GreenColour), white = 1 + colours.ToList().IndexOf(UnitFlags.WhiteColour);+ Assert.That(new[] { green, white }, Is.All.GreaterThan(0), "green cloth, white crescent and stars");+ var (v, area) = InFlagUnits(m, 1008f, 672f);+ Assert.AreEqual(1008f * 672f, area(green, false), 1f, "the green field, 2:3");+ // The crescent: every white vertex outside the stars lies on the outer circle or the inner one, and none outside the outer.+ Vector2 o = new Vector2(448f, 336f), inner = new Vector2(UnitFlags.EgyptInnerCentre, 336f);+ float side = 1008f / 7f;+ var stars = new[] { new Vector2(448f, 336f + side / 2f), new Vector2(448f, 336f - side / 2f), new Vector2(448f + side * Mathf.Sqrt(3f) / 2f, 336f) };+ Assert.AreEqual(side, (stars[0] - stars[1]).magnitude, 1e-3f); Assert.AreEqual(side, (stars[2] - stars[0]).magnitude, 1e-3f, "an equilateral triangle, a seventh of the length a side");+ var crescent = m.GetTriangles(white).Select(i => v[i]).Where(p => p.z > 1e-4f).Select(p => (Vector2)p).Where(p => stars.All(c => (p - c).magnitude > 42f + 1e-2f)).ToList();+ Assert.IsNotEmpty(crescent);+ foreach (var p in crescent)+ Assert.That(Mathf.Min(Mathf.Abs((p - o).magnitude - 168f), Mathf.Abs((p - inner).magnitude - UnitFlags.EgyptInnerRadius)), Is.LessThan(0.05f), $"a crescent vertex at {p} on neither circle");+ Assert.AreEqual(448f - 672f / 4f, crescent.Min(p => p.x), 0.05f, "the crescent's back a quarter of the hoist behind its centre");+ Assert.AreEqual(63f, UnitFlags.EgyptInnerCentre - UnitFlags.EgyptInnerRadius - 280f, 1e-3f, "its breadth at the middle 63");+ Assert.AreEqual(63f, 0.75f * 672f / 8f, 1e-3f, "three quarters of a star's diameter");+ Assert.IsTrue(crescent.Any(p => Mathf.Abs(p.y - 336f) < 0.01f && Mathf.Abs(p.x - 343f) < 0.05f), "the inner edge at 343 on the axis");+ float d = UnitFlags.EgyptInnerCentre - 448f, R = 168f, r = UnitFlags.EgyptInnerRadius;+ Assert.AreEqual(448f + (d * d + R * R - r * r) / (2f * d), crescent.Max(p => p.x), 0.05f, "the horns towards the fly, where the circles meet");+ float lens = r * r * Mathf.Acos((d * d + r * r - R * R) / (2f * d * r)) + R * R * Mathf.Acos((d * d + R * R - r * r) / (2f * d * R))+ - 0.5f * Mathf.Sqrt((-d + r + R) * (d + r - R) * (d - r + R) * (d + r + R));+ Assert.AreEqual(Mathf.PI * R * R - lens, area(white, true) - 3f * StarArea(42f, 5), 0.02f * (Mathf.PI * R * R - lens), "the crescent: the outer disc less the inner (within the arcs' polygon)");+ // The stars: five points, 84 across, centred on the triangle; one up, one down, one towards the fly (the Commons drawing).+ float[] want = { 90f, 270f, 0f };+ for (int i = 0; i < 3; i++)+ {+ var pts = StarPoints(m, v, white, stars[i], 42f);+ Assert.AreEqual(5, pts.Count, $"star {i}: five points");+ Assert.IsTrue(pts.Any(a => Mathf.Abs(Mathf.DeltaAngle(a, want[i])) < 0.1f), $"star {i}: a point at {want[i]} degrees");+ Assert.Less((stars[i] - inner).magnitude + 42f, UnitFlags.EgyptInnerRadius, $"star {i}: between the horns, clear of the crescent");+ }+ UnityEngine.Object.DestroyImmediate(m);+ }++ /// <summary>A regular {n/2} star's area, its points on a circle of radius <paramref name="outer"/>.</summary>+ static float StarArea(float outer, int n)+ {+ float inner = outer * Mathf.Cos(2f * Mathf.PI / n) / Mathf.Cos(Mathf.PI / n);+ return n * outer * inner * Mathf.Sin(Mathf.PI / n); // 2n triangles from the centre, each outer x inner x sin(pi / n) / 2+ }++ /// <summary>Iraq's flag as the Organic Law of 1925, Art. 4 gives it (UnitFlags' class note), in the law's units (length 2):+ /// three equal bands, black, white and green from the top; at the staff a red trapezoid, the flag's width at the staff, the+ /// white band's at its other base, a quarter of the length deep; two white seven-pointed stars on it, one above the other,+ /// each in a circle a ninth of the length across at (1/4, 1/3) and (1/4, 2/3) (FOTW's construction; the law fixes none).</summary>+ [Test]+ public void IraqsFlagFollowsTheOrganicLawOf1925()+ {+ var m = UnitFlags.Build(UnitFlags.Iraq)!;+ var colours = UnitFlags.Colours(UnitFlags.Iraq).ToList();+ int black = 1 + colours.IndexOf(UnitFlags.BlackColour), white = 1 + colours.IndexOf(UnitFlags.WhiteColour), green = 1 + colours.IndexOf(UnitFlags.GreenColour), red = 1 + colours.IndexOf(UnitFlags.RedColour);+ Assert.That(new[] { black, white, green, red }, Is.All.GreaterThan(0), "black, white, green and red cloth");+ var (v, area) = InFlagUnits(m, 2f, 1f);+ // The trapezoid (0,0), (0,1), (1/2,2/3), (1/2,1/3) cuts 1/12 off the black and the green band and 1/6 off the white.+ Assert.AreEqual((1f + 1f / 3f) / 2f * 0.5f, area(red, false), 1e-4f, "the red trapezoid: bases 1 and 1/3, a quarter of the length deep");+ Assert.AreEqual(2f / 3f - 1f / 12f, area(black, false), 1e-4f, "the black band, the top third");+ Assert.AreEqual(2f / 3f - 1f / 12f, area(green, false), 1e-4f, "the green band, the bottom third");+ Assert.AreEqual(2f / 3f - 1f / 6f, area(white, false), 1e-4f, "the white band, the middle third");+ Assert.That(m.GetTriangles(black).Select(i => v[i].y), Is.All.GreaterThanOrEqualTo(2f / 3f - 1e-4f), "black on top");+ Assert.That(m.GetTriangles(green).Select(i => v[i].y), Is.All.LessThanOrEqualTo(1f / 3f + 1e-4f), "green below");+ var redX = m.GetTriangles(red).Select(i => v[i]).ToList();+ Assert.AreEqual(0.5f, redX.Max(p => p.x), 1e-4f, "the trapezoid a quarter of the length deep");+ CollectionAssert.AreEquivalent(new[] { 1f / 3f, 2f / 3f }, redX.Where(p => Mathf.Abs(p.x - 0.5f) < 1e-4f).Select(p => Mathf.Round(p.y * 3000f) / 3000f).Distinct(), "its lesser base the white band");+ Assert.AreEqual(2f * StarArea(1f / 9f, 7), area(white, true), 1e-4f, "two white stars on the red");+ foreach (float y in new[] { 1f / 3f, 2f / 3f })+ {+ var pts = StarPoints(m, v, white, new Vector2(0.25f, y), 1f / 9f);+ Assert.AreEqual(7, pts.Count, "seven points");+ Assert.IsTrue(pts.Any(a => Mathf.Abs(Mathf.DeltaAngle(a, 90f)) < 0.1f), "one point up");+ }+ UnityEngine.Object.DestroyImmediate(m);+ }++ /// <summary>Syria's flag as the Constitution of 1930, Art. 4 gives it (UnitFlags' class note), in the law's units (length+ /// 2): three equal bands, green, white and black from the top; three red five-pointed stars in line on the white, a quarter+ /// of the length apart, each 0.24 of the height across, one point up (the Commons drawing; the law fixes none).</summary>+ [Test]+ public void SyriasFlagFollowsTheConstitutionOf1930()+ {+ var m = UnitFlags.Build(UnitFlags.Syria)!;+ var colours = UnitFlags.Colours(UnitFlags.Syria).ToList();+ int green = 1 + colours.IndexOf(UnitFlags.GreenColour), white = 1 + colours.IndexOf(UnitFlags.WhiteColour), black = 1 + colours.IndexOf(UnitFlags.BlackColour), red = 1 + colours.IndexOf(UnitFlags.RedColour);+ Assert.That(new[] { green, white, black, red }, Is.All.GreaterThan(0), "green, white, black and red cloth");+ Assert.Greater(red, white, "the stars drawn over the white");+ var (v, area) = InFlagUnits(m, 2f, 1f);+ foreach (int band in new[] { green, white, black }) Assert.AreEqual(2f / 3f, area(band, false), 1e-4f, "three equal bands");+ Assert.That(m.GetTriangles(green).Select(i => v[i].y), Is.All.GreaterThanOrEqualTo(2f / 3f - 1e-4f), "green on top");+ Assert.That(m.GetTriangles(black).Select(i => v[i].y), Is.All.LessThanOrEqualTo(1f / 3f + 1e-4f), "black below");+ Assert.AreEqual(0f, area(red, false), 1e-6f, "the stars only, a hair off the white");+ Assert.AreEqual(3f * StarArea(0.12f, 5), area(red, true), 1e-4f, "three red stars");+ Assert.That(m.GetTriangles(red).Select(i => v[i].y), Is.All.InRange(1f / 3f, 2f / 3f), "on the white");+ foreach (float x in new[] { 0.5f, 1f, 1.5f })+ {+ var pts = StarPoints(m, v, red, new Vector2(x, 0.5f), 0.12f);+ Assert.AreEqual(5, pts.Count, "five points");+ Assert.IsTrue(pts.Any(a => Mathf.Abs(Mathf.DeltaAngle(a, 90f)) < 0.1f), "one point up");+ }+ UnityEngine.Object.DestroyImmediate(m);+ }++ /// <summary>Lebanon's flag as the Constitution's Art. 5 (1943) gives it (UnitFlags' class note), 2:3 (practice), in units+ /// of length 3: red, white, red, the white as broad as both reds; the cedar on the white, touching both reds, a third of+ /// the length wide, in <see cref="UnitFlags.LebanonCedarColour"/> (all green: the owner, 31 October 2026, "All green (Recommended)").</summary>+ [Test]+ public void LebanonsFlagFollowsArticle5Of1943()+ {+ var m = UnitFlags.Build(UnitFlags.Lebanon)!;+ var colours = UnitFlags.Colours(UnitFlags.Lebanon).ToList();+ Assert.AreEqual(UnitFlags.GreenColour, UnitFlags.LebanonCedarColour, "all green, the owner's choice of 31 October 2026");+ int red = 1 + colours.IndexOf(UnitFlags.RedColour), white = 1 + colours.IndexOf(UnitFlags.WhiteColour), cedar = 1 + colours.IndexOf(UnitFlags.LebanonCedarColour);+ Assert.That(new[] { red, white, cedar }, Is.All.GreaterThan(0), "red, white and the cedar");+ Assert.Greater(cedar, white, "the cedar drawn over the white");+ var (v, area) = InFlagUnits(m, 3f, 2f);+ Assert.AreEqual(3f, area(white, false), 1e-4f, "the white band");+ Assert.AreEqual(3f, area(red, false), 1e-4f, "both reds together as broad as the white");+ Assert.That(m.GetTriangles(white).Select(i => v[i].y), Is.All.InRange(0.5f - 1e-4f, 1.5f + 1e-4f), "the white in the middle");+ var tree = m.GetTriangles(cedar).Select(i => v[i]).ToList();+ Assert.That(tree.Select(p => Mathf.Abs(p.z)), Is.All.GreaterThan(1e-4f), "the cedar a hair off the white");+ Assert.AreEqual(1.5f, tree.Max(p => p.y), 1e-4f, "its top touches the upper red");+ Assert.AreEqual(0.5f, tree.Min(p => p.y), 1e-4f, "its base touches the lower red");+ Assert.AreEqual(1f, tree.Max(p => p.x) - tree.Min(p => p.x), 1e-4f, "a third of the length wide");+ Assert.AreEqual(1.5f, (tree.Max(p => p.x) + tree.Min(p => p.x)) / 2f, 1e-4f, "in the middle");+ Assert.That(area(cedar, true), Is.InRange(0.3f, 0.7f), "a tree, not a box: about half its box");+ for (int i = 0; i + 1 < UnitFlags.CedarRows.Length; i++)+ Assert.Greater(UnitFlags.CedarRows[i].y, UnitFlags.CedarRows[i + 1].y - 1e-6f, "rows from the top down");+ Assert.LessOrEqual(UnitFlags.CedarRows.Length, 24, "a simple outline");+ UnityEngine.Object.DestroyImmediate(m);+ }+// ---- The scale ------------------------------------------------------------------------------------------------/// <summary>T29's figures stand about 1.8 times a house; T54 measured main's at about 2.5 at close30 against the White