shapeRender.js 586 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // 矩形渲染
  2. export const rectangleRender = ({
  3. ctx,
  4. width,
  5. height,
  6. X,
  7. Y,
  8. color,
  9. lineWidth
  10. }) => {
  11. ctx.beginPath();
  12. // //设置线条颜色,必须放在绘制之前
  13. ctx.strokeStyle = color;
  14. ctx.lineWidth = lineWidth || 2;
  15. ctx.strokeRect(X, Y, width, height);
  16. return ctx;
  17. };
  18. // 图形渲染
  19. export const shapeRender = ({
  20. ctx,
  21. width,
  22. height,
  23. shapeType,
  24. X,
  25. Y,
  26. color,
  27. roundY,
  28. roundX,
  29. roundR,
  30. lineWidth
  31. }) => {
  32. const typeFn = [
  33. () => rectangleRender({ ctx, width, height, X, Y, color, lineWidth })
  34. ];
  35. typeFn[shapeType]();
  36. };