跳到主要内容

GetX

Returns the X coordinate for the "moveTo"/"lineTo" path commands.

Syntax

expression.GetX();

expression - A variable that represents a ApiPathCommand class.

Parameters

This method doesn't have any parameters.

Returns

string | null

Example

Analyzes path commands of a star shape.

// Retrieves information about the first command including type and coordinates.
let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 200, 100));
let stroke = Api.CreateStroke(36000, Api.CreateSolidFill(Api.CreateRGBColor(200, 100, 0)));
let shape = Api.CreateShape("star5", 80 * 36000, 80 * 36000, fill, stroke);
let geometry = shape.GetGeometry();
let path = geometry.GetPath(0);
let commands = path.GetCommands();
paragraph.AddText("Command count: " + path.GetCommandCount());
let cmd = path.GetCommand(0);
paragraph.AddText(", First command: " + cmd.GetType() + " (" + cmd.GetX() + ", " + cmd.GetY() + ")");
paragraph.AddDrawing(shape);