DSL Reference
基本構文
画面・レイアウト定義
PlaceFlowではscreenまたはlayoutでレイアウトを定義します。
screen size(幅, 高さ) { ... } ※テキスト省略可能
layout "レイアウト名" size(幅, 高さ) { ... }
layout size(幅, 高さ) { ... } ※テキスト省略可能
テキスト省略例
screen size(600, 400) { // 画面名を省略した場合 box "コンテンツ" at(50, 50) size(200, 100) } layout size(800, 600) { // レイアウト名を省略した場合 button "ボタン" at(100, 100) size(100, 40) }
自動サイズ調整
screen "画面名" size(auto) { // 要素の配置に合わせて自動サイズ調整 }
コメント
// 行コメント
構文ルール
⚠️ 重要な制約
- 1要素1行: 各要素定義は必ず1行で記述してください
- スタイル定義: style()内も複数行に分けることはできません
- 改行禁止: 要素定義の途中で改行するとパースエラーになります
✅ 正しい例:
box "Example" at(50, 50) size(100, 50) style(background: "#007bff", color: "white")
❌ 間違った例:
box "Example" at(50, 50) size(100, 50) style( background: "#007bff", color: "white" )
要素の命名
asキーワードで要素に名前を付けて、後で参照できます。
button "ログイン" at(50, 100) size(100, 40) as loginBtn
レイアウト要素
box "テキスト" at(x, y) size(幅, 高さ) 3d ※3D効果
box at(x, y) size(幅, 高さ) ※テキスト省略可能
属性
| 属性 | 説明 | 例 |
|---|---|---|
| at(x, y) | 位置座標 | at(50, 100) |
| size(w, h) | サイズ指定 | size(200, 100) |
| 3d | 立体的な3D効果を適用。奥行き感のある表示になります | box "3D Box" ... 3d |
| style(...) | スタイリング(3D効果使用時は色が自動調整されます) | style(background: "#4caf50") |
💡 3D効果について
3dキーワードを追加することで、Box要素に立体感を与えることができます。
• 奥行き10pxの立体効果が自動適用されます
• 背景色が設定されている場合、上面・右面の色が自動的に明暗調整されます
• 3D効果はスタイリングと組み合わせて使用できます
screen "Box Examples" size(400, 200) { box "Normal Box" at(50, 50) size(120, 60) box "3D Box" at(200, 50) size(120, 60) 3d box "Styled Box" at(50, 120) size(120, 60) style(background: "#e3f2fd", border: "2px solid #1976d2") box "3D Styled" at(200, 120) size(120, 60) 3d style(background: "#4caf50", color: "white") }
生成結果:
rect at(x, y) size(幅, 高さ) ※テキスト省略可能
rect at(x, y) size(幅, 高さ) radius(角丸半径)
属性
| 属性 | 説明 | 例 |
|---|---|---|
| at(x, y) | 位置座標 | at(50, 100) |
| size(w, h) | サイズ指定 | size(100, 60) |
| radius(r) | 角丸半径 | radius(5) |
| style(...) | スタイリング | style(fill: "#f0f0f0") |
screen "Rectangle Examples" size(350, 180) { rect at(50, 40) size(80, 50) rect "テキスト付き" at(50, 100) size(120, 50) style(fill: "#e3f2fd") rect "角丸" at(200, 40) size(100, 50) radius(10) style(fill: "#ffeb3b") rect "カスタム" at(200, 100) size(100, 50) radius(8) style(fill: "#4caf50", color: "white") }
生成結果:
UI要素
button at(x, y) size(幅, 高さ) ※テキスト省略可能
screen "Button Examples" size(300, 150) { button "Click Me" at(50, 50) size(100, 40) button "Styled Button" at(50, 100) size(120, 40) style(background: "#4CAF50", color: "white") }
生成結果:
input "プレースホルダー" at(x, y) size(幅, 高さ) type="password"
screen "Input Examples" size(300, 120) { input "Enter your name" at(50, 30) size(200, 30) input "Email address" at(50, 70) size(200, 30) style(border: "2px solid #2196F3") }
生成結果:
text "テキスト内容" at(x, y) fontSize(サイズ)
screen "Text Examples" size(400, 200) { text "タイトル" at(50, 40) style(fontSize: 24, fontWeight: "bold") text "サブタイトル" at(50, 80) style(fontSize: 16, color: "#666") text "本文テキスト" at(50, 120) style(fontSize: 14) text "中央寄せ" at(200, 160) style(textAlign: "center", fontSize: 14) }
生成結果:
図表要素
circle at(x, y) radius(半径)
screen "Circle Examples" size(300, 150) { circle "1" at(80, 75) radius(30) circle "API" at(220, 75) radius(35) style(fill: "#2196F3", color: "white") }
生成結果:
database at(x, y) size(幅, 高さ) ※テキスト省略可能
screen "Database Examples" size(400, 200) { database "MySQL" at(50, 60) size(100, 80) database "Redis" at(200, 60) size(100, 80) style(fill: "#dc3545") }
生成結果:
node at(x, y) size(幅, 高さ) ※テキスト省略可能
screen "Infrastructure" size(500, 300) { node "Web Server" at(50, 50) size(120, 80) as web node "App Server" at(200, 50) size(120, 80) as app node "Cache Server" at(350, 50) size(120, 80) as cache }
生成結果:
person at(x, y) size(幅, 高さ) ※テキスト省略可能
screen "Person Examples" size(400, 200) { person "ユーザー" at(50, 60) size(80, 100) person "管理者" at(200, 60) size(80, 100) style(fill: "#28a745") }
生成結果:
loadbalancer at(x, y) size(幅, 高さ) ※テキスト省略可能
screen "Load Balancing" size(500, 250) { loadbalancer "ALB" at(200, 50) size(100, 60) as alb node "Server 1" at(100, 150) size(80, 60) as srv1 node "Server 2" at(300, 150) size(80, 60) as srv2 }
生成結果:
screen "Group Demo" size(400, 300) { // ログインフォームのグループ化 group at(50, 50) { box "Login Form" at(0, 0) size(200, 150) text "Username" at(20, 30) input "Enter username" at(20, 50) size(160, 30) button "Login" at(70, 110) size(80, 25) } // システム構成のグループ化 group at(280, 80) { database "DB" at(0, 0) size(60, 50) node "API" at(80, 0) size(70, 50) } }
生成結果:
✨ Group機能の特徴
• 相対座標: グループ内の要素はグループ位置からの相対座標で配置
• ネスト対応: グループの中にさらにグループを配置可能
• 透明グループ: group at(0,0)は座標変換なしで要素をまとめるだけ
• SVG出力: <g transform="translate(x,y)">タグとして出力
図形・線
screen "Line Examples" size(300, 200) { box "A" at(50, 50) size(60, 40) box "B" at(190, 120) size(60, 40) line from(110, 70) to(190, 140) line from(50, 120) to(250, 50) style(stroke: "#dc3545", strokeWidth: "3") }
生成結果:
arrow from(x1, y1) to(x2, y2) size(矢印サイズ)
screen "Arrow Examples" size(400, 150) { box "開始" at(50, 50) size(80, 50) box "終了" at(270, 50) size(80, 50) arrow from(130, 75) to(270, 75) arrow from(200, 120) to(130, 100) style(stroke: "#28a745") }
生成結果:
要素間接続
PlaceFlowでは要素に名前を付けて直接接続することができます。要素間の接続点は自動的に計算され、直感的なコードが書けます。
基本接続
| 構文 | 説明 | 例 |
|---|---|---|
| -> | 方向付き接続(右矢印) | elementA -> elementB |
| <- | 逆方向接続(左矢印) | elementA <- elementB |
| <-> | 双方向接続 | elementA <-> elementB |
| -- | 線接続(矢印なし) | elementA -- elementB |
点線接続
| 構文 | 説明 | 例 |
|---|---|---|
| -.> | 点線矢印接続 | elementA -.> elementB |
| <-. | 点線左矢印接続 | elementA <-. elementB |
| <-.> | 点線双方向接続 | elementA <-.> elementB |
| -.- | 点線接続 | elementA -.- elementB |
曲線接続
| 構文 | 説明 | 例 |
|---|---|---|
| ~> | 曲線矢印接続 | elementA ~> elementB |
| <~ | 曲線左矢印接続 | elementA <~ elementB |
| <~> | 曲線双方向接続 | elementA <~> elementB |
| ~.~> | 点線曲線矢印接続 | elementA ~.~> elementB |
| <~.~ | 点線曲線左矢印接続 | elementA <~.~ elementB |
| <~.~> | 点線曲線双方向接続 | elementA <~.~> elementB |
要素 ... as 名前接続構文:
名前1 [接続記号] 名前2 "ラベル" (ラベルオプション)
名前ベース方向付き接続
screen "Name-based Connection" size(400, 150) { database "DB" at(50, 40) size(80, 70) as db box "API" at(200, 40) size(80, 70) as api circle "UI" at(320, 50) radius(30) as ui db -> api api -> ui }
生成結果:
双方向接続
screen "Bidirectional Connection" size(400, 150) { circle "サーバーA" at(80, 75) radius(40) as serverA circle "サーバーB" at(320, 75) radius(40) as serverB serverA <-> serverB }
生成結果:
曲線接続の例
screen "Curve Connections" size(500, 300) { box "起点" at(50, 50) size(80, 60) as start box "終点" at(350, 50) size(80, 60) as end circle "中継A" at(100, 180) radius(40) as relayA circle "中継B" at(300, 180) radius(40) as relayB // 曲線接続の例 start ~> end "曲線矢印" relayA <~> relayB "曲線双方向" start ~.~> relayA "点線曲線" end <~.~ relayB }
生成結果:
スタイリング
style()関数を使用して、要素の外観をカスタマイズできます。
共通スタイルプロパティ
| プロパティ | 説明 | 例 |
|---|---|---|
| background | 背景色 | background: "#f0f0f0" |
| color | 文字色 | color: "#333" |
| border | 境界線 | border: "2px solid #007bff" |
| fontSize | フォントサイズ | fontSize: 16 |
| fontWeight | フォント太さ | fontWeight: "bold" |
| textAlign | テキスト配置 | textAlign: "center" |
図形要素のスタイル
| プロパティ | 説明 | 例 |
|---|---|---|
| fill | 塗りつぶし色 | fill: "#ff5722" |
| stroke | 線の色 | stroke: "#333" |
| strokeWidth | 線の太さ | strokeWidth: 2 |
screen "Styled Elements" size(400, 200) { box "Primary Box" at(50, 50) size(150, 60) style(background: "#007bff", color: "white", border: "2px solid #0056b3") circle "Alert" at(300, 80) radius(35) style(fill: "#dc3545", color: "white", fontWeight: "bold") }
生成結果:
高度な機能
ネストしたレイアウト
要素の中に他の要素を配置できます。
screen "Nested Layout" size(400, 300) { box "メインコンテナ" at(50, 50) size(300, 200) { box "ヘッダー" at(20, 20) size(260, 50) style(background: "#f8f9fa") box "サイドバー" at(20, 80) size(80, 100) style(background: "#e9ecef") box "コンテンツ" at(110, 80) size(170, 100) style(background: "#ffffff") } }
生成結果:
要素の参照と接続
asで名前を付けた要素は、後で参照できます。
screen "System Diagram" size(500, 300) { person "User" at(50, 120) size(80, 60) as user node "Web App" at(200, 120) size(100, 60) as webapp database "Database" at(370, 120) size(80, 60) as db user -> webapp webapp -> db }