newElement.ts 821 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { RoughCanvas } from "roughjs/bin/canvas";
  2. import { SceneState } from "../scene/types";
  3. import { randomSeed } from "../random";
  4. export function newElement(
  5. type: string,
  6. x: number,
  7. y: number,
  8. strokeColor: string,
  9. backgroundColor: string,
  10. fillStyle: string,
  11. strokeWidth: number,
  12. roughness: number,
  13. opacity: number,
  14. width = 0,
  15. height = 0
  16. ) {
  17. const element = {
  18. type: type,
  19. x: x,
  20. y: y,
  21. width: width,
  22. height: height,
  23. isSelected: false,
  24. strokeColor: strokeColor,
  25. backgroundColor: backgroundColor,
  26. fillStyle: fillStyle,
  27. strokeWidth: strokeWidth,
  28. roughness: roughness,
  29. opacity: opacity,
  30. seed: randomSeed(),
  31. draw(
  32. rc: RoughCanvas,
  33. context: CanvasRenderingContext2D,
  34. sceneState: SceneState
  35. ) {}
  36. };
  37. return element;
  38. }