mxCloud.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Copyright (c) 2006-2015, JGraph Ltd
  3. * Copyright (c) 2006-2015, Gaudenz Alder
  4. */
  5. /**
  6. * Class: mxCloud
  7. *
  8. * Extends <mxActor> to implement a cloud shape.
  9. *
  10. * This shape is registered under <mxConstants.SHAPE_CLOUD> in
  11. * <mxCellRenderer>.
  12. *
  13. * Constructor: mxCloud
  14. *
  15. * Constructs a new cloud shape.
  16. *
  17. * Parameters:
  18. *
  19. * bounds - <mxRectangle> that defines the bounds. This is stored in
  20. * <mxShape.bounds>.
  21. * fill - String that defines the fill color. This is stored in <fill>.
  22. * stroke - String that defines the stroke color. This is stored in <stroke>.
  23. * strokewidth - Optional integer that defines the stroke width. Default is
  24. * 1. This is stored in <strokewidth>.
  25. */
  26. function mxCloud(bounds, fill, stroke, strokewidth)
  27. {
  28. mxActor.call(this);
  29. this.bounds = bounds;
  30. this.fill = fill;
  31. this.stroke = stroke;
  32. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  33. };
  34. /**
  35. * Extends mxActor.
  36. */
  37. mxUtils.extend(mxCloud, mxActor);
  38. /**
  39. * Function: redrawPath
  40. *
  41. * Draws the path for this shape.
  42. */
  43. mxCloud.prototype.redrawPath = function(c, x, y, w, h)
  44. {
  45. c.moveTo(0.25 * w, 0.25 * h);
  46. c.curveTo(0.05 * w, 0.25 * h, 0, 0.5 * h, 0.16 * w, 0.55 * h);
  47. c.curveTo(0, 0.66 * h, 0.18 * w, 0.9 * h, 0.31 * w, 0.8 * h);
  48. c.curveTo(0.4 * w, h, 0.7 * w, h, 0.8 * w, 0.8 * h);
  49. c.curveTo(w, 0.8 * h, w, 0.6 * h, 0.875 * w, 0.5 * h);
  50. c.curveTo(w, 0.3 * h, 0.8 * w, 0.1 * h, 0.625 * w, 0.2 * h);
  51. c.curveTo(0.5 * w, 0.05 * h, 0.3 * w, 0.05 * h, 0.25 * w, 0.25 * h);
  52. c.close();
  53. };
  54. __mxOutput.mxCloud = typeof mxCloud !== 'undefined' ? mxCloud : undefined;