Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

polyline.ts 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import CodeShape from './index'
  2. import { v4 as uuid } from 'uuid'
  3. import { PolylineShape, ShapeType } from 'types'
  4. import { vectorToPoint } from 'utils/utils'
  5. import { defaultStyle } from 'lib/shape-styles'
  6. export default class Polyline extends CodeShape<PolylineShape> {
  7. constructor(props = {} as Partial<PolylineShape>) {
  8. props.point = vectorToPoint(props.point)
  9. props.points = props.points.map(vectorToPoint)
  10. super({
  11. id: uuid(),
  12. seed: Math.random(),
  13. type: ShapeType.Polyline,
  14. isGenerated: true,
  15. name: 'Polyline',
  16. parentId: 'page0',
  17. childIndex: 0,
  18. point: [0, 0],
  19. points: [[0, 0]],
  20. rotation: 0,
  21. isAspectRatioLocked: false,
  22. isLocked: false,
  23. isHidden: false,
  24. style: defaultStyle,
  25. ...props,
  26. })
  27. }
  28. export() {
  29. const shape = { ...this.shape }
  30. shape.point = vectorToPoint(shape.point)
  31. shape.points = shape.points.map(vectorToPoint)
  32. return shape
  33. }
  34. get points() {
  35. return this.shape.points
  36. }
  37. }