A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
docs: explain the flex enums visually in the UI layout guide (en + zh)
yhhc5c4faacdedd
diff --git a/docs/astro/src/assets/guides/flex-align.svg b/docs/astro/src/assets/guides/flex-align.svgnew file mode 100644index 000000000..a2e8aea91--- /dev/null+++ b/docs/astro/src/assets/guides/flex-align.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 434 304" width="434" height="304" role="img"><text x="8" y="35" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">Start</text><rect x="118" y="8" width="300" height="60" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="128" y="18" width="34" height="20" rx="4" fill="#e8615f"/><rect x="168" y="18" width="34" height="30" rx="4" fill="#54c479"/><rect x="208" y="18" width="34" height="22" rx="4" fill="#5b9cf0"/><rect x="248" y="18" width="34" height="26" rx="4" fill="#f0bd4f"/><text x="8" y="111" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">Center</text><rect x="118" y="84" width="300" height="60" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="128" y="104" width="34" height="20" rx="4" fill="#e8615f"/><rect x="168" y="99" width="34" height="30" rx="4" fill="#54c479"/><rect x="208" y="103" width="34" height="22" rx="4" fill="#5b9cf0"/><rect x="248" y="101" width="34" height="26" rx="4" fill="#f0bd4f"/><text x="8" y="187" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">End</text><rect x="118" y="160" width="300" height="60" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="128" y="190" width="34" height="20" rx="4" fill="#e8615f"/><rect x="168" y="180" width="34" height="30" rx="4" fill="#54c479"/><rect x="208" y="188" width="34" height="22" rx="4" fill="#5b9cf0"/><rect x="248" y="184" width="34" height="26" rx="4" fill="#f0bd4f"/><text x="8" y="263" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">Stretch</text><text x="8" y="280" fill="#8b91a0" font-size="11" font-weight="400" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">auto-sized items fill the cross axis</text><rect x="118" y="236" width="300" height="60" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="128" y="246" width="34" height="40" rx="4" fill="#e8615f"/><rect x="168" y="246" width="34" height="40" rx="4" fill="#54c479"/><rect x="208" y="246" width="34" height="40" rx="4" fill="#5b9cf0"/><rect x="248" y="246" width="34" height="40" rx="4" fill="#f0bd4f"/></svg>\ No newline at end of filediff --git a/docs/astro/src/assets/guides/flex-direction.svg b/docs/astro/src/assets/guides/flex-direction.svgnew file mode 100644index 000000000..12296e7f2--- /dev/null+++ b/docs/astro/src/assets/guides/flex-direction.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 344 576" width="344" height="576" role="img"><text x="8" y="69" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">Row</text><text x="8" y="86" fill="#8b91a0" font-size="11" font-weight="400" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">main axis →</text><rect x="118" y="8" width="210" height="128" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="155" y="58" width="28" height="28" rx="4" fill="#e8615f"/><text x="169" y="76" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">1</text><rect x="191" y="58" width="28" height="28" rx="4" fill="#54c479"/><text x="205" y="76" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">2</text><rect x="227" y="58" width="28" height="28" rx="4" fill="#5b9cf0"/><text x="241" y="76" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">3</text><rect x="263" y="58" width="28" height="28" rx="4" fill="#f0bd4f"/><text x="277" y="76" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">4</text><text x="8" y="213" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">RowReverse</text><text x="8" y="230" fill="#8b91a0" font-size="11" font-weight="400" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">main axis ←</text><rect x="118" y="152" width="210" height="128" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="263" y="202" width="28" height="28" rx="4" fill="#e8615f"/><text x="277" y="220" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">1</text><rect x="227" y="202" width="28" height="28" rx="4" fill="#54c479"/><text x="241" y="220" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">2</text><rect x="191" y="202" width="28" height="28" rx="4" fill="#5b9cf0"/><text x="205" y="220" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">3</text><rect x="155" y="202" width="28" height="28" rx="4" fill="#f0bd4f"/><text x="169" y="220" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">4</text><text x="8" y="357" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">Column</text><text x="8" y="374" fill="#8b91a0" font-size="11" font-weight="400" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">main axis ↓</text><rect x="118" y="296" width="210" height="128" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="210" y="308" width="26" height="20" rx="4" fill="#e8615f"/><text x="223" y="322" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">1</text><rect x="210" y="336" width="26" height="20" rx="4" fill="#54c479"/><text x="223" y="350" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">2</text><rect x="210" y="364" width="26" height="20" rx="4" fill="#5b9cf0"/><text x="223" y="378" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">3</text><rect x="210" y="392" width="26" height="20" rx="4" fill="#f0bd4f"/><text x="223" y="406" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">4</text><text x="8" y="501" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">ColumnReverse</text><text x="8" y="518" fill="#8b91a0" font-size="11" font-weight="400" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">main axis ↑</text><rect x="118" y="440" width="210" height="128" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="210" y="536" width="26" height="20" rx="4" fill="#e8615f"/><text x="223" y="550" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">1</text><rect x="210" y="508" width="26" height="20" rx="4" fill="#54c479"/><text x="223" y="522" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">2</text><rect x="210" y="480" width="26" height="20" rx="4" fill="#5b9cf0"/><text x="223" y="494" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">3</text><rect x="210" y="452" width="26" height="20" rx="4" fill="#f0bd4f"/><text x="223" y="466" fill="#0d0f14" font-size="12" font-weight="700" text-anchor="middle" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">4</text></svg>\ No newline at end of filediff --git a/docs/astro/src/assets/guides/flex-justify.svg b/docs/astro/src/assets/guides/flex-justify.svgnew file mode 100644index 000000000..bbfdd5c5d--- /dev/null+++ b/docs/astro/src/assets/guides/flex-justify.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 434 420" width="434" height="420" role="img"><text x="8" y="32" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">Start</text><rect x="118" y="8" width="300" height="54" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="128" y="18" width="30" height="34" rx="4" fill="#e8615f"/><rect x="164" y="18" width="30" height="34" rx="4" fill="#54c479"/><rect x="200" y="18" width="30" height="34" rx="4" fill="#5b9cf0"/><rect x="236" y="18" width="30" height="34" rx="4" fill="#f0bd4f"/><text x="8" y="102" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">Center</text><rect x="118" y="78" width="300" height="54" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="199" y="88" width="30" height="34" rx="4" fill="#e8615f"/><rect x="235" y="88" width="30" height="34" rx="4" fill="#54c479"/><rect x="271" y="88" width="30" height="34" rx="4" fill="#5b9cf0"/><rect x="307" y="88" width="30" height="34" rx="4" fill="#f0bd4f"/><text x="8" y="172" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">End</text><rect x="118" y="148" width="300" height="54" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="270" y="158" width="30" height="34" rx="4" fill="#e8615f"/><rect x="306" y="158" width="30" height="34" rx="4" fill="#54c479"/><rect x="342" y="158" width="30" height="34" rx="4" fill="#5b9cf0"/><rect x="378" y="158" width="30" height="34" rx="4" fill="#f0bd4f"/><text x="8" y="242" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">SpaceBetween</text><rect x="118" y="218" width="300" height="54" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="128" y="228" width="30" height="34" rx="4" fill="#e8615f"/><rect x="211.3" y="228" width="30" height="34" rx="4" fill="#54c479"/><rect x="294.7" y="228" width="30" height="34" rx="4" fill="#5b9cf0"/><rect x="378" y="228" width="30" height="34" rx="4" fill="#f0bd4f"/><text x="8" y="312" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">SpaceAround</text><rect x="118" y="288" width="300" height="54" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="148" y="298" width="30" height="34" rx="4" fill="#e8615f"/><rect x="218" y="298" width="30" height="34" rx="4" fill="#54c479"/><rect x="288" y="298" width="30" height="34" rx="4" fill="#5b9cf0"/><rect x="358" y="298" width="30" height="34" rx="4" fill="#f0bd4f"/><text x="8" y="382" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">SpaceEvenly</text><rect x="118" y="358" width="300" height="54" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="160" y="368" width="30" height="34" rx="4" fill="#e8615f"/><rect x="222" y="368" width="30" height="34" rx="4" fill="#54c479"/><rect x="284" y="368" width="30" height="34" rx="4" fill="#5b9cf0"/><rect x="346" y="368" width="30" height="34" rx="4" fill="#f0bd4f"/></svg>\ No newline at end of filediff --git a/docs/astro/src/assets/guides/flex-wrap.svg b/docs/astro/src/assets/guides/flex-wrap.svgnew file mode 100644index 000000000..48be4b55c--- /dev/null+++ b/docs/astro/src/assets/guides/flex-wrap.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 434 200" width="434" height="200" role="img"><text x="8" y="47" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">NoWrap</text><text x="8" y="64" fill="#8b91a0" font-size="11" font-weight="400" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">children shrink to one line</text><rect x="118" y="8" width="300" height="84" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="128" y="37" width="41.7" height="26" rx="4" fill="#e8615f"/><rect x="175.7" y="37" width="41.7" height="26" rx="4" fill="#54c479"/><rect x="223.3" y="37" width="41.7" height="26" rx="4" fill="#5b9cf0"/><rect x="271" y="37" width="41.7" height="26" rx="4" fill="#f0bd4f"/><rect x="318.7" y="37" width="41.7" height="26" rx="4" fill="#e8615f"/><rect x="366.3" y="37" width="41.7" height="26" rx="4" fill="#54c479"/><text x="8" y="147" fill="#cbd0db" font-size="13" font-weight="600" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">Wrap</text><text x="8" y="164" fill="#8b91a0" font-size="11" font-weight="400" text-anchor="start" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif">overflow flows to new lines</text><rect x="118" y="108" width="300" height="84" rx="7" fill="#14161c" stroke="#2b2f3a" stroke-width="1"/><rect x="128" y="118" width="54" height="26" rx="4" fill="#e8615f"/><rect x="188" y="118" width="54" height="26" rx="4" fill="#54c479"/><rect x="248" y="118" width="54" height="26" rx="4" fill="#5b9cf0"/><rect x="308" y="118" width="54" height="26" rx="4" fill="#f0bd4f"/><rect x="128" y="150" width="54" height="26" rx="4" fill="#e8615f"/><rect x="188" y="150" width="54" height="26" rx="4" fill="#54c479"/></svg>\ No newline at end of filediff --git a/docs/astro/src/content/docs/guides/ui-layout.mdx b/docs/astro/src/content/docs/guides/ui-layout.mdxindex 738133304..71fccaa63 100644--- a/docs/astro/src/content/docs/guides/ui-layout.mdx+++ b/docs/astro/src/content/docs/guides/ui-layout.mdx@@ -97,6 +97,34 @@ CSS flexbox — each field maps 1:1 to a CSS property:`gap` and `padding` are plain numbers (design px), not `Dimension`s.</Aside>+### How flex arranges children++A flex container lays its children out along a **main axis** (chosen by `direction`),+with the **cross axis** perpendicular to it. `justifyContent` distributes children+along the main axis, `alignItems` lines them up across the cross axis, and `wrap` lets+an over-full line spill onto the next. Every enum value below is exactly its+CSS-flexbox namesake — the engine runs Yoga, so if you know flexbox, you know this.++**`direction`** — the main axis, and the order children flow in:++++**`justifyContent`** — how children pack along the **main axis**, and how any leftover+space is shared out:++++**`alignItems`** — how children line up across the **cross axis**. `Stretch` (the+default) grows only the items whose cross-size is `auto`; items with a fixed size keep it:++++**`wrap`** — when the children don't fit the main axis, `NoWrap` shrinks them onto one+line (via `flexShrink`); `Wrap` keeps their size and flows the overflow onto new lines+(those lines are then distributed by `alignContent`):+++```typescriptimport { FlexContainer, FlexDirection, JustifyContent, AlignItems } from 'esengine';diff --git a/docs/astro/src/content/docs/zh-cn/guides/ui-layout.mdx b/docs/astro/src/content/docs/zh-cn/guides/ui-layout.mdxindex 10fb3319e..42ca036be 100644--- a/docs/astro/src/content/docs/zh-cn/guides/ui-layout.mdx+++ b/docs/astro/src/content/docs/zh-cn/guides/ui-layout.mdx@@ -88,6 +88,30 @@ CSS 属性一一对应:`gap` 和 `padding` 是普通数字(设计像素),不是 `Dimension`。</Aside>+### flex 如何排布子项++flex 容器沿一条**主轴**(由 `direction` 决定)排布子项,**交叉轴**与之垂直。`justifyContent`+沿主轴分配子项,`alignItems` 沿交叉轴对齐它们,`wrap` 让放不下的一行溢出到下一行。下面每个+枚举值都与它的 CSS flexbox 同名值完全一致——引擎底层跑的就是 Yoga,你会 flexbox 就会这个。++**`direction`** —— 主轴,以及子项流动的顺序:++++**`justifyContent`** —— 子项沿**主轴**如何排布,以及多出来的空间如何分配:++++**`alignItems`** —— 子项沿**交叉轴**如何对齐。`Stretch`(默认)只拉伸交叉轴尺寸为 `auto` 的子项;+有固定尺寸的子项保持不变:++++**`wrap`** —— 当子项在主轴上放不下时,`NoWrap` 通过 `flexShrink` 把它们压缩进一行;`Wrap` 保持+其尺寸、把溢出流到新行(这些行再由 `alignContent` 分配):+++```typescriptimport { FlexContainer, FlexDirection, JustifyContent, AlignItems } from 'esengine';