LiveFlow.Paths.Geometry (LiveFlow v0.3.2)

Copy Markdown View Source

Edge geometry: handle coordinates (fixed or floating) and the path of an edge between two nodes. Shared by LiveFlow.Components.Edge and LiveFlow.Export.

Nodes must carry absolute positions (see LiveFlow.State.absolute_nodes/1).

Summary

Functions

Built-in types are their own path type; custom types default to bezier.

Computes the path of an edge. Returns %{path, label_x, label_y, source, target} where source/target are %{x, y, position}, or nil without nodes.

Nearest point on the node border facing the other node's center.

Coordinates and side of an edge endpoint on node.

Center of a side of the node box.

Point on a side of the node box; offset goes from 0.0 (top/left) to 1.0 (bottom/right), nil meaning the center.

Functions

base_path_type(type)

Built-in types are their own path type; custom types default to bezier.

edge_path(edge, source_node, target_node)

@spec edge_path(LiveFlow.Edge.t(), LiveFlow.Node.t() | nil, LiveFlow.Node.t() | nil) ::
  map() | nil

Computes the path of an edge. Returns %{path, label_x, label_y, source, target} where source/target are %{x, y, position}, or nil without nodes.

floating_point(node, other_node)

Nearest point on the node border facing the other node's center.

handle_point(node, other_node, handle_id, type, floating)

@spec handle_point(
  LiveFlow.Node.t(),
  LiveFlow.Node.t(),
  String.t() | nil,
  :source | :target,
  boolean()
) ::
  {%{x: number(), y: number()}, atom()}

Coordinates and side of an edge endpoint on node.

side_center(node, position)

Center of a side of the node box.

side_point(node, position, offset)

Point on a side of the node box; offset goes from 0.0 (top/left) to 1.0 (bottom/right), nil meaning the center.