View Source Idmlx.Components.Polygon (idmlx v0.2.1)

Represents a polygon in an InDesign document.

This module provides functionality for handling polygon elements, including:

  • Geometric properties (points, coordinates, dimensions)
  • Layer information
  • Style attributes
  • Transformation data

Polygon Structure

  • name - Unique identifier for the polygon
  • layer - Layer containing the polygon
  • content_type - Type of content (e.g., "GraphicType")
  • coordinates - Bounding box coordinates
  • item_transform - Transformation matrix [a, b, c, d, tx, ty]
  • points - List of polygon vertices after transformation
  • dimensions - Width and height of the bounding box
  • object_style - Applied object style reference
  • draggable - Whether the polygon can be dragged
  • attributes - Raw XML attributes

Examples

%Idmlx.Components.Polygon{
  name: "polygon_1",
  content_type: "GraphicType",
  points: [[0.0, 0.0], [100.0, 0.0], [100.0, 100.0], [0.0, 100.0]],
  coordinates: %{"x1" => 0.0, "y1" => 0.0, "x2" => 100.0, "y2" => 100.0},
  dimensions: %{"width" => 100.0, "height" => 100.0}
}

Summary

Functions

Parses a polygon element from an XML fragment.

Types

coordinates()

@type coordinates() :: %{required(String.t()) => float()}

dimensions()

@type dimensions() :: %{required(String.t()) => float()}

point()

@type point() :: [float()]

t()

@type t() :: %Idmlx.Components.Polygon{
  attributes: [map()] | nil,
  content_type: String.t() | nil,
  coordinates: coordinates() | nil,
  dimensions: dimensions() | nil,
  draggable: boolean() | nil,
  item_transform: [float()] | nil,
  layer: any() | nil,
  name: String.t() | nil,
  object_style: String.t() | nil,
  points: [point()] | nil
}

Functions

parse(xml_fragment, layer \\ nil, story \\ nil)

@spec parse(SweetXml.t(), any(), any()) :: t()

Parses a polygon element from an XML fragment.

Processes the polygon geometry, transforms, and attributes to create a complete polygon representation.

Parameters

  • xml_fragment: XML fragment containing polygon data
  • layer: Optional layer information
  • _story: Optional story reference (unused for polygons)

Returns

A Polygon struct with calculated properties

Examples

iex> xml = get_polygon_xml()
iex> Idmlx.Components.Polygon.parse(xml)
%Polygon{
  name: "polygon_1",
  content_type: "GraphicType",
  points: [[0.0, 0.0], [100.0, 0.0], [100.0, 100.0], [0.0, 100.0]]
}