lines.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { LinePoint } from '@/types/elements'
  2. import { XY } from 'fabric'
  3. export interface LinePoolItem {
  4. path: string
  5. style: 'solid' | 'dashed'
  6. points: [LinePoint, LinePoint]
  7. data: XY[]
  8. isBroken?: boolean
  9. isCurve?: boolean
  10. isCubic?: boolean
  11. }
  12. export interface PresetLine {
  13. type: string
  14. children: LinePoolItem[]
  15. }
  16. export const LinePoolItems: LinePoolItem[] = [
  17. {
  18. path: "M 0 0 L 20 20",
  19. style: "solid",
  20. points: ["", ""],
  21. data: [
  22. { x: 0, y: 0 },
  23. { x: 200, y: 0 },
  24. ],
  25. },
  26. ];
  27. export const PathLineLibs: PresetLine[] = [
  28. {
  29. type: '直线',
  30. children: [
  31. { path: 'M 0 0 L 20 20', style: 'solid', points: ['', ''], data: [{x: 0, y: 0}, {x: 200, y: 0}] },
  32. { path: 'M 0 0 L 20 20', style: 'dashed', points: ['', ''], data: [{x: 0, y: 0}, {x: 200, y: 0}] },
  33. { path: 'M 0 0 L 20 20', style: 'solid', points: ['', 'arrow'], data: [{x: 0, y: 0}, {x: 200, y: 0}] },
  34. { path: 'M 0 0 L 20 20', style: 'dashed', points: ['', 'arrow'], data: [{x: 0, y: 0}, {x: 200, y: 0}] },
  35. { path: 'M 0 0 L 20 20', style: 'solid', points: ['', 'dot'], data: [{x: 0, y: 0}, {x: 200, y: 0}] },
  36. ],
  37. },
  38. {
  39. type: '折线、曲线',
  40. children: [
  41. { path: 'M 0 0 L 0 20 L 20 20', style: 'solid', points: ['', 'arrow'], isBroken: true, data: [{x: 0, y: 0}, {x: 0, y: 100}, {x: 200, y: 100}] },
  42. { path: 'M 0 0 Q 0 20 20 20', style: 'solid', points: ['', 'arrow'], isCurve: true, data: [{x: 0, y: 0}, {x: 200, y: 0}] },
  43. { path: 'M 0 0 C 20 0 0 20 20 20', style: 'solid', points: ['', 'arrow'], isCubic: true, data: [{x: 0, y: 0}, {x: 200, y: 0}] },
  44. ],
  45. },
  46. ]