cd_polygons_bezier_regions.e 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. deferred class CD_POLYGONS_BEZIER_REGIONS
  2. -- The functions "begin_***", "vertex" and "end" are use for many situations.
  3. -- "begin_***" is called once, "vertex" can be called many times, and
  4. -- "end_polygon" is called once to actually do something. If you call
  5. -- "begin_***" again before "end_polygon" the process is restarted, except for
  6. -- "begin_region" that can contains one or more polygons inside.
  7. inherit
  8. CANVAS_DRAW
  9. feature {ANY}
  10. begin_fill
  11. -- Starts defining a polygon to be drawn. Connects the last point to the
  12. -- first and fills the resulting polygon according to the current
  13. -- interior style. When the interior style "hollow" is defined then it
  14. -- behaves as if the mode were "begin_closed_lines".
  15. do
  16. int_canvas_begin (cnvs, 0)
  17. end
  18. begin_open_lines
  19. -- Starts defining a polygon to be drawn. Connects all the points
  20. -- at "end". Depends on line width and line style attributes.
  21. do
  22. int_canvas_begin (cnvs, 1)
  23. end
  24. begin_closed_lines
  25. -- Starts defining a polygon to be drawn. Connects all the points at
  26. -- "end" and connects the last point to the first. Depends on line width
  27. -- and line style attributes.
  28. do
  29. int_canvas_begin (cnvs, 2)
  30. end
  31. begin_clip
  32. -- Instead of creating a polygon to be drawn, creates a polygon to define
  33. -- a polygonal clipping region.
  34. do
  35. int_canvas_begin (cnvs, 3)
  36. end
  37. begin_bezier
  38. -- Defines the points of a bezier curve.
  39. -- See: "bezier_curve" and "add_bezier_curve".
  40. do
  41. int_canvas_begin (cnvs, 4)
  42. end
  43. begin_region
  44. -- Starts the creation of a complex region for clipping. All calls to
  45. -- "box", "sector", "chord", Filled Polygons and Text will be composed in
  46. -- a region for clipping. See Regions documentation.
  47. do
  48. int_canvas_begin (cnvs, 5)
  49. end
  50. begin_path
  51. -- Creates a path composed of several primitives that can be line draw,
  52. -- filled or used as clipping. Must call "path_set" to configure the
  53. -- action between sequences of "canvas_vertex".
  54. do
  55. int_canvas_begin (cnvs, 6)
  56. end
  57. end_polygon
  58. -- Ends the polygon's definition and draws it.
  59. do
  60. int_canvas_end (cnvs)
  61. end
  62. -- Vertex operations.
  63. vertex (x, y: INTEGER)
  64. -- Adds a vertex to the polygon definition.
  65. do
  66. int_canvas_vertex (cnvs, x, y)
  67. end
  68. vertex_real (x, y: REAL_64)
  69. -- As "vertex" but with REAL_64 coordinates.
  70. do
  71. int_canvas_c_double_vertex (cnvs, x, y)
  72. end
  73. wd_vertex (x, y: REAL_64)
  74. -- As "vertex" but with World coordinates.
  75. do
  76. int_wd_canvas_vertex (cnvs, x, y)
  77. end
  78. -- Path operations
  79. new_path
  80. -- Creates a new empty path. Useful if more than one path is configured.
  81. -- "begin_path" already creates a new path.
  82. do
  83. int_canvas_path_set (cnvs, 0)
  84. end
  85. move_to
  86. -- Moves the current position to the given coordinates. Must be followed
  87. -- by 1 call to "vertex", "vertex_real", or "wd_vertex".
  88. do
  89. int_canvas_path_set (cnvs, 1)
  90. end
  91. line_to
  92. -- Adds a line to the path from the current position to the given
  93. -- coordinates. The current position is updated to the given
  94. -- coordinates. If there is no current position, nothing is connected and
  95. -- only the current position is updated. Must be followed by 1 call to
  96. -- "vertex", "vertex_real", or "wd_vertex".
  97. do
  98. int_canvas_path_set (cnvs, 2)
  99. end
  100. arc
  101. -- Adds an arc to the path. If there is a current position adds also a
  102. -- line from the current position to the start of the arc. The end of the
  103. -- arc becomes the current position. Must be followed by 3 calls to
  104. -- "vertex", "vertex_real", or "wd_vertex". One for the center of the arc
  105. -- (xc,yc), one for the bounding rectangle size (w,h), and one for the
  106. -- start and end angles (angle1,angle2). Angles are in degrees and
  107. -- oriented counter-clockwise, but angle2 can be smaller than angle1 to
  108. -- describe a clockwise arc. When using integer coordinates angles must
  109. -- be multiplied by 1000.
  110. do
  111. int_canvas_path_set (cnvs, 3)
  112. end
  113. curve_to
  114. -- Adds a bezier curve to the path. If there is no current position, the
  115. -- first point will be used twice. The end point becomes the current
  116. -- position. Must be followed by 3 calls to "vertex", "vertex_real", or
  117. -- "wd_vertex". Must be first control point (x1,y1) + second control
  118. -- point (x2,y2) + end point (x3,y3).
  119. do
  120. int_canvas_path_set (cnvs, 4)
  121. end
  122. close
  123. -- Adds a line to the path that connects the last point with the first
  124. -- point of the path, closing it.
  125. do
  126. int_canvas_path_set (cnvs, 5)
  127. end
  128. fill
  129. -- Fills the path with the current fill attributes, then the path is
  130. -- discarded.
  131. do
  132. int_canvas_path_set (cnvs, 6)
  133. end
  134. stroke
  135. -- Strokes the path with the current line attributes, then the path is
  136. -- discarded.
  137. do
  138. int_canvas_path_set (cnvs, 7)
  139. end
  140. fill_and_stroke
  141. -- Fills the path with the current fill attributes, strokes the path with
  142. -- the current line attributes, then the path is discarded.
  143. do
  144. int_canvas_path_set (cnvs, 8)
  145. end
  146. clip
  147. -- Use the path as a clipping area to be intersected with the current
  148. -- clipping area, then the path is discarded.
  149. do
  150. int_canvas_path_set (cnvs, 9)
  151. end
  152. feature {}
  153. int_canvas_begin (wgt: POINTER; mode: INTEGER)
  154. external "plug_in"
  155. alias "{
  156. location: "${sys}/plugins"
  157. module_name: "iup"
  158. feature_name: "cdCanvasBegin"
  159. }"
  160. end
  161. int_canvas_end (wgt: POINTER)
  162. external "plug_in"
  163. alias "{
  164. location: "${sys}/plugins"
  165. module_name: "iup"
  166. feature_name: "cdCanvasEnd"
  167. }"
  168. end
  169. int_canvas_vertex (wgt: POINTER; x, y: INTEGER)
  170. external "plug_in"
  171. alias "{
  172. location: "${sys}/plugins"
  173. module_name: "iup"
  174. feature_name: "cdCanvasVertex"
  175. }"
  176. end
  177. int_canvas_c_double_vertex (wgt: POINTER; x, y: REAL_64)
  178. external "plug_in"
  179. alias "{
  180. location: "${sys}/plugins"
  181. module_name: "iup"
  182. feature_name: "cdfCanvasVertex"
  183. }"
  184. end
  185. int_wd_canvas_vertex (wgt: POINTER; x, y: REAL_64)
  186. external "plug_in"
  187. alias "{
  188. location: "${sys}/plugins"
  189. module_name: "iup"
  190. feature_name: "wdCanvasVertex"
  191. }"
  192. end
  193. int_canvas_path_set (wgt: POINTER; a: INTEGER)
  194. external "plug_in"
  195. alias "{
  196. location: "${sys}/plugins"
  197. module_name: "iup"
  198. feature_name: "cdCanvasPathSet"
  199. }"
  200. end
  201. end
  202. -- The MIT License (MIT)
  203. -- Copyright (c) 2016 by German A. Arias
  204. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  205. -- of this software and associated documentation files (the "Software"), to deal
  206. -- in the Software without restriction, including without limitation the rights
  207. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  208. -- copies of the Software, and to permit persons to whom the Software is
  209. -- furnished to do so, subject to the following conditions:
  210. --
  211. -- The above copyright notice and this permission notice shall be included in
  212. -- all copies or substantial portions of the Software.
  213. --
  214. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  215. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  216. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  217. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  218. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  219. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  220. -- SOFTWARE.