g_integer.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /* This file is part of the GNU plotutils package. Copyright (C) 1995,
  2. 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
  3. The GNU plotutils package is free software. You may redistribute it
  4. and/or modify it under the terms of the GNU General Public License as
  5. published by the Free Software foundation; either version 2, or (at your
  6. option) any later version.
  7. The GNU plotutils package is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with the GNU plotutils package; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
  14. Boston, MA 02110-1301, USA. */
  15. /* This file contains the versions of the Plotter methods that (i) take as
  16. arguments, and/or (ii) return integers rather than doubles. */
  17. #include "sys-defines.h"
  18. #include "extern.h"
  19. int
  20. _API_arc (R___(Plotter *_plotter) int xc, int yc, int x0, int y0, int x1, int y1)
  21. {
  22. return _API_farc (R___(_plotter)
  23. (double)xc, (double)yc,
  24. (double)x0, (double)y0,
  25. (double)x1, (double)y1);
  26. }
  27. int
  28. _API_arcrel (R___(Plotter *_plotter) int dxc, int dyc, int dx0, int dy0, int dx1, int dy1)
  29. {
  30. return _API_farcrel (R___(_plotter)
  31. (double)dxc, (double)dyc,
  32. (double)dx0, (double)dy0,
  33. (double)dx1, (double)dy1);
  34. }
  35. int
  36. _API_bezier2 (R___(Plotter *_plotter) int xc, int yc, int x0, int y0, int x1, int y1)
  37. {
  38. return _API_fbezier2 (R___(_plotter)
  39. (double)xc, (double)yc,
  40. (double)x0, (double)y0,
  41. (double)x1, (double)y1);
  42. }
  43. int
  44. _API_bezier2rel (R___(Plotter *_plotter) int dxc, int dyc, int dx0, int dy0, int dx1, int dy1)
  45. {
  46. return _API_fbezier2rel (R___(_plotter)
  47. (double)dxc, (double)dyc,
  48. (double)dx0, (double)dy0,
  49. (double)dx1, (double)dy1);
  50. }
  51. int
  52. _API_bezier3 (R___(Plotter *_plotter) int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
  53. {
  54. return _API_fbezier3 (R___(_plotter)
  55. (double)x0, (double)y0,
  56. (double)x1, (double)y1,
  57. (double)x2, (double)y2,
  58. (double)x3, (double)y3);
  59. }
  60. int
  61. _API_bezier3rel (R___(Plotter *_plotter) int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
  62. {
  63. return _API_fbezier3rel (R___(_plotter)
  64. (double)x0, (double)y0,
  65. (double)x1, (double)y1,
  66. (double)x2, (double)y2,
  67. (double)x3, (double)y3);
  68. }
  69. int
  70. _API_box (R___(Plotter *_plotter) int x0, int y0, int x1, int y1)
  71. {
  72. return _API_fbox (R___(_plotter)
  73. (double)x0, (double)y0, (double)x1, (double)y1);
  74. }
  75. int
  76. _API_boxrel (R___(Plotter *_plotter) int dx0, int dy0, int dx1, int dy1)
  77. {
  78. return _API_fboxrel (R___(_plotter)
  79. (double)dx0, (double)dy0,
  80. (double)dx1, (double)dy1);
  81. }
  82. int
  83. _API_circle (R___(Plotter *_plotter) int x, int y, int r)
  84. {
  85. return _API_fcircle (R___(_plotter)
  86. (double)x, (double)y, (double)r);
  87. }
  88. int
  89. _API_circlerel (R___(Plotter *_plotter) int dx, int dy, int r)
  90. {
  91. return _API_fcirclerel (R___(_plotter)
  92. (double)dx, (double)dy, (double)r);
  93. }
  94. int
  95. _API_cont (R___(Plotter *_plotter) int x, int y)
  96. {
  97. return _API_fcont (R___(_plotter)
  98. (double)x, (double)y);
  99. }
  100. int
  101. _API_contrel (R___(Plotter *_plotter) int dx, int dy)
  102. {
  103. return _API_fcontrel (R___(_plotter)
  104. (double)dx, (double)dy);
  105. }
  106. int
  107. _API_ellarc (R___(Plotter *_plotter) int xc, int yc, int x0, int y0, int x1, int y1)
  108. {
  109. return _API_fellarc (R___(_plotter)
  110. (double)xc, (double)yc,
  111. (double)x0, (double)y0,
  112. (double)x1, (double)y1);
  113. }
  114. int
  115. _API_ellarcrel (R___(Plotter *_plotter) int dxc, int dyc, int dx0, int dy0, int dx1, int dy1)
  116. {
  117. return _API_fellarcrel (R___(_plotter)
  118. (double)dxc, (double)dyc,
  119. (double)dx0, (double)dy0,
  120. (double)dx1, (double)dy1);
  121. }
  122. int
  123. _API_ellipse (R___(Plotter *_plotter) int x, int y, int rx, int ry, int angle)
  124. {
  125. return _API_fellipse (R___(_plotter)
  126. (double)x, (double)y,
  127. (double)rx, (double)ry, (double)angle);
  128. }
  129. int
  130. _API_ellipserel (R___(Plotter *_plotter) int dx, int dy, int rx, int ry, int angle)
  131. {
  132. return _API_fellipserel (R___(_plotter)
  133. (double)dx, (double)dy,
  134. (double)rx, (double)ry,
  135. (double)angle);
  136. }
  137. int
  138. _API_fontname (R___(Plotter *_plotter) const char *s)
  139. {
  140. double new_size = _API_ffontname (R___(_plotter) s);
  141. return IROUND(new_size);
  142. }
  143. int
  144. _API_fontsize (R___(Plotter *_plotter) int size)
  145. {
  146. double new_size = _API_ffontsize (R___(_plotter) (double)size);
  147. return IROUND(new_size);
  148. }
  149. int
  150. _API_line (R___(Plotter *_plotter) int x0, int y0, int x1, int y1)
  151. {
  152. return _API_fline (R___(_plotter)
  153. (double)x0, (double)y0,
  154. (double)x1, (double)y1);
  155. }
  156. int
  157. _API_linedash (R___(Plotter *_plotter) int n, const int *dashes, int offset)
  158. {
  159. double *idashes;
  160. int i, retval;
  161. if (!_plotter->data->open)
  162. {
  163. _plotter->error (R___(_plotter)
  164. "linedash: invalid operation");
  165. return -1;
  166. }
  167. /* sanity checks */
  168. if (n < 0 || (n > 0 && dashes == NULL))
  169. return -1;
  170. for (i = 0; i < n; i++)
  171. if (dashes[i] < 0)
  172. return -1;
  173. idashes = (double *)_pl_xmalloc ((unsigned int)n * sizeof(double));
  174. for (i = 0; i < n; i++)
  175. idashes[i] = dashes[i];
  176. retval = _API_flinedash (R___(_plotter)
  177. n, idashes, (double)offset);
  178. free (idashes);
  179. return retval;
  180. }
  181. int
  182. _API_linerel (R___(Plotter *_plotter) int dx0, int dy0, int dx1, int dy1)
  183. {
  184. return _API_flinerel (R___(_plotter)
  185. (double)dx0, (double)dy0,
  186. (double)dx1, (double)dy1);
  187. }
  188. int
  189. _API_labelwidth (R___(Plotter *_plotter) const char *s)
  190. {
  191. double width = _API_flabelwidth (R___(_plotter) s);
  192. return IROUND(width);
  193. }
  194. int
  195. _API_linewidth (R___(Plotter *_plotter) int new_line_width)
  196. {
  197. return _API_flinewidth (R___(_plotter) (double)new_line_width);
  198. }
  199. int
  200. _API_marker (R___(Plotter *_plotter) int x, int y, int type, int size)
  201. {
  202. return _API_fmarker (R___(_plotter)
  203. (double)x, (double)y,
  204. type, (double)size);
  205. }
  206. int
  207. _API_markerrel (R___(Plotter *_plotter) int dx, int dy, int type, int size)
  208. {
  209. return _API_fmarkerrel (R___(_plotter)
  210. (double)dx, (double)dy,
  211. type, (double)size);
  212. }
  213. int
  214. _API_move (R___(Plotter *_plotter) int x, int y)
  215. {
  216. return _API_fmove (R___(_plotter)
  217. (double)x, (double)y);
  218. }
  219. int
  220. _API_moverel (R___(Plotter *_plotter) int x, int y)
  221. {
  222. return _API_fmoverel (R___(_plotter)
  223. (double)x, (double)y);
  224. }
  225. int
  226. _API_point (R___(Plotter *_plotter) int x, int y)
  227. {
  228. return _API_fpoint (R___(_plotter)
  229. (double)x, (double)y);
  230. }
  231. int
  232. _API_pointrel (R___(Plotter *_plotter) int dx, int dy)
  233. {
  234. return _API_fpointrel (R___(_plotter)
  235. (double)dx, (double)dy);
  236. }
  237. int
  238. _API_space (R___(Plotter *_plotter) int x0, int y0, int x1, int y1)
  239. {
  240. return _API_fspace (R___(_plotter)
  241. (double)x0, (double)y0,
  242. (double)x1, (double)y1);
  243. }
  244. int
  245. _API_space2 (R___(Plotter *_plotter) int x0, int y0, int x1, int y1, int x2, int y2)
  246. {
  247. return _API_fspace2 (R___(_plotter)
  248. (double)x0, (double)y0,
  249. (double)x1, (double)y1,
  250. (double)x2, (double)y2);
  251. }
  252. int
  253. _API_textangle (R___(Plotter *_plotter) int angle)
  254. {
  255. double new_size = _API_ftextangle (R___(_plotter)
  256. (double)angle);
  257. return IROUND(new_size);
  258. }