Heart.js 548 B

1234567891011121314151617181920212223242526
  1. var Path = require("../Path");
  2. /**
  3. * 心形
  4. * @module zrender/graphic/shape/Heart
  5. */
  6. var _default = Path.extend({
  7. type: 'heart',
  8. shape: {
  9. cx: 0,
  10. cy: 0,
  11. width: 0,
  12. height: 0
  13. },
  14. buildPath: function (ctx, shape) {
  15. var x = shape.cx;
  16. var y = shape.cy;
  17. var a = shape.width;
  18. var b = shape.height;
  19. ctx.moveTo(x, y);
  20. ctx.bezierCurveTo(x + a / 2, y - b * 2 / 3, x + a * 2, y + b / 3, x, y + b);
  21. ctx.bezierCurveTo(x - a * 2, y + b / 3, x - a / 2, y - b * 2 / 3, x, y);
  22. }
  23. });
  24. module.exports = _default;