{"version":3,"file":"Triangle.min.mjs","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   * @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"],"names":["triangleDefaultValues","width","height","Triangle","FabricObject","getDefaults","_objectSpread","super","ownDefaults","_render","ctx","widthBy2","this","heightBy2","beginPath","moveTo","lineTo","closePath","_renderPaintInOrder","_toSVG","concat","_defineProperty","classRegistry","setClass","setSVGClass"],"mappings":"2NAMO,MAAMA,EAA6D,CACxEC,MAAO,IACPC,OAAQ,KAGH,MAAMC,UAKHC,EAOR,kBAAOC,GACL,OAAAC,EAAAA,EAAA,GAAYC,MAAMF,eAAkBF,EAASK,YAC/C,CAMAC,OAAAA,CAAQC,GACN,MAAMC,EAAWC,KAAKX,MAAQ,EAC5BY,EAAYD,KAAKV,OAAS,EAE5BQ,EAAII,YACJJ,EAAIK,QAAQJ,EAAUE,GACtBH,EAAIM,OAAO,GAAIH,GACfH,EAAIM,OAAOL,EAAUE,GACrBH,EAAIO,YAEJL,KAAKM,oBAAoBR,EAC3B,CAOAS,MAAAA,GACE,MAAMR,EAAWC,KAAKX,MAAQ,EAC5BY,EAAYD,KAAKV,OAAS,EAE5B,MAAO,CAAC,YAAa,eAAgB,WAD7B,GAAAkB,QAAOT,EAAQS,KAAAA,OAAIP,EAASO,OAAAA,QAAOP,OAASO,OAAIT,EAAQS,KAAAA,OAAIP,GACX,OAC3D,EACDQ,EA5CYlB,EAAQ,OAQL,YAAUkB,EARblB,EAAQ,cAUEH,GAoCvBsB,EAAcC,SAASpB,GACvBmB,EAAcE,YAAYrB"}