You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ray.ts 1004B

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