FShape
| packages | @univerjs-pro/sheets-shape-ui |
|---|
The facade class for sheet shape builder and shape instance operations.
APIs
setPosition
Sets the position, changing where the shape appears on the sheet.
Signature
setPosition(anchorRowPos: number, anchorColPos: number, rowOffset: number, columnOffset: number): thisParameters
anchorRowPos(number) - The row index where the shape top edge is anchored (0-indexed).anchorColPos(number) - The column index where the shape left edge is anchored (0-indexed).rowOffset(number) - The pixel offset from the anchor row.columnOffset(number) - The pixel offset from the anchor column.
Returns
- (
this) - The builder itself for chaining.
setAbsolutePosition
Sets the position by absolute pixel coordinates.
Signature
setAbsolutePosition(x: number, y: number): thisParameters
x(number) - The x-coordinate of the shape top-left corner.y(number) - The y-coordinate of the shape top-left corner.
Returns
- (
this) - The builder itself for chaining.
setShapeType
Sets the type of the shape.
Signature
setShapeType(shapeType: ShapeTypeEnum): thisParameters
shapeType(ShapeTypeEnum) - The target shape type, available fromuniverAPI.Enum.ShapeTypeEnum.
Returns
- (
this) - The builder itself for chaining.
setShapeSolidFill
Sets a solid fill style for the shape.
Signature
setShapeSolidFill(color: string, opacity?: number): thisParameters
color(string) - Fill color, e.g.#ff0000.opacity(number, optional) - Fill opacity in range0to1.
Returns
- (
this) - The builder itself for chaining.
setShapeGradientFill
Sets a gradient fill style for the shape.
Signature
setShapeGradientFill(shapeGradientType: ShapeGradientTypeEnum, colorStops: Array<{ position: number; color: string }>, gradientAngle?: number): thisParameters
shapeGradientType(ShapeGradientTypeEnum) - Gradient type, e.g. linear/radial.colorStops(Array<{ position: number; color: string }>) - Gradient stops, each withposition(0~1) andcolor.gradientAngle(number, optional) - Gradient angle in degrees.
Returns
- (
this) - The builder itself for chaining.
setNoneFill
Removes fill and makes the shape transparent.
Signature
setNoneFill(): thisReturns
- (
this) - The builder itself for chaining.
setStrokeColor
Sets stroke color of the shape.
Signature
setStrokeColor(color: string): thisParameters
color(string) - Stroke color, e.g.#ff0000.
Returns
- (
this) - The builder itself for chaining.
setStrokeWidth
Sets stroke width of the shape.
Signature
setStrokeWidth(width: number): thisParameters
width(number) - Stroke width in pixels.
Returns
- (
this) - The builder itself for chaining.
setStrokeLineDashType
Sets stroke dash style.
Signature
setStrokeLineDashType(lineDashType: ShapeLineDashEnum): thisParameters
lineDashType(ShapeLineDashEnum) - Stroke dash style.
Returns
- (
this) - The builder itself for chaining.
setStrokeLineJoinType
Sets stroke line join style.
Signature
setStrokeLineJoinType(lineJoinType: ShapeLineJoinEnum): thisParameters
lineJoinType(ShapeLineJoinEnum) - Line join style.
Returns
- (
this) - The builder itself for chaining.
setStrokeLineCapType
Sets stroke line cap style.
Signature
setStrokeLineCapType(lineCapType: ShapeLineCapEnum): thisParameters
lineCapType(ShapeLineCapEnum) - Line cap style.
Returns
- (
this) - The builder itself for chaining.
setStrokeOpacity
Sets stroke opacity.
Signature
setStrokeOpacity(opacity: number): thisParameters
opacity(number) - Opacity in range0to1.
Returns
- (
this) - The builder itself for chaining.
setStrokeLineType
Sets stroke line type.
Signature
setStrokeLineType(lineType: ShapeLineTypeEnum): thisParameters
lineType(ShapeLineTypeEnum) - Line type, available fromuniverAPI.Enum.ShapeLineTypeEnum.
Returns
- (
this) - The builder itself for chaining.
setWidth
Sets shape width in pixels.
Signature
setWidth(width: number): thisParameters
width(number) - Width in pixels.
Returns
- (
this) - The builder itself for chaining.
setHeight
Sets shape height in pixels.
Signature
setHeight(height: number): thisParameters
height(number) - Height in pixels.
Returns
- (
this) - The builder itself for chaining.
isLineShape
Returns whether this shape is a line/connector shape.
Signature
isLineShape(): booleanReturns
- (
boolean) -trueif this is a connector shape; otherwisefalse.
getConnectionSites
Returns connection sites (attachment points) for this shape.
Signature
getConnectionSites(): Array<{ x: number; y: number; index: number; ang: number }>Returns
Array<{ x: number; y: number; index: number; ang: number }>- Local connection sites.x(number) - Local x-coordinate.y(number) - Local y-coordinate.index(number) - Site index.ang(number) - Site angle in 1/60000 degree units.
getAdjustPoints
Returns adjust handles for this shape.
Signature
getAdjustPoints(): Array<{ x: number; y: number; adjName: string }>Returns
Array<{ x: number; y: number; adjName: string }>- Local adjust points.x(number) - Local x-coordinate.y(number) - Local y-coordinate.adjName(string) - Adjust parameter name.
getConnectorLinePoints
Returns connector line points for connector shapes.
Signature
getConnectorLinePoints(): IShapePoint[]Returns
- (
IShapePoint[]) - Connector points in local coordinates. Returns empty array if not a connector.
getStartConnectInfo
Returns start connection info for connector shapes.
Signature
getStartConnectInfo(): IShapeRelationItem | nullReturns
- (
IShapeRelationItem | null) - Start connection target info, ornullif not connected.
getEndConnectInfo
Returns end connection info for connector shapes.
Signature
getEndConnectInfo(): IShapeRelationItem | nullReturns
- (
IShapeRelationItem | null) - End connection target info, ornullif not connected.
build
Builds a shape payload for insert/update.
Signature
build(): IShapeBuilderInfoReturns
- (
IShapeBuilderInfo) - Shape builder info that can be used byinsertShapeorupdateShape.
getShapeId
Returns the unique shape id.
Signature
getShapeId(): stringReturns
- (
string) - Shape id.
getShapeType
Returns the shape type.
Signature
getShapeType(): ShapeTypeEnum | undefinedReturns
- (
ShapeTypeEnum | undefined) - Current shape type.
getShapeData
Returns shape style data (fill/stroke/etc).
Signature
getShapeData(): IShapeDataReturns
- (
IShapeData) - Shape data object.
getPosition
Returns absolute position in pixels.
Signature
getPosition(): { x: number; y: number }Returns
- (
{ x: number; y: number }) - Position of shape top-left corner.
getSize
Returns size in pixels.
Signature
getSize(): { width: number; height: number }Returns
- (
{ width: number; height: number }) - Shape width and height.
