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.

dot.tsx 990B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { v4 as uuid } from "uuid"
  2. import * as vec from "utils/vec"
  3. import { BaseLibShape, DotShape, ShapeType } from "types"
  4. const Dot: BaseLibShape<ShapeType.Dot> = {
  5. create(props): DotShape {
  6. return {
  7. id: uuid(),
  8. type: ShapeType.Dot,
  9. name: "Dot",
  10. parentId: "page0",
  11. childIndex: 0,
  12. point: [0, 0],
  13. rotation: 0,
  14. style: {},
  15. ...props,
  16. }
  17. },
  18. render({ id }) {
  19. return <circle id={id} cx={4} cy={4} r={4} />
  20. },
  21. getBounds(shape) {
  22. const {
  23. point: [cx, cy],
  24. } = shape
  25. return {
  26. minX: cx,
  27. maxX: cx + 4,
  28. minY: cy,
  29. maxY: cy + 4,
  30. width: 4,
  31. height: 4,
  32. }
  33. },
  34. hitTest(shape, test) {
  35. return vec.dist(shape.point, test) < 4
  36. },
  37. rotate(shape) {
  38. return shape
  39. },
  40. translate(shape) {
  41. return shape
  42. },
  43. scale(shape, scale: number) {
  44. return shape
  45. },
  46. stretch(shape, scaleX: number, scaleY: number) {
  47. return shape
  48. },
  49. }
  50. export default Dot