ArrowSymbols.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /* *
  2. *
  3. * (c) 2017 Highsoft AS
  4. * Authors: Lars A. V. Cabrera
  5. *
  6. * License: www.highcharts.com/license
  7. *
  8. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  9. *
  10. * */
  11. 'use strict';
  12. import SVGRenderer from '../Core/Renderer/SVG/SVGRenderer.js';
  13. var symbols = SVGRenderer.prototype.symbols;
  14. /* *
  15. *
  16. * Functions
  17. *
  18. * */
  19. /**
  20. * Creates an arrow symbol. Like a triangle, except not filled.
  21. * ```
  22. * o
  23. * o
  24. * o
  25. * o
  26. * o
  27. * o
  28. * o
  29. * ```
  30. *
  31. * @private
  32. * @function
  33. *
  34. * @param {number} x
  35. * x position of the arrow
  36. *
  37. * @param {number} y
  38. * y position of the arrow
  39. *
  40. * @param {number} w
  41. * width of the arrow
  42. *
  43. * @param {number} h
  44. * height of the arrow
  45. *
  46. * @return {Highcharts.SVGPathArray}
  47. * Path array
  48. */
  49. function arrow(x, y, w, h) {
  50. return [
  51. ['M', x, y + h / 2],
  52. ['L', x + w, y],
  53. ['L', x, y + h / 2],
  54. ['L', x + w, y + h]
  55. ];
  56. }
  57. /**
  58. * Creates a half-width arrow symbol. Like a triangle, except not filled.
  59. * ```
  60. * o
  61. * o
  62. * o
  63. * o
  64. * o
  65. * ```
  66. *
  67. * @private
  68. * @function
  69. *
  70. * @param {number} x
  71. * x position of the arrow
  72. *
  73. * @param {number} y
  74. * y position of the arrow
  75. *
  76. * @param {number} w
  77. * width of the arrow
  78. *
  79. * @param {number} h
  80. * height of the arrow
  81. *
  82. * @return {Highcharts.SVGPathArray}
  83. * Path array
  84. */
  85. function arrowHalf(x, y, w, h) {
  86. return arrow(x, y, w / 2, h);
  87. }
  88. /**
  89. * Creates a left-oriented triangle.
  90. * ```
  91. * o
  92. * ooooooo
  93. * ooooooooooooo
  94. * ooooooo
  95. * o
  96. * ```
  97. *
  98. * @private
  99. * @function
  100. *
  101. * @param {number} x
  102. * x position of the triangle
  103. *
  104. * @param {number} y
  105. * y position of the triangle
  106. *
  107. * @param {number} w
  108. * width of the triangle
  109. *
  110. * @param {number} h
  111. * height of the triangle
  112. *
  113. * @return {Highcharts.SVGPathArray}
  114. * Path array
  115. */
  116. function triangleLeft(x, y, w, h) {
  117. return [
  118. ['M', x + w, y],
  119. ['L', x, y + h / 2],
  120. ['L', x + w, y + h],
  121. ['Z']
  122. ];
  123. }
  124. /**
  125. * Creates a half-width, left-oriented triangle.
  126. * ```
  127. * o
  128. * oooo
  129. * ooooooo
  130. * oooo
  131. * o
  132. * ```
  133. *
  134. * @private
  135. * @function
  136. *
  137. * @param {number} x
  138. * x position of the triangle
  139. *
  140. * @param {number} y
  141. * y position of the triangle
  142. *
  143. * @param {number} w
  144. * width of the triangle
  145. *
  146. * @param {number} h
  147. * height of the triangle
  148. *
  149. * @return {Highcharts.SVGPathArray}
  150. * Path array
  151. */
  152. function triangleLeftHalf(x, y, w, h) {
  153. return triangleLeft(x, y, w / 2, h);
  154. }
  155. symbols.arrow = arrow;
  156. symbols['arrow-filled'] = triangleLeft;
  157. symbols['arrow-filled-half'] = triangleLeftHalf;
  158. symbols['arrow-half'] = arrowHalf;
  159. symbols['triangle-left'] = triangleLeft;
  160. symbols['triangle-left-half'] = triangleLeftHalf;
  161. /* *
  162. *
  163. * Default Export
  164. *
  165. * */
  166. export default symbols;