MapSymbols.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* *
  2. *
  3. * (c) 2010-2021 Torstein Honsi
  4. *
  5. * License: www.highcharts.com/license
  6. *
  7. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8. *
  9. * */
  10. 'use strict';
  11. import H from '../Core/Globals.js';
  12. var Renderer = H.Renderer, VMLRenderer = H.VMLRenderer;
  13. import SVGRenderer from '../Core/Renderer/SVG/SVGRenderer.js';
  14. /* *
  15. *
  16. * Functions
  17. *
  18. * */
  19. // eslint-disable-next-line valid-jsdoc
  20. /**
  21. * Create symbols for the zoom buttons
  22. * @private
  23. */
  24. function selectiveRoundedRect(x, y, w, h, rTopLeft, rTopRight, rBottomRight, rBottomLeft) {
  25. return [
  26. ['M', x + rTopLeft, y],
  27. // top side
  28. ['L', x + w - rTopRight, y],
  29. // top right corner
  30. ['C', x + w - rTopRight / 2, y, x + w, y + rTopRight / 2, x + w, y + rTopRight],
  31. // right side
  32. ['L', x + w, y + h - rBottomRight],
  33. // bottom right corner
  34. ['C', x + w, y + h - rBottomRight / 2, x + w - rBottomRight / 2, y + h, x + w - rBottomRight, y + h],
  35. // bottom side
  36. ['L', x + rBottomLeft, y + h],
  37. // bottom left corner
  38. ['C', x + rBottomLeft / 2, y + h, x, y + h - rBottomLeft / 2, x, y + h - rBottomLeft],
  39. // left side
  40. ['L', x, y + rTopLeft],
  41. // top left corner
  42. ['C', x, y + rTopLeft / 2, x + rTopLeft / 2, y, x + rTopLeft, y],
  43. ['Z']
  44. ];
  45. }
  46. SVGRenderer.prototype.symbols.topbutton = function (x, y, w, h, options) {
  47. var r = (options && options.r) || 0;
  48. return selectiveRoundedRect(x - 1, y - 1, w, h, r, r, 0, 0);
  49. };
  50. SVGRenderer.prototype.symbols.bottombutton = function (x, y, w, h, options) {
  51. var r = (options && options.r) || 0;
  52. return selectiveRoundedRect(x - 1, y - 1, w, h, 0, 0, r, r);
  53. };
  54. // The symbol callbacks are generated on the SVGRenderer object in all browsers.
  55. // Even VML browsers need this in order to generate shapes in export. Now share
  56. // them with the VMLRenderer.
  57. if (Renderer !== SVGRenderer) {
  58. ['topbutton', 'bottombutton'].forEach(function (shape) {
  59. Renderer.prototype.symbols[shape] = SVGRenderer.prototype.symbols[shape];
  60. });
  61. }
  62. export default SVGRenderer.prototype.symbols;