geometry.odin (5165B)
1 // This file is part of Blend2D project <https://blend2d.com> 2 // 3 // See blend2d.h or LICENSE.md for license and copyright information 4 // SPDX-License-Identifier: Zlib 5 package blend2d 6 7 when ODIN_OS == .Windows { 8 foreign import lib "blend2d.lib" 9 } else when ODIN_OS == .Darwin { 10 foreign import lib "libblend2d.a" 11 } else when ODIN_OS == .Linux { 12 foreign import lib "libblend2d.a" 13 } 14 15 16 //! Direction of a geometry used by geometric primitives and paths. 17 GeometryDirection :: enum u32 { 18 //! No direction specified. 19 NONE = 0, 20 21 //! Clockwise direction. 22 CW = 1, 23 24 //! Counter-clockwise direction. 25 CCW = 2, 26 FORCE_UINT = 4294967295, 27 } 28 29 //! Geometry type. 30 //! 31 //! Geometry describes a shape or path that can be either rendered or added to a BLPath container. Both \ref BLPath 32 //! and \ref BLContext provide functionality to work with all geometry types. Please note that each type provided 33 //! here requires to pass a matching struct or class to the function that consumes a `geometry_type` and `geometry_data` 34 //! arguments. 35 //! 36 //! \cond INTERNAL 37 //! \note Always modify `BL_GEOMETRY_TYPE_SIMPLE_LAST` and related functions when adding a new type to `BLGeometryType` 38 //! enum. Some functions just pass the geometry type and data to another function, but the rendering context must copy 39 //! simple types to a render job, which means that it must know which type is simple and also sizes of all simple 40 //! types, see `geometry_p.h` for more details about handling simple types. 41 //! \endcond 42 GeometryType :: enum u32 { 43 //! No geometry provided. 44 NONE = 0, 45 46 //! BLBoxI struct. 47 BOXI = 1, 48 49 //! BLBox struct. 50 BOXD = 2, 51 52 //! BLRectI struct. 53 RECTI = 3, 54 55 //! BLRect struct. 56 RECTD = 4, 57 58 //! BLCircle struct. 59 CIRCLE = 5, 60 61 //! BLEllipse struct. 62 ELLIPSE = 6, 63 64 //! BLRoundRect struct. 65 ROUND_RECT = 7, 66 67 //! BLArc struct. 68 ARC = 8, 69 70 //! BLArc struct representing chord. 71 CHORD = 9, 72 73 //! BLArc struct representing pie. 74 PIE = 10, 75 76 //! BLLine struct. 77 LINE = 11, 78 79 //! BLTriangle struct. 80 TRIANGLE = 12, 81 82 //! BLArrayView<BLPointI> representing a polyline. 83 POLYLINEI = 13, 84 85 //! BLArrayView<BLPoint> representing a polyline. 86 POLYLINED = 14, 87 88 //! BLArrayView<BLPointI> representing a polygon. 89 POLYGONI = 15, 90 91 //! BLArrayView<BLPoint> representing a polygon. 92 POLYGOND = 16, 93 94 //! BLArrayView<BLBoxI> struct. 95 ARRAY_VIEW_BOXI = 17, 96 97 //! BLArrayView<BLBox> struct. 98 ARRAY_VIEW_BOXD = 18, 99 100 //! BLArrayView<BLRectI> struct. 101 ARRAY_VIEW_RECTI = 19, 102 103 //! BLArrayView<BLRect> struct. 104 ARRAY_VIEW_RECTD = 20, 105 106 //! BLPath (or BLPathCore). 107 PATH = 21, 108 109 //! Maximum value of `BLGeometryType`. 110 MAX_VALUE = 21, 111 112 //! \cond INTERNAL 113 114 //! The last simple type. 115 SIMPLE_LAST = 12, 116 117 //! \endcond 118 FORCE_UINT = 4294967295, 119 } 120 121 //! Fill rule. 122 FillRule :: enum u32 { 123 //! Non-zero fill-rule. 124 NON_ZERO = 0, 125 126 //! Even-odd fill-rule. 127 EVEN_ODD = 1, 128 129 //! Maximum value of `BLFillRule`. 130 MAX_VALUE = 1, 131 FORCE_UINT = 4294967295, 132 } 133 134 //! Hit-test result. 135 HitTest :: enum u32 { 136 //! Fully in. 137 IN = 0, 138 139 //! Partially in/out. 140 PART = 1, 141 142 //! Fully out. 143 OUT = 2, 144 145 //! Hit test failed (invalid argument, NaNs, etc). 146 INVALID = 4294967295, 147 FORCE_UINT = 4294967295, 148 } 149 150 //! Point specified as [x, y] using `int` as a storage type. 151 PointI :: struct { 152 x: i32, 153 y: i32, 154 } 155 156 //! Size specified as [w, h] using `int` as a storage type. 157 SizeI :: struct { 158 w: i32, 159 h: i32, 160 } 161 162 //! Box specified as [x0, y0, x1, y1] using `int` as a storage type. 163 BoxI :: struct { 164 x0: i32, 165 y0: i32, 166 x1: i32, 167 y1: i32, 168 } 169 170 //! Rectangle specified as [x, y, w, h] using `int` as a storage type. 171 RectI :: struct { 172 x: i32, 173 y: i32, 174 w: i32, 175 h: i32, 176 } 177 178 //! Point specified as [x, y] using `double` as a storage type. 179 Point :: struct { 180 x: f64, 181 y: f64, 182 } 183 184 //! Size specified as [w, h] using `double` as a storage type. 185 Size :: struct { 186 w: f64, 187 h: f64, 188 } 189 190 //! Box specified as [x0, y0, x1, y1] using `double` as a storage type. 191 Box :: struct { 192 x0: f64, 193 y0: f64, 194 x1: f64, 195 y1: f64, 196 } 197 198 //! Rectangle specified as [x, y, w, h] using `double` as a storage type. 199 Rect :: struct { 200 x: f64, 201 y: f64, 202 w: f64, 203 h: f64, 204 } 205 206 //! Line specified as [x0, y0, x1, y1] using `double` as a storage type. 207 Line :: struct { 208 x0, y0: f64, 209 x1, y1: f64, 210 } 211 212 //! Triangle data specified as [x0, y0, x1, y1, x2, y2] using `double` as a storage type. 213 Triangle :: struct { 214 x0, y0: f64, 215 x1, y1: f64, 216 x2, y2: f64, 217 } 218 219 //! Rounded rectangle specified as [x, y, w, h, rx, ry] using `double` as a storage type. 220 RoundRect :: struct { 221 x, y, w, h: f64, 222 rx, ry: f64, 223 } 224 225 //! Circle specified as [cx, cy, r] using `double` as a storage type. 226 Circle :: struct { 227 cx, cy: f64, 228 r: f64, 229 } 230 231 //! Ellipse specified as [cx, cy, rx, ry] using `double` as a storage type. 232 Ellipse :: struct { 233 cx, cy: f64, 234 rx, ry: f64, 235 } 236 237 //! Arc specified as [cx, cy, rx, ry, start, sweep] using `double` as a storage type. 238 Arc :: struct { 239 cx, cy: f64, 240 rx, ry: f64, 241 start: f64, 242 sweep: f64, 243 } 244