| 1 | /* |
| 2 | * Copyright © 2020 Benjamin Otte |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Lesser General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2.1 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
| 15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 | * |
| 17 | * Authors: Benjamin Otte <[email protected]> |
| 18 | */ |
| 19 | |
| 20 | #include "config.h"cxx . . $ `<file>/build/config.h`/ |
| 21 | |
| 22 | #include "gskstrokeprivate.h"cxx . . $ `<file>/gsk/gskstrokeprivate.h`/ |
| 23 | |
| 24 | /** |
| 25 | * GskStroke: |
| 26 | * |
| 27 | * Collects the parameters that are needed when stroking a path. |
| 28 | * |
| 29 | * Since: 4.14 |
| 30 | */ |
| 31 | |
| 32 | G_DEFINE_BOXED_TYPEcxx . . $ `<external>/9567554376676449156/gtype.h:2440:9`! (GskStroke, gsk_stroke, gsk_stroke_copy, gsk_stroke_free) |
| 33 | |
| 34 | |
| 35 | /** |
| 36 | * gsk_stroke_new: |
| 37 | * @line_width: line width of the stroke. Must be > 0 |
| 38 | * |
| 39 | * Creates a new `GskStroke` with the given @line_width. |
| 40 | * |
| 41 | * Returns: a new `GskStroke` |
| 42 | * |
| 43 | * Since: 4.14 |
| 44 | */ |
| 45 | GskStrokecxx . . $ GskStroke# * |
| 46 | gsk_stroke_newcxx . . $ gsk_stroke_new(3267d4a00bf637ba). (float line_width) |
| 47 | { |
| 48 | GskStrokecxx . . $ GskStroke# *self; |
| 49 | |
| 50 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (line_width >= 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 51 | |
| 52 | self = g_new0cxx . . $ `<external>/1123956534522462559/gmem.h:335:9`! (GskStroke, 1); |
| 53 | |
| 54 | self->line_widthcxx . . $ _GskStroke#line_width. = line_width; |
| 55 | self->line_capcxx . . $ _GskStroke#line_cap. = GSK_LINE_CAP_BUTTcxx . . $ GSK_LINE_CAP_BUTT.; |
| 56 | self->line_joincxx . . $ _GskStroke#line_join. = GSK_LINE_JOIN_MITERcxx . . $ GSK_LINE_JOIN_MITER.; |
| 57 | self->miter_limitcxx . . $ _GskStroke#miter_limit. = 4.f; /* following svg */ |
| 58 | |
| 59 | return self; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * gsk_stroke_copy: |
| 64 | * @other: the stroke to copy |
| 65 | * |
| 66 | * Creates a copy of a `GskStroke`. |
| 67 | * |
| 68 | * Returns: a new `GskStroke`. Use [[email protected]] to free it |
| 69 | * |
| 70 | * Since: 4.14 |
| 71 | */ |
| 72 | GskStrokecxx . . $ GskStroke# * |
| 73 | gsk_stroke_copycxx . . $ gsk_stroke_copy(4154927d4d533838). (const GskStrokecxx . . $ GskStroke# *other) |
| 74 | { |
| 75 | GskStrokecxx . . $ GskStroke# *self; |
| 76 | |
| 77 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (other != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 78 | |
| 79 | self = g_newcxx . . $ `<external>/1123956534522462559/gmem.h:318:9`! (GskStroke, 1); |
| 80 | |
| 81 | *self = GSK_STROKE_INIT_COPYcxx . . $ `gsk/gskstrokeprivate.h:40:9`! (other); |
| 82 | |
| 83 | return self; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * gsk_stroke_free: |
| 88 | * @self: a stroke |
| 89 | * |
| 90 | * Frees a `GskStroke`. |
| 91 | * |
| 92 | * Since: 4.14 |
| 93 | */ |
| 94 | void |
| 95 | gsk_stroke_freecxx . . $ gsk_stroke_free(68e920122dcc7922). (GskStrokecxx . . $ GskStroke# *self) |
| 96 | { |
| 97 | if (self == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 98 | return; |
| 99 | |
| 100 | gsk_stroke_clearcxx . . $ gsk_stroke_clear(68e920122dcc7922). (self); |
| 101 | |
| 102 | g_freecxx . . $ g_free(5d22bdacc48458e8). (self); |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * gsk_stroke_to_cairo: |
| 107 | * @self: a stroke |
| 108 | * @cr: the cairo context to configure |
| 109 | * |
| 110 | * A helper function that sets the stroke parameters |
| 111 | * of a cairo context from a `GskStroke`. |
| 112 | * |
| 113 | * Since: 4.14 |
| 114 | */ |
| 115 | void |
| 116 | gsk_stroke_to_cairocxx . . $ gsk_stroke_to_cairo(852c48aec36edaaf). (const GskStrokecxx . . $ GskStroke# *self, |
| 117 | cairo_tcxx . . $ cairo_t# *cr) |
| 118 | { |
| 119 | cairo_set_line_widthcxx . . $ cairo_set_line_width(74853563bcf87c34). (cr, self->line_widthcxx . . $ _GskStroke#line_width.); |
| 120 | |
| 121 | /* gcc can optimize that to a direct case. This catches later additions to the enum */ |
| 122 | switch (self->line_capcxx . . $ _GskStroke#line_cap.) |
| 123 | { |
| 124 | case GSK_LINE_CAP_BUTTcxx . . $ GSK_LINE_CAP_BUTT.: |
| 125 | cairo_set_line_capcxx . . $ cairo_set_line_cap(d77e63337584009). (cr, CAIRO_LINE_CAP_BUTTcxx . . $ CAIRO_LINE_CAP_BUTT.); |
| 126 | break; |
| 127 | case GSK_LINE_CAP_ROUNDcxx . . $ GSK_LINE_CAP_ROUND.: |
| 128 | cairo_set_line_capcxx . . $ cairo_set_line_cap(d77e63337584009). (cr, CAIRO_LINE_CAP_ROUNDcxx . . $ CAIRO_LINE_CAP_ROUND.); |
| 129 | break; |
| 130 | case GSK_LINE_CAP_SQUAREcxx . . $ GSK_LINE_CAP_SQUARE.: |
| 131 | cairo_set_line_capcxx . . $ cairo_set_line_cap(d77e63337584009). (cr, CAIRO_LINE_CAP_SQUAREcxx . . $ CAIRO_LINE_CAP_SQUARE.); |
| 132 | break; |
| 133 | default: |
| 134 | g_assert_not_reachedcxx . . $ `<external>/15287032793271088244/gtestutils.h:274:9`! (); |
| 135 | break; |
| 136 | } |
| 137 | |
| 138 | /* gcc can optimize that to a direct case. This catches later additions to the enum */ |
| 139 | switch (self->line_joincxx . . $ _GskStroke#line_join.) |
| 140 | { |
| 141 | case GSK_LINE_JOIN_MITERcxx . . $ GSK_LINE_JOIN_MITER.: |
| 142 | cairo_set_line_joincxx . . $ cairo_set_line_join(344263d01aaacd1b). (cr, CAIRO_LINE_JOIN_MITERcxx . . $ CAIRO_LINE_JOIN_MITER.); |
| 143 | break; |
| 144 | case GSK_LINE_JOIN_ROUNDcxx . . $ GSK_LINE_JOIN_ROUND.: |
| 145 | cairo_set_line_joincxx . . $ cairo_set_line_join(344263d01aaacd1b). (cr, CAIRO_LINE_JOIN_ROUNDcxx . . $ CAIRO_LINE_JOIN_ROUND.); |
| 146 | break; |
| 147 | case GSK_LINE_JOIN_BEVELcxx . . $ GSK_LINE_JOIN_BEVEL.: |
| 148 | cairo_set_line_joincxx . . $ cairo_set_line_join(344263d01aaacd1b). (cr, CAIRO_LINE_JOIN_BEVELcxx . . $ CAIRO_LINE_JOIN_BEVEL.); |
| 149 | break; |
| 150 | default: |
| 151 | g_assert_not_reachedcxx . . $ `<external>/15287032793271088244/gtestutils.h:274:9`! (); |
| 152 | break; |
| 153 | } |
| 154 | |
| 155 | cairo_set_miter_limitcxx . . $ cairo_set_miter_limit(74853563bcf87c34). (cr, self->miter_limitcxx . . $ _GskStroke#miter_limit.); |
| 156 | |
| 157 | if (self->dash_lengthcxx . . $ _GskStroke#dash_length.) |
| 158 | { |
| 159 | gsizecxx . . $ gsize# i; |
| 160 | double *dash = g_newacxx . . $ `<external>/2019178843399655176/galloca.h:131:9`! (double, self->n_dash); |
| 161 | |
| 162 | for (i = 0; i < self->n_dashcxx . . $ _GskStroke#n_dash.; i++) |
| 163 | { |
| 164 | dash[i] = self->dashcxx . . $ _GskStroke#dash.[i]; |
| 165 | } |
| 166 | cairo_set_dashcxx . . $ cairo_set_dash(b59e67dc2db9312a). (cr, dash, self->n_dashcxx . . $ _GskStroke#n_dash., self->dash_offsetcxx . . $ _GskStroke#dash_offset.); |
| 167 | } |
| 168 | else |
| 169 | cairo_set_dashcxx . . $ cairo_set_dash(b59e67dc2db9312a). (cr, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 0.0); |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * gsk_stroke_equal: |
| 174 | * @stroke1: the first stroke |
| 175 | * @stroke2: the second stroke |
| 176 | * |
| 177 | * Checks if two strokes are identical. |
| 178 | * |
| 179 | * Returns: true if the two strokes are equal, false otherwise |
| 180 | * |
| 181 | * Since: 4.14 |
| 182 | */ |
| 183 | gbooleancxx . . $ gboolean# |
| 184 | gsk_stroke_equalcxx . . $ gsk_stroke_equal(9148c8c3ff42c9d8). (gconstpointercxx . . $ gconstpointer# stroke1, |
| 185 | gconstpointercxx . . $ gconstpointer# stroke2) |
| 186 | { |
| 187 | const GskStrokecxx . . $ GskStroke# *self1 = stroke1; |
| 188 | const GskStrokecxx . . $ GskStroke# *self2 = stroke2; |
| 189 | |
| 190 | if (self1->line_widthcxx . . $ _GskStroke#line_width. != self2->line_widthcxx . . $ _GskStroke#line_width. || |
| 191 | self1->line_capcxx . . $ _GskStroke#line_cap. != self2->line_capcxx . . $ _GskStroke#line_cap. || |
| 192 | self1->line_joincxx . . $ _GskStroke#line_join. != self2->line_joincxx . . $ _GskStroke#line_join. || |
| 193 | self1->miter_limitcxx . . $ _GskStroke#miter_limit. != self2->miter_limitcxx . . $ _GskStroke#miter_limit. || |
| 194 | self1->n_dashcxx . . $ _GskStroke#n_dash. != self2->n_dashcxx . . $ _GskStroke#n_dash. || |
| 195 | self1->dash_offsetcxx . . $ _GskStroke#dash_offset. != self2->dash_offsetcxx . . $ _GskStroke#dash_offset.) |
| 196 | return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 197 | |
| 198 | for (gsizecxx . . $ gsize# i = 0; i < self1->n_dashcxx . . $ _GskStroke#n_dash.; i++) |
| 199 | if (self1->dashcxx . . $ _GskStroke#dash.[i] != self2->dashcxx . . $ _GskStroke#dash.[i]) |
| 200 | return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 201 | |
| 202 | return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!; |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * gsk_stroke_set_line_width: |
| 207 | * @self: a stroke |
| 208 | * @line_width: width of the line in pixels |
| 209 | * |
| 210 | * Sets the line width to be used when stroking. |
| 211 | * |
| 212 | * The line width must be >= 0. |
| 213 | * |
| 214 | * Since: 4.14 |
| 215 | */ |
| 216 | void |
| 217 | gsk_stroke_set_line_widthcxx . . $ gsk_stroke_set_line_width(b98cf12f015ba217). (GskStrokecxx . . $ GskStroke# *self, |
| 218 | float line_width) |
| 219 | { |
| 220 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (self != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 221 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (line_width >= 0); |
| 222 | |
| 223 | self->line_widthcxx . . $ _GskStroke#line_width. = line_width; |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * gsk_stroke_get_line_width: |
| 228 | * @self: a stroke |
| 229 | * |
| 230 | * Gets the line width used. |
| 231 | * |
| 232 | * Returns: the line width |
| 233 | * |
| 234 | * Since: 4.14 |
| 235 | */ |
| 236 | float |
| 237 | gsk_stroke_get_line_widthcxx . . $ gsk_stroke_get_line_width(b8f15f61b581d68c). (const GskStrokecxx . . $ GskStroke# *self) |
| 238 | { |
| 239 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (self != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0.0); |
| 240 | |
| 241 | return self->line_widthcxx . . $ _GskStroke#line_width.; |
| 242 | } |
| 243 | |
| 244 | /** |
| 245 | * gsk_stroke_set_line_cap: |
| 246 | * @self: a stroke |
| 247 | * @line_cap: the line cap |
| 248 | * |
| 249 | * Sets the line cap to be used when stroking. |
| 250 | * |
| 251 | * See [[email protected]] for details. |
| 252 | * |
| 253 | * Since: 4.14 |
| 254 | */ |
| 255 | void |
| 256 | gsk_stroke_set_line_capcxx . . $ gsk_stroke_set_line_cap(b56c88ccfbbd9009). (GskStrokecxx . . $ GskStroke# *self, |
| 257 | GskLineCapcxx . . $ GskLineCap# line_cap) |
| 258 | { |
| 259 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (self != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 260 | |
| 261 | self->line_capcxx . . $ _GskStroke#line_cap. = line_cap; |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * gsk_stroke_get_line_cap: |
| 266 | * @self: a stroke |
| 267 | * |
| 268 | * Gets the line cap used. |
| 269 | * |
| 270 | * See [[email protected]] for details. |
| 271 | * |
| 272 | * Returns: the line cap |
| 273 | * |
| 274 | * Since: 4.14 |
| 275 | */ |
| 276 | GskLineCapcxx . . $ GskLineCap# |
| 277 | gsk_stroke_get_line_capcxx . . $ gsk_stroke_get_line_cap(c748be9ab2e6d53a). (const GskStrokecxx . . $ GskStroke# *self) |
| 278 | { |
| 279 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (self != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0.0); |
| 280 | |
| 281 | return self->line_capcxx . . $ _GskStroke#line_cap.; |
| 282 | } |
| 283 | |
| 284 | /** |
| 285 | * gsk_stroke_set_line_join: |
| 286 | * @self: a stroke |
| 287 | * @line_join: the line join to use |
| 288 | * |
| 289 | * Sets the line join to be used when stroking. |
| 290 | * |
| 291 | * See [[email protected]] for details. |
| 292 | * |
| 293 | * Since: 4.14 |
| 294 | */ |
| 295 | void |
| 296 | gsk_stroke_set_line_joincxx . . $ gsk_stroke_set_line_join(8996f6aa96938956). (GskStrokecxx . . $ GskStroke# *self, |
| 297 | GskLineJoincxx . . $ GskLineJoin# line_join) |
| 298 | { |
| 299 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (self != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 300 | |
| 301 | self->line_joincxx . . $ _GskStroke#line_join. = line_join; |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * gsk_stroke_get_line_join: |
| 306 | * @self: a stroke |
| 307 | * |
| 308 | * Gets the line join used. |
| 309 | * |
| 310 | * See [[email protected]] for details. |
| 311 | * |
| 312 | * Returns: the line join |
| 313 | * |
| 314 | * Since: 4.14 |
| 315 | */ |
| 316 | GskLineJoincxx . . $ GskLineJoin# |
| 317 | gsk_stroke_get_line_joincxx . . $ gsk_stroke_get_line_join(588bf66f062969b8). (const GskStrokecxx . . $ GskStroke# *self) |
| 318 | { |
| 319 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (self != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0.0); |
| 320 | |
| 321 | return self->line_joincxx . . $ _GskStroke#line_join.; |
| 322 | } |
| 323 | |
| 324 | /** |
| 325 | * gsk_stroke_set_miter_limit: |
| 326 | * @self: a stroke |
| 327 | * @limit: the miter limit |
| 328 | * |
| 329 | * Sets the miter limit to be used when stroking. |
| 330 | * |
| 331 | * The miter limit is the distance from the corner where sharp |
| 332 | * turns of joins get cut off. |
| 333 | * |
| 334 | * The limit is specfied in units of line width and must be non-negative. |
| 335 | * |
| 336 | * For joins of type [[email protected]] that exceed the miter limit, |
| 337 | * the join gets rendered as if it was of type [[email protected]]. |
| 338 | * |
| 339 | * Since: 4.14 |
| 340 | */ |
| 341 | void |
| 342 | gsk_stroke_set_miter_limitcxx . . $ gsk_stroke_set_miter_limit(b98cf12f015ba217). (GskStrokecxx . . $ GskStroke# *self, |
| 343 | float limit) |
| 344 | { |
| 345 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (self != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 346 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (limit >= 0); |
| 347 | |
| 348 | self->miter_limitcxx . . $ _GskStroke#miter_limit. = limit; |
| 349 | } |
| 350 | |
| 351 | /** |
| 352 | * gsk_stroke_get_miter_limit: |
| 353 | * @self: a stroke |
| 354 | * |
| 355 | * Gets the miter limit. |
| 356 | * |
| 357 | * Returns: the miter limit |
| 358 | * |
| 359 | * Since: 4.14 |
| 360 | */ |
| 361 | float |
| 362 | gsk_stroke_get_miter_limitcxx . . $ gsk_stroke_get_miter_limit(b8f15f61b581d68c). (const GskStrokecxx . . $ GskStroke# *self) |
| 363 | { |
| 364 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (self != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 4.f); |
| 365 | |
| 366 | return self->miter_limitcxx . . $ _GskStroke#miter_limit.; |
| 367 | } |
| 368 | |
| 369 | /** |
| 370 | * gsk_stroke_set_dash: |
| 371 | * @self: a stroke |
| 372 | * @dash: (array length=n_dash) (transfer none) (nullable): |
| 373 | * the array of dashes |
| 374 | * @n_dash: number of elements in @dash |
| 375 | * |
| 376 | * Sets the dash pattern to use. |
| 377 | * |
| 378 | * A dash pattern is specified by an array of alternating non-negative |
| 379 | * values. Each value provides the length of alternate "on" and "off" |
| 380 | * portions of the stroke. |
| 381 | * |
| 382 | * Each "on" segment will have caps applied as if the segment were a |
| 383 | * separate contour. In particular, it is valid to use an "on" length |
| 384 | * of 0 with [[email protected]] or [[email protected]] |
| 385 | * to draw dots or squares along a path. |
| 386 | * |
| 387 | * If @n_dash is 0, if all elements in @dash are 0, or if there are |
| 388 | * negative values in @dash, then dashing is disabled. |
| 389 | * |
| 390 | * If @n_dash is 1, an alternating "on" and "off" pattern with the |
| 391 | * single dash length provided is assumed. |
| 392 | * |
| 393 | * If @n_dash is uneven, the dash array will be used with the first |
| 394 | * element in @dash defining an "on" or "off" in alternating passes |
| 395 | * through the array. |
| 396 | * |
| 397 | * You can specify a starting offset into the dash with |
| 398 | * [[email protected]_dash_offset]. |
| 399 | * |
| 400 | * Since: 4.14 |
| 401 | */ |
| 402 | void |
| 403 | gsk_stroke_set_dashcxx . . $ gsk_stroke_set_dash(15b38fd2d7a3c508). (GskStrokecxx . . $ GskStroke# *self, |
| 404 | const float *dash, |
| 405 | gsizecxx . . $ gsize# n_dash) |
| 406 | { |
| 407 | float dash_length; |
| 408 | gsizecxx . . $ gsize# i; |
| 409 | |
| 410 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (self != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 411 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (dash != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || n_dash == 0); |
| 412 | |
| 413 | dash_length = 0; |
| 414 | for (i = 0; i < n_dash; i++) |
| 415 | { |
| 416 | if (!(dash[i] >= 0)) /* should catch NaN */ |
| 417 | { |
| 418 | g_criticalcxx . . $ `<external>/5169755362661750954/gmessages.h:337:9`! ("invalid value in dash array at position %zu", i); |
| 419 | return; |
| 420 | } |
| 421 | dash_length += dash[i]; |
| 422 | } |
| 423 | |
| 424 | self->dash_lengthcxx . . $ _GskStroke#dash_length. = dash_length; |
| 425 | g_freecxx . . $ g_free(5d22bdacc48458e8). (self->dashcxx . . $ _GskStroke#dash.); |
| 426 | self->dashcxx . . $ _GskStroke#dash. = g_memdup2cxx . . $ g_memdup2(7ca5e6a2fd1baf31). (dash, sizeof (gfloatcxx . . $ gfloat#) * n_dash); |
| 427 | self->n_dashcxx . . $ _GskStroke#n_dash. = n_dash; |
| 428 | } |
| 429 | |
| 430 | /** |
| 431 | * gsk_stroke_get_dash: |
| 432 | * @self: a stroke |
| 433 | * @n_dash: (out): number of elements in the array returned |
| 434 | * |
| 435 | * Gets the dash array in use. |
| 436 | * |
| 437 | * Returns: (array length=n_dash) (transfer none) (nullable): |
| 438 | * the dash array or `NULL` if the dash array is empty |
| 439 | * |
| 440 | * Since: 4.14 |
| 441 | */ |
| 442 | const float * |
| 443 | gsk_stroke_get_dashcxx . . $ gsk_stroke_get_dash(362f91e7ef770cbb). (const GskStrokecxx . . $ GskStroke# *self, |
| 444 | gsizecxx . . $ gsize# *n_dash) |
| 445 | { |
| 446 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (self != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 447 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (n_dash != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 448 | |
| 449 | *n_dash = self->n_dashcxx . . $ _GskStroke#n_dash.; |
| 450 | |
| 451 | return self->dashcxx . . $ _GskStroke#dash.; |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * gsk_stroke_set_dash_offset: |
| 456 | * @self: a stroke |
| 457 | * @offset: offset into the dash pattern |
| 458 | * |
| 459 | * Sets the offset into the dash pattern where dashing should begin. |
| 460 | * |
| 461 | * This is an offset into the length of the path, not an index into |
| 462 | * the array values of the dash array. |
| 463 | * |
| 464 | * See [[email protected]_dash] for more details on dashing. |
| 465 | * |
| 466 | * Since: 4.14 |
| 467 | */ |
| 468 | void |
| 469 | gsk_stroke_set_dash_offsetcxx . . $ gsk_stroke_set_dash_offset(b98cf12f015ba217). (GskStrokecxx . . $ GskStroke# *self, |
| 470 | float offset) |
| 471 | { |
| 472 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (self != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 473 | |
| 474 | self->dash_offsetcxx . . $ _GskStroke#dash_offset. = offset; |
| 475 | } |
| 476 | |
| 477 | /** |
| 478 | * gsk_stroke_get_dash_offset: |
| 479 | * @self: a stroke |
| 480 | * |
| 481 | * Gets the dash offset. |
| 482 | * |
| 483 | * Returns: the dash offset |
| 484 | * |
| 485 | * Since: 4.14 |
| 486 | */ |
| 487 | float |
| 488 | gsk_stroke_get_dash_offsetcxx . . $ gsk_stroke_get_dash_offset(b8f15f61b581d68c). (const GskStrokecxx . . $ GskStroke# *self) |
| 489 | { |
| 490 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (self != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 4.f); |
| 491 | |
| 492 | return self->dash_offsetcxx . . $ _GskStroke#dash_offset.; |
| 493 | } |
| 494 | |
| 495 | /*< private > |
| 496 | * gsk_stroke_get_join_width: |
| 497 | * @stroke: a stroke |
| 498 | * |
| 499 | * Returns a width that is sufficient to use |
| 500 | * when calculating stroke bounds around joins |
| 501 | * and caps. |
| 502 | * |
| 503 | * Returns: the join width |
| 504 | */ |
| 505 | float |
| 506 | gsk_stroke_get_join_widthcxx . . $ gsk_stroke_get_join_width(b8f15f61b581d68c). (const GskStrokecxx . . $ GskStroke# *stroke) |
| 507 | { |
| 508 | float width; |
| 509 | |
| 510 | switch (stroke->line_capcxx . . $ _GskStroke#line_cap.) |
| 511 | { |
| 512 | case GSK_LINE_CAP_BUTTcxx . . $ GSK_LINE_CAP_BUTT.: |
| 513 | width = 0; |
| 514 | break; |
| 515 | case GSK_LINE_CAP_ROUNDcxx . . $ GSK_LINE_CAP_ROUND.: |
| 516 | width = stroke->line_widthcxx . . $ _GskStroke#line_width.; |
| 517 | break; |
| 518 | case GSK_LINE_CAP_SQUAREcxx . . $ GSK_LINE_CAP_SQUARE.: |
| 519 | width = G_SQRT2cxx . . $ `<external>/10787549987161854489/gtypes.h:204:9`! * stroke->line_widthcxx . . $ _GskStroke#line_width.; |
| 520 | break; |
| 521 | default: |
| 522 | g_assert_not_reachedcxx . . $ `<external>/15287032793271088244/gtestutils.h:274:9`! (); |
| 523 | } |
| 524 | |
| 525 | switch (stroke->line_joincxx . . $ _GskStroke#line_join.) |
| 526 | { |
| 527 | case GSK_LINE_JOIN_MITERcxx . . $ GSK_LINE_JOIN_MITER.: |
| 528 | width = MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! (width, MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! (stroke->miter_limit, 1.f) * stroke->line_width); |
| 529 | break; |
| 530 | case GSK_LINE_JOIN_ROUNDcxx . . $ GSK_LINE_JOIN_ROUND.: |
| 531 | case GSK_LINE_JOIN_BEVELcxx . . $ GSK_LINE_JOIN_BEVEL.: |
| 532 | width = MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! (width, stroke->line_width); |
| 533 | break; |
| 534 | default: |
| 535 | g_assert_not_reachedcxx . . $ `<external>/15287032793271088244/gtestutils.h:274:9`! (); |
| 536 | } |
| 537 | |
| 538 | return width; |
| 539 | } |