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 1000B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import CodeShape from './index'
  2. import { uniqueId } from 'utils/utils'
  3. import { RayShape, ShapeProps, ShapeType } from 'types'
  4. import { defaultStyle } from 'state/shape-styles'
  5. /* ----------------- Start Copy Here ---------------- */
  6. export default class Ray extends CodeShape<RayShape> {
  7. constructor(props = {} as ShapeProps<RayShape>) {
  8. super({
  9. id: uniqueId(),
  10. type: ShapeType.Ray,
  11. isGenerated: true,
  12. name: 'Ray',
  13. parentId: 'page1',
  14. childIndex: 0,
  15. point: [0, 0],
  16. direction: [0, 1],
  17. rotation: 0,
  18. ...props,
  19. style: {
  20. ...defaultStyle,
  21. ...props.style,
  22. isFilled: false,
  23. },
  24. })
  25. }
  26. /**
  27. * The ray's direction.
  28. *
  29. * ```ts
  30. * const shapeDirection = shape.direction
  31. *
  32. * shape.direction = [0,0]
  33. * ```
  34. */
  35. get direction(): number[] {
  36. return this.shape.direction
  37. }
  38. set direction(direction: number[]) {
  39. this.utils.setProperty(this.shape, 'direction', direction)
  40. }
  41. }