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.

points.ts 663B

12345678910111213141516171819202122232425262728
  1. import Command from "./command"
  2. import history from "../history"
  3. import { Data } from "types"
  4. import { getPage } from "utils/utils"
  5. import { getShapeUtils } from "lib/shape-utils"
  6. export default function pointsCommand(
  7. data: Data,
  8. id: string,
  9. before: number[][],
  10. after: number[][]
  11. ) {
  12. history.execute(
  13. data,
  14. new Command({
  15. name: "set_points",
  16. category: "canvas",
  17. do(data) {
  18. const shape = getPage(data).shapes[id]
  19. getShapeUtils(shape).setPoints!(shape, after)
  20. },
  21. undo(data) {
  22. const shape = getPage(data).shapes[id]
  23. getShapeUtils(shape).setPoints!(shape, before)
  24. },
  25. })
  26. )
  27. }