LineTo
Draws a line from the current point to the specified coordinates.
Syntax
expression.LineTo(x, y);
expression - A variable that represents a ApiPath class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| x | Required | GeometryCoordinate | The X coordinate. | |
| y | Required | GeometryCoordinate | The Y coordinate. |
Returns
This method doesn't return any data.
Example
Draw a straight line from the current position to a new point in a custom shape in a spreadsheet.
// How do I add a straight segment to a custom shape path in a spreadsheet?
// Extend a shape outline by connecting the current drawing position to a target coordinate in a spreadsheet.
let worksheet = Api.GetActiveSheet();
let customGeometry = Api.CreateCustomGeometry();
let path = customGeometry.AddPath();
path.SetWidth(100 * 36000);
path.SetHeight(100 * 36000);
path.SetStroke(true);
path.SetFill("norm");
path.MoveTo(50 * 36000, 0);
path.LineTo(70 * 36000, 45 * 36000);
path.LineTo(55 * 36000, 70 * 36000);
path.LineTo(100 * 36000, 100 * 36000);
path.LineTo(0, 100 * 36000);
path.Close();
let fill = Api.CreateSolidFill(Api.RGB(100, 150, 200));
let stroke = Api.CreateStroke(18000, Api.CreateSolidFill(Api.RGB(50, 75, 100)));
let shape = worksheet.AddShape("rect", 60 * 36000, 60 * 36000, fill, stroke, 3, 0, 2, 2);
shape.SetGeometry(customGeometry);