{"version":3,"file":"Triangle.min.mjs","names":[],"sources":["../../../src/shapes/Triangle.ts"],"sourcesContent":["import { classRegistry } from '../ClassRegistry';\nimport { FabricObject } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { TClassProperties, TOptions } from '../typedefs';\nimport type { ObjectEvents } from '../EventTypeDefs';\n\nexport const triangleDefaultValues: Partial<TClassProperties<Triangle>> = {\n  width: 100,\n  height: 100,\n};\n\nexport class Triangle<\n  Props extends TOptions<FabricObjectProps> = Partial<FabricObjectProps>,\n  SProps extends SerializedObjectProps = SerializedObjectProps,\n  EventSpec extends ObjectEvents = ObjectEvents,\n>\n  extends FabricObject<Props, SProps, EventSpec>\n  implements FabricObjectProps\n{\n  static type = 'Triangle';\n\n  static ownDefaults = triangleDefaultValues;\n\n  static getDefaults(): Record<string, any> {\n    return { ...super.getDefaults(), ...Triangle.ownDefaults };\n  }\n\n  /**\n   * Constructor\n   * @param {Object} [options] Options object\n   */\n  constructor(options?: Props) {\n    super();\n    Object.assign(this, Triangle.ownDefaults);\n    this.setOptions(options);\n  }\n\n  /**\n   * @private\n   * @param {CanvasRenderingContext2D} ctx Context to render on\n   */\n  _render(ctx: CanvasRenderingContext2D) {\n    const widthBy2 = this.width / 2,\n      heightBy2 = this.height / 2;\n\n    ctx.beginPath();\n    ctx.moveTo(-widthBy2, heightBy2);\n    ctx.lineTo(0, -heightBy2);\n    ctx.lineTo(widthBy2, heightBy2);\n    ctx.closePath();\n\n    this._renderPaintInOrder(ctx);\n  }\n\n  /**\n   * Returns svg representation of an instance\n   * @return {Array} an array of strings with the specific svg representation\n   * of the instance\n   */\n  _toSVG() {\n    const widthBy2 = this.width / 2,\n      heightBy2 = this.height / 2,\n      points = `${-widthBy2} ${heightBy2},0 ${-heightBy2},${widthBy2} ${heightBy2}`;\n    return ['<polygon ', 'COMMON_PARTS', 'points=\"', points, '\" />'];\n  }\n}\n\nclassRegistry.setClass(Triangle);\nclassRegistry.setSVGClass(Triangle);\n"],"mappings":"oOAWA,IAAa,EAAb,MAAa,UAKH,CAAA,CAOR,OAAA,aAAO,CACL,MAAO,CAAA,GAAK,MAAM,aAAA,CAAA,GAAkB,EAAS,YAAA,CAO/C,YAAY,EAAA,CACV,OAAA,CACA,OAAO,OAAO,KAAM,EAAS,YAAA,CAC7B,KAAK,WAAW,EAAA,CAOlB,QAAQ,EAAA,CACN,IAAM,EAAW,KAAK,MAAQ,EAC5B,EAAY,KAAK,OAAS,EAE5B,EAAI,WAAA,CACJ,EAAI,OAAA,CAAQ,EAAU,EAAA,CACtB,EAAI,OAAO,EAAA,CAAI,EAAA,CACf,EAAI,OAAO,EAAU,EAAA,CACrB,EAAI,WAAA,CAEJ,KAAK,oBAAoB,EAAA,CAQ3B,QAAA,CACE,IAAM,EAAW,KAAK,MAAQ,EAC5B,EAAY,KAAK,OAAS,EAE5B,MAAO,CAAC,YAAa,eAAgB,WAD1B,GAAA,CAAI,EAAA,GAAY,EAAA,KAAA,CAAgB,EAAA,GAAa,EAAA,GAAY,IACX,OAAA,GAAA,EAAA,EA5CpD,OAAO,WAAA,CAAA,EAAA,EAEP,cAfiE,CACxE,MAAO,IACP,OAAQ,IAAA,CAAA,CA2DV,EAAc,SAAS,EAAA,CACvB,EAAc,YAAY,EAAA,CAAA,OAAA,KAAA"}