Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

line.ts 1.1KB

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