README

mizchi/moonlight/model does not have a README file

#
Anchor

pub(all) enum Anchor {
Center
Top
Bottom
Left
Right
TopLeft
TopRight
BottomLeft
BottomRight
LineStart
LineEnd
}

アンカー位置(図形上の接続点)
impl Eq for Anchor
impl Show for Anchor

#
ArrowType

pub(all) enum ArrowType {
NoArrow
Arrow
}

矢印の種類
impl Eq for ArrowType
impl Show for ArrowType

#
BoundingBox

pub(all) struct BoundingBox {
x : Double
y : Double
width : Double
height : Double
}

バウンディングボックス
impl Eq for BoundingBox
impl Show for BoundingBox

#
BoundingBox::contains

fn BoundingBox::contains(self : BoundingBox, p : Point) -> Bool

ポイントがバウンディングボックス内にあるか判定

#
BoundingBox::intersects

fn BoundingBox::intersects(self : BoundingBox, other : BoundingBox) -> Bool

2つのバウンディングボックスが交差するか判定

#
BoxSelectState

pub(all) struct BoxSelectState {
start_x : Double
start_y : Double
current_x : Double
current_y : Double
}

矩形選択状態

#
BoxSelectState::to_bbox

矩形選択のバウンディングボックスを取得

#
ChildMoveResult

pub(all) struct ChildMoveResult {
child_id : String
new_x : Double
new_y : Double
}

子要素の移動後座標を計算(純粋関数)

#
Command

pub(all) enum Command {
AddElement(Element)
RemoveElement(Element)
MoveElement(String, Double, Double, Double, Double)
ResizeElement(String, ShapeType, ShapeType)
ReorderElement(String, Int, Int)
UpdateStyle(String, Style, Style)
RenameElement(String, String)
UpdateText(String, String, String)
}

操作コマンド(各操作の実行と取り消しを表現)
impl Eq for Command
impl Show for Command

#
ConnectedLineUpdate

pub(all) struct ConnectedLineUpdate {
line_id : String
new_x : Double
new_y : Double
new_x2 : Double
new_y2 : Double
}

接続ラインの更新結果

#
Connection

pub(all) struct Connection {
element_id : String
anchor : Anchor
}

接続情報(線の端点が他の要素に接続している場合)
impl Eq for Connection
impl Show for Connection

#
ConnectionGraph

pub(all) struct ConnectionGraph {
adjacency : Map[String, Array[Edge]]
edges : Array[Edge]
line_to_edge : Map[String, Edge]
}

接続グラフ(隣接リスト形式)

#
ConnectionGraph::are_directly_connected

fn ConnectionGraph::are_directly_connected(self : ConnectionGraph, id1 : String, id2 : String) -> Bool

2つの要素が直接接続されているか判定

#
ConnectionGraph::connection_distance

fn ConnectionGraph::connection_distance(self : ConnectionGraph, from_id : String, to_id : String) -> Int

2点間の接続距離(エッジ数) 接続されていない場合は -1

#
ConnectionGraph::distance_map_from

fn ConnectionGraph::distance_map_from(self : ConnectionGraph, start_id : String) -> Map[String, Int]

指定要素から各要素への接続距離マップを取得

#
ConnectionGraph::find_all_paths

fn ConnectionGraph::find_all_paths(self : ConnectionGraph, from_id : String, to_id : String, elements : Array[Element], max_paths : Int) -> Array[Path]

2点間の全パスを探索(制限付き) max_paths: 最大パス数

#
ConnectionGraph::find_shortest_path

fn ConnectionGraph::find_shortest_path(self : ConnectionGraph, from_id : String, to_id : String, elements : Array[Element]) -> Path?

2点間の最短パスを探索(BFS) 見つからない場合は None

#
ConnectionGraph::get_all_components

fn ConnectionGraph::get_all_components(self : ConnectionGraph) -> Array[Array[String]]

グラフ内の全ての連結成分を取得

#
ConnectionGraph::get_connected_component

fn ConnectionGraph::get_connected_component(self : ConnectionGraph, start_id : String) -> Array[String]

連結成分を検出(同じグループに属する要素を取得)

#
ConnectionGraph::get_connected_lines

fn ConnectionGraph::get_connected_lines(self : ConnectionGraph, element_id : String) -> Array[String]

指定要素に接続している全ての Line ID を取得

#
ConnectionGraph::get_neighbors

fn ConnectionGraph::get_neighbors(self : ConnectionGraph, element_id : String) -> Array[String]

指定要素に直接接続している要素の ID リストを取得

#
ConnectionGraph::get_stats

fn ConnectionGraph::get_stats(self : ConnectionGraph, all_element_ids : Array[String]) -> GraphStats

グラフの統計を取得

#
ConnectionGraph::has_cycle

fn ConnectionGraph::has_cycle(self : ConnectionGraph) -> Bool

循環(サイクル)検出 グラフに循環がある場合 true

#
ConnectionGraph::is_hub

fn ConnectionGraph::is_hub(self : ConnectionGraph, element_id : String) -> Bool

要素が「ハブ」(3つ以上の接続を持つ)かどうか判定

#
ConnectionGraph::is_isolated

fn ConnectionGraph::is_isolated(self : ConnectionGraph, element_id : String) -> Bool

要素が「孤立」(接続なし)かどうか判定

#
ConnectionGraph::is_leaf

fn ConnectionGraph::is_leaf(self : ConnectionGraph, element_id : String) -> Bool

要素が「リーフ」(1つの接続のみ持つ)かどうか判定

#
ConnectionGraph::new

空のグラフを作成

#
ContextMenu

pub(all) struct ContextMenu {
x : Double
y : Double
scene_x : Double
scene_y : Double
target_id : String?
}

コンテキストメニューの状態
impl Eq for ContextMenu
impl Show for ContextMenu

#
DragState

pub(all) struct DragState {
element_id : String
start_x : Double
start_y : Double
offset_x : Double
offset_y : Double
start_shape : ShapeType?
start_connections : LineConnections?
connected_start_positions : Array[(String, Double, Double)]
}

ドラッグ状態
impl Eq for DragState
impl Show for DragState

#
Edge

pub(all) struct Edge {
from_id : String
to_id : String
line_id : String
from_anchor : Anchor
to_anchor : Anchor
}

グラフのエッジ(接続)
impl Eq for Edge
impl Show for Edge

#
Element

pub(all) struct Element {
id : String
x : Double
y : Double
shape : ShapeType
style : Style
transform : String?
parent_id : String?
connections : LineConnections?
}

図形要素
impl Eq for Element
impl Show for Element

#
Element::bounding_box

fn Element::bounding_box(self : Element) -> BoundingBox

要素のバウンディングボックスを計算

#
Element::find_nearest_anchor

fn Element::find_nearest_anchor(self : Element, point : Point, threshold : Double) -> (Anchor, Point, Double)?

点から最も近いアンカーを探す

#
Element::get_all_anchors

fn Element::get_all_anchors(self : Element) -> Array[(Anchor, Point)]

全てのアンカー位置を取得(ShapeConfig.anchor_types を使用)

#
Element::get_anchor_point

fn Element::get_anchor_point(self : Element, anchor : Anchor) -> Point

指定アンカーの座標を取得

#
Element::hit_test

fn Element::hit_test(self : Element, p : Point) -> Bool

ポイントが要素上にあるか判定

#
Element::is_valid

fn Element::is_valid(self : Element) -> Bool

要素が有効(追加可能)かどうかを判定

#
Element::new

fn Element::new(id : String, x : Double, y : Double, shape : ShapeType) -> Element

新しい要素を作成

#
Element::with_parent

fn Element::with_parent(self : Element, parent_id : String) -> Element

親要素を設定(空文字列の場合はNone)

#
Element::with_style

fn Element::with_style(self : Element, style : Style) -> Element

スタイルを設定した要素を作成

#
ElementCapability

pub(all) struct ElementCapability {
can_move : Bool
can_resize : Bool
can_edit : Bool
can_delete : Bool
can_connect : Bool
can_add_child : Bool
}

要素の操作権限

#
ElementCapability::full

全操作可能

#
ElementCapability::move_and_delete

fn ElementCapability::move_and_delete() -> ElementCapability

移動と削除のみ可能(問題のある要素を除去可能にする)

#
ElementCapability::move_only

移動のみ可能

#
ElementCapability::none

全操作不可

#
EllipseResizeResult

pub(all) struct EllipseResizeResult {
cx : Double
cy : Double
rx : Double
ry : Double
}

楕円リサイズ結果

#
GraphStats

pub(all) struct GraphStats {
node_count : Int
edge_count : Int
component_count : Int
hub_count : Int
leaf_count : Int
isolated_count : Int
}

グラフの統計情報
impl Eq for GraphStats
impl Show for GraphStats

#
HandlePosition

pub(all) enum HandlePosition {
NW
NE
SW
SE
LineStart
LineEnd
}

リサイズハンドルの位置

#
History

pub(all) struct History {
undo_stack : Array[Command]
redo_stack : Array[Command]
}

履歴管理

#
History::can_redo

fn History::can_redo(self : History) -> Bool

Redo 可能かどうか

#
History::can_undo

fn History::can_undo(self : History) -> Bool

Undo 可能かどうか

#
History::new

fn History::new() -> History

履歴を作成

#
KeyBinding

pub(all) struct KeyBinding {
key : String
ctrl : Bool
shift : Bool
meta : Bool
action : String
label : String
category : String
}

キーバインド定義

#
LineConnections

pub(all) struct LineConnections {
start : Connection?
end : Connection?
}

線の接続情報

#
LineConnections::get_connected_ids

fn LineConnections::get_connected_ids(self : LineConnections) -> Array[String]

LineConnections から接続要素のIDリストを取得

#
LineConnections::none

デフォルトの接続情報(接続なし)

#
LineCoords

pub(all) struct LineCoords {
id : String
x : Double
y : Double
x2 : Double
y2 : Double
}

Line の更新後座標
impl Eq for LineCoords
impl Show for LineCoords

#
LineResizeResult

pub(all) struct LineResizeResult {
x1 : Double
y1 : Double
x2 : Double
y2 : Double
}

Line リサイズ結果

#
MoveResult

pub(all) struct MoveResult {
elements : Array[Element]
}

要素移動の結果

#
MoveTarget

pub(all) struct MoveTarget {
id : String
new_x : Double
new_y : Double
}

移動対象の情報
impl Eq for MoveTarget
impl Show for MoveTarget

#
MultiDragState

pub(all) struct MultiDragState {
element_ids : Array[String]
start_positions : Array[(String, Double, Double)]
line_endpoints : Array[(String, Double, Double)]
mouse_start_x : Double
mouse_start_y : Double
}

複数要素のドラッグ状態

#
NearestConnectionResult

pub(all) struct NearestConnectionResult {
element : Element
anchor : Anchor
point : Point
}

接続ポイント検索結果

#
Path

pub(all) struct Path {
nodes : Array[String]
edges : Array[Edge]
total_distance : Double
}

パス(経路)情報
impl Eq for Path
impl Show for Path

#
Point

pub(all) struct Point {
x : Double
y : Double
}

2D 座標点
impl Eq for Point
impl Show for Point

#
PresetColor

pub(all) struct PresetColor {
name : String
light : String
dark : String
}

プリセットカラー
impl Eq for PresetColor
impl Show for PresetColor

#
RecalculationResult

pub(all) struct RecalculationResult {
element_updates : Array[MoveTarget]
line_updates : Array[LineCoords]
}

再計算結果

#
RectResizeResult

pub(all) struct RectResizeResult {
x : Double
y : Double
width : Double
height : Double
}

矩形のリサイズ計算結果

#
RepairAction

pub(all) enum RepairAction {
RemoveConnection(String, String)
RemoveParent(String)
DeleteElement(String)
RegenerateId(String, String)
}

修復アクション
impl Eq for RepairAction

#
ResizeState

pub(all) struct ResizeState {
element_id : String
handle : HandlePosition
start_x : Double
start_y : Double
start_shape : ShapeType
mouse_start_x : Double
mouse_start_y : Double
}

リサイズ状態
impl Eq for ResizeState
impl Show for ResizeState

#
ShapeConfig

pub(all) struct ShapeConfig {
has_stroke : Bool
has_fill : Bool
has_stroke_width : Bool
has_font : Bool
has_dasharray : Bool
has_arrows : Bool
can_connect : Bool
is_connection_target : Bool
anchor_types : Array[Anchor]
}

シェープごとの設定(UI表示、編集可能なスタイル、アンカー、接続)

#
ShapeType

pub(all) enum ShapeType {
Rect(Double, Double, Double?, Double?)
Circle(Double)
Ellipse(Double, Double)
Line(Double, Double)
Polyline(Array[Point])
Path(String, Double, Double, Double, Double)
Text(String, Double?)
}

図形の種類
impl Eq for ShapeType
impl Show for ShapeType

#
ShapeType::config

fn ShapeType::config(self : ShapeType) -> ShapeConfig

シェープタイプから設定を取得

#
ShapeType::is_valid

fn ShapeType::is_valid(self : ShapeType, x : Double, y : Double) -> Bool

図形が有効(生成可能)かどうかを判定
  • Circle: 半径 > 0
  • Rect: 幅 > 0 かつ 高さ > 0
  • Ellipse: rx > 0 かつ ry > 0
  • Line: 始点と終点が異なる(距離 > 0)
  • Path: 常に無効(UIから直接生成不可)
  • Polyline: ポイント数 >= 2
  • Text: 常に有効

#
Style

pub(all) struct Style {
fill : String?
stroke : String?
stroke_width : Double?
opacity : Double?
stroke_dasharray : String?
marker_start : ArrowType?
marker_end : ArrowType?
font_family : String?
}

共通スタイル属性
impl Eq for Style
impl Show for Style

#
Style::default

fn Style::default() -> Style

デフォルトスタイル

#
TextEditState

pub(all) struct TextEditState {
parent_id : String
x : Double
y : Double
editing_id : String?
initial_text : String
font_size : Double?
}

テキスト編集状態
impl Eq for TextEditState

#
TextResizeResult

pub(all) struct TextResizeResult {
font_size : Double
}

Text リサイズ結果

#
Theme

pub(all) struct Theme {
background : String
stroke : String
fill : String
text : String
ui_bg : String
ui_bg_hover : String
ui_bg_muted : String
ui_border : String
ui_text : String
ui_text_muted : String
ui_accent : String
}

テーマ設定
impl Eq for Theme
impl Show for Theme

#
Theme::dark

fn Theme::dark() -> Theme

ダークテーマのデフォルト

#
Theme::light

fn Theme::light() -> Theme

ライトテーマのデフォルト

#
ThemeMode

pub(all) enum ThemeMode {
Light
Dark
}

テーマモード
impl Eq for ThemeMode
impl Show for ThemeMode

#
ValidationIssue

pub(all) struct ValidationIssue {
level : ValidationLevel
element_id : String?
code : String
message : String
}

検証で見つかった問題

#
ValidationLevel

pub(all) enum ValidationLevel {
Error
Warning
Info
}

検証問題の重大度

#
ValidationResult

pub(all) struct ValidationResult {
is_valid : Bool
issues : Array[ValidationIssue]
capabilities : Map[String, ElementCapability]
}

検証結果

#
ValidationResult::valid

空の検証結果(有効)

#
Viewport

pub(all) struct Viewport {
scroll_x : Double
scroll_y : Double
zoom : Double
}

Viewport (表示領域) 座標変換
impl Eq for Viewport
impl Show for Viewport

#
Viewport::default

fn Viewport::default() -> Viewport

デフォルトビューポート

#
Viewport::scene_to_screen

fn Viewport::scene_to_screen(self : Viewport, scene_x : Double, scene_y : Double) -> Point

シーン座標から画面座標への変換

#
Viewport::screen_to_scene

fn Viewport::screen_to_scene(self : Viewport, screen_x : Double, screen_y : Double) -> Point

画面座標からシーン座標への変換

#
anchor_to_string

fn anchor_to_string(anchor : Anchor) -> String

Anchor を文字列に変換

#
apply_element_move

fn apply_element_move(elements : Array[Element], target_id : String, new_x : Double, new_y : Double) -> Array[Element]

要素の移動結果を計算(純粋関数) 入力の要素配列を変更せず、更新後の新しい配列を返す

#
build_connection_graph

fn build_connection_graph(elements : Array[Element]) -> ConnectionGraph

要素配列からグラフを構築

#
calc_bring_forward

fn calc_bring_forward(current_idx : Int, length : Int) -> Int?

配列の並べ替え計算(bring_forward相当)

#
calc_bring_to_front

fn calc_bring_to_front(current_idx : Int, length : Int) -> Int?

配列の並べ替え計算(bring_to_front相当)

#
calc_child_positions

fn calc_child_positions(parent_id : String, dx : Double, dy : Double, elements : Array[Element]) -> Array[ChildMoveResult]

親要素移動時の子要素の新座標を計算

#
calc_circle_resize

fn calc_circle_resize(start_r : Double, dx : Double, dy : Double, handle : HandlePosition, min_r : Double) -> Double

円のリサイズを計算(純粋関数)

#
calc_connected_line_updates

fn calc_connected_line_updates(target_id : String, new_target_x : Double, new_target_y : Double, lines : Array[Element], all_elements : Array[Element]) -> Array[ConnectedLineUpdate]

要素移動後の接続ラインの新座標を計算(純粋関数) target_id: 移動した要素のID new_target_x, new_target_y: 移動後の座標 lines: 接続されている可能性があるLine要素のリスト all_elements: 全要素(アンカー位置計算用)

#
calc_distance

fn calc_distance(x1 : Double, y1 : Double, x2 : Double, y2 : Double) -> Double

2点間の距離を計算

#
calc_drag_position

fn calc_drag_position(offset_x : Double, offset_y : Double, mouse_x : Double, mouse_y : Double) -> Point

ドラッグ位置を計算(純粋関数)

#
calc_ellipse_resize

fn calc_ellipse_resize(cx : Double, cy : Double, start_rx : Double, start_ry : Double, dx : Double, dy : Double, handle : HandlePosition, min_r : Double) -> EllipseResizeResult

楕円のリサイズを計算(純粋関数)

#
calc_line_resize

fn calc_line_resize(start_x : Double, start_y : Double, start_x2 : Double, start_y2 : Double, dx : Double, dy : Double, handle : HandlePosition) -> LineResizeResult

Line のリサイズを計算(純粋関数)

#
calc_rect_resize

fn calc_rect_resize(start_x : Double, start_y : Double, start_w : Double, start_h : Double, dx : Double, dy : Double, handle : HandlePosition, min_size : Double) -> RectResizeResult

矩形のリサイズを計算(純粋関数)

#
calc_send_backward

fn calc_send_backward(current_idx : Int, length : Int) -> Int?

配列の並べ替え計算(send_backward相当)

#
calc_send_to_back

fn calc_send_to_back(current_idx : Int, length : Int) -> Int?

配列の並べ替え計算(send_to_back相当)

#
calc_text_bounds

fn calc_text_bounds(content : String, x : Double, y : Double, font_size : Double) -> BoundingBox

テキストのバウンディングボックスを計算 中央揃えを考慮した位置とサイズを返す

#
calc_text_hit_area

fn calc_text_hit_area(content : String, font_size : Double) -> (Double, Double)

テキストヒットエリアのサイズを計算 文字数とフォントサイズからヒットエリアの幅と高さを推定する

#
calc_text_resize

fn calc_text_resize(start_font_size : Double, dx : Double, dy : Double, handle : HandlePosition, min_size : Double) -> TextResizeResult

Text のリサイズを計算(純粋関数) フォントサイズを変更

#
can_add_element

fn can_add_element(new_element : Element, existing_elements : Array[Element]) -> (Bool, Array[ValidationIssue])

要素が追加可能か事前チェック

#
can_delete_element

fn can_delete_element(element_id : String, all_elements : Array[Element]) -> (Bool, Array[ValidationIssue])

要素が削除可能か事前チェック

#
category_edit

let category_edit : String

#
category_mode

let category_mode : String

#
category_navigation

let category_navigation : String

#
category_tool

let category_tool : String

キーバインドカテゴリ

#
compute_line_move_topology

fn compute_line_move_topology(elements : Array[Element], moved_line_id : String, new_x : Double, new_y : Double, dx : Double, dy : Double) -> Array[LineCoords]

Line 移動時の座標更新を計算(トポロジー検出)

移動した Line から BFS で接続グラフをたどり、 影響を受ける全ての Line の新しい座標を計算する

#
css_var_fill

let css_var_fill : String

#
css_var_stroke

let css_var_stroke : String

CSS変数名

#
css_var_text

let css_var_text : String

#
escape_xml

fn escape_xml(s : String) -> String

XML エスケープ

#
find_element_at

fn find_element_at(elements : Array[Element], point : Point) -> Element?

要素配列から座標にヒットする要素を検索(上から順に、純粋関数)

#
find_elements_in_box

fn find_elements_in_box(elements : Array[Element], box_bbox : BoundingBox) -> Array[Element]

矩形選択内の要素を検索(純粋関数)

#
find_keybinding_by_action

fn find_keybinding_by_action(action : String) -> KeyBinding?

アクションに対応するキーバインドを検索

#
find_nearest_connection

fn find_nearest_connection(elements : Array[Element], point : Point, exclude_ids : Array[String], threshold : Double) -> NearestConnectionResult?

指定座標から最も近い接続ポイントを探す(純粋関数)
  • 子要素(parent_id がある要素)は除外される
  • exclude_ids に含まれる要素は除外される

#
format_shape

fn format_shape(shape : ShapeType) -> String

ShapeType を文字列にフォーマット

#
get_anchor_from_line_coords

fn get_anchor_from_line_coords(x : Double, y : Double, x2 : Double, y2 : Double, anchor : Anchor) -> Point

Line の座標からアンカーポイントを計算(公開版)

#
get_element_capability

fn get_element_capability(result : ValidationResult, element_id : String) -> ElementCapability

要素の操作権限を取得

#
get_element_issues

fn get_element_issues(result : ValidationResult, element_id : String) -> Array[ValidationIssue]

特定要素の問題を取得

#
get_errors

fn get_errors(result : ValidationResult) -> Array[ValidationIssue]

エラーのみ取得

#
get_keybindings

fn get_keybindings() -> Array[KeyBinding]

全キーバインド定義を取得

#
get_keybindings_by_category

fn get_keybindings_by_category(category : String) -> Array[KeyBinding]

カテゴリでフィルタしたキーバインドを取得

#
get_marker_attrs

fn get_marker_attrs(style : Style) -> Array[(String, String)]

矢印マーカー属性を取得

#
get_parent_stroke

fn get_parent_stroke(elements : Array[Element], parent_id : String?) -> String?

要素配列から指定IDの親要素のストローク色を取得

#
get_text_fill_color

fn get_text_fill_color(text_style : Style, parent_stroke : String?) -> String

テキスト要素の塗りつぶし色を計算 Excalidraw 仕様: 親要素がある場合、親の stroke 色をテキストの fill として使用 parent_stroke: 親要素のストローク色 戻り値: テキストに適用する fill 色

#
get_warnings

fn get_warnings(result : ValidationResult) -> Array[ValidationIssue]

警告のみ取得

#
is_element_operable

fn is_element_operable(result : ValidationResult, element_id : String) -> Bool

要素が操作可能か判定

#
issue_circular_parent

let issue_circular_parent : String

#
issue_duplicate_id

let issue_duplicate_id : String

#
issue_invalid_coordinates

let issue_invalid_coordinates : String

無効な座標(NaN, Infinity)

#
issue_invalid_id

let issue_invalid_id : String

#
issue_invalid_parent

let issue_invalid_parent : String

#
issue_invalid_shape

let issue_invalid_shape : String

#
issue_line_same_points

let issue_line_same_points : String

#
issue_negative_dimension

let issue_negative_dimension : String

#
issue_orphan_connection

let issue_orphan_connection : String

#
issue_plain_svg_element

let issue_plain_svg_element : String

プレーンSVG要素(Moonlight形式でない)

#
issue_self_connection

let issue_self_connection : String

#
issue_text_empty

let issue_text_empty : String

#
issue_unsupported_shape

let issue_unsupported_shape : String

未サポートのシェープタイプ

#
keybinding_to_string

fn keybinding_to_string(kb : KeyBinding) -> String

キーバインドを表示用文字列に変換

#
match_keybinding

fn match_keybinding(key : String, ctrl : Bool, shift : Bool, meta : Bool) -> KeyBinding?

キーイベントに一致するキーバインドを検索

#
move_element_with_relations

fn move_element_with_relations(elements : Array[Element], id : String, new_x : Double, new_y : Double) -> Array[Element]

要素を移動し、関連する全ての更新を行う(純粋関数)
  • 対象要素の座標を更新
  • 子要素を同じ差分で移動
  • 接続されているラインの端点を更新

#
num_str

fn num_str(value : Double) -> String

数値を文字列に変換(小数点以下2桁に丸め)

#
parse_anchor

fn parse_anchor(anchor_str : String) -> Anchor?

アンカー名文字列を Anchor に変換

#
parse_handle_position

fn parse_handle_position(handle_str : String) -> HandlePosition

ハンドル文字列を HandlePosition に変換

#
point_in_circle

fn point_in_circle(px : Double, py : Double, cx : Double, cy : Double, radius : Double) -> Bool

点が円内にあるかチェック

#
point_in_rect

fn point_in_rect(px : Double, py : Double, rx : Double, ry : Double, width : Double, height : Double) -> Bool

点が矩形内にあるかチェック

#
point_to_line_distance

fn point_to_line_distance(px : Double, py : Double, x1 : Double, y1 : Double, x2 : Double, y2 : Double) -> Double

線分と点の最短距離を計算

#
preset_colors

fn preset_colors() -> Array[PresetColor]

プリセットカラー一覧

#
propagate_line_connections_bfs

fn propagate_line_connections_bfs(elements : Array[Element], start_ids : Array[String], except_ids? : Array[String]) -> Array[Element]

BFS で接続された全てのラインを更新(純粋関数) 指定した要素群から開始して、接続されている全てのラインを再帰的に更新する except_ids に含まれる要素は更新対象から除外される

#
recalculate_on_partial_move

fn recalculate_on_partial_move(moved_targets : Array[MoveTarget], elements : Array[Element]) -> RecalculationResult

部分移動時の全体再計算 moved_targets: 移動した要素のリスト elements: 全要素 戻り値: 接続されている他の要素・ラインの更新情報

#
reorder_array

fn[T] reorder_array(arr : Array[T], from_idx : Int, to_idx : Int) -> Array[T]

配列内の要素を新しいインデックスに移動

#
resize_element_with_relations

fn resize_element_with_relations(elements : Array[Element], id : String, new_shape : ShapeType) -> Array[Element]

要素のサイズ変更後に関連要素を更新(純粋関数、BFS で全ホップを伝播)
  • 子要素を親の中央に再配置
  • 接続されているラインの端点を更新

#
round_coord

fn round_coord(value : Double) -> Double

座標値を整数に丸める(データ可読性向上のため)

#
round_element_coords

fn round_element_coords(el : Element) -> Element

要素の座標を整数に丸める

#
shape_name

fn shape_name(shape : ShapeType) -> String

ShapeType の名前を小文字で取得

#
snap_to_grid

fn snap_to_grid(x : Double, y : Double, grid_size : Int, enabled : Bool) -> (Double, Double)

座標をグリッドにスナップ(純粋関数)

#
sort_elements_for_render

fn sort_elements_for_render(elements : Array[Element]) -> Array[Element]

要素を描画順にソート(親要素を先、子要素を後に) 子要素(Text等)が親要素(Line等)の上に描画されるようにする

#
style_to_svg_attrs

fn style_to_svg_attrs(style : Style) -> Array[(String, String)]

スタイルをSVG属性のリストに変換

#
suggest_repairs

fn suggest_repairs(issues : Array[ValidationIssue]) -> Array[RepairAction]

問題に対する修復アクションを提案

#
test_count_issues_by_code

fn test_count_issues_by_code(issues : Array[ValidationIssue], code : String) -> Int

#
test_make_circle

fn test_make_circle(id : String, x : Double, y : Double, r : Double) -> Element

#
test_make_connected_line

fn test_make_connected_line(id : String, x1 : Double, y1 : Double, x2 : Double, y2 : Double, start_conn : Connection?, end_conn : Connection?) -> Element

#
test_make_line

fn test_make_line(id : String, x1 : Double, y1 : Double, x2 : Double, y2 : Double) -> Element

#
test_make_rect

fn test_make_rect(id : String, x : Double, y : Double, w : Double, h : Double) -> Element

#
test_make_text

fn test_make_text(id : String, x : Double, y : Double, content : String) -> Element

#
update_element_in_array

fn update_element_in_array(elements : Array[Element], id : String, updater : (Element) -> Element) -> Array[Element]

要素配列から指定IDの要素を更新

#
update_element_position

fn update_element_position(el : Element, new_x : Double, new_y : Double) -> Element

要素の位置を更新した新しい要素を返す

#
update_elements_in_array

fn update_elements_in_array(elements : Array[Element], updates : Array[(String, (Element) -> Element)]) -> Array[Element]

複数の要素を一括更新

#
update_line_endpoint

fn update_line_endpoint(el : Element, endpoint : String, new_x : Double, new_y : Double) -> Element

ラインの端点を更新した新しい要素を返す

#
validate_elements

fn validate_elements(elements : Array[Element]) -> ValidationResult

要素配列を検証し、結果を返す

#
validate_single_element

fn validate_single_element(el : Element, all_elements : Array[Element]) -> Array[ValidationIssue]

単一要素の検証(他の要素との関係も考慮)