您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

polyline.ts 1001B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. type: ShapeType.Polyline,
  13. isGenerated: true,
  14. name: 'Polyline',
  15. parentId: 'page0',
  16. childIndex: 0,
  17. point: [0, 0],
  18. points: [[0, 0]],
  19. rotation: 0,
  20. isAspectRatioLocked: false,
  21. isLocked: false,
  22. isHidden: false,
  23. style: defaultStyle,
  24. ...props,
  25. })
  26. }
  27. export() {
  28. const shape = { ...this.shape }
  29. shape.point = vectorToPoint(shape.point)
  30. shape.points = shape.points.map(vectorToPoint)
  31. return shape
  32. }
  33. get points() {
  34. return this.shape.points
  35. }
  36. }