| 3276 | } |
| 3277 | |
| 3278 | static void nsvg__parseGradient(NSVGparser* p, const char** attr, char type) |
| 3279 | { |
| 3280 | int i; |
| 3281 | NSVGgradientData* grad = (NSVGgradientData*)AllocateZeroPool(sizeof(NSVGgradientData)); |
| 3282 | if (grad == NULL) return; |
| 3283 | //defaults |
| 3284 | grad->units = NSVG_USER_SPACE; //NSVG_OBJECT_SPACE; |
| 3285 | grad->type = type; |
| 3286 | grad->ditherCoarse = 0; //default value |
| 3287 | if (grad->type == NSVG_PAINT_LINEAR_GRADIENT) { |
| 3288 | grad->direction.linear.x1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); |
| 3289 | grad->direction.linear.y1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); |
| 3290 | grad->direction.linear.x2 = nsvg__coord(100.0f, NSVG_UNITS_PERCENT); |
| 3291 | grad->direction.linear.y2 = nsvg__coord(100.0f, NSVG_UNITS_PERCENT); |
| 3292 | } else if (grad->type == NSVG_PAINT_RADIAL_GRADIENT) { |
| 3293 | grad->direction.radial.cx = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); |
| 3294 | grad->direction.radial.cy = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); |
| 3295 | grad->direction.radial.r = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); |
| 3296 | } else if (grad->type == NSVG_PAINT_CONIC_GRADIENT) { |
| 3297 | grad->direction.radial.cx = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); |
| 3298 | grad->direction.radial.cy = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); |
| 3299 | grad->direction.radial.r = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); |
| 3300 | } |
| 3301 | |
| 3302 | nsvg__xformIdentity(grad->xform); |
| 3303 | |
| 3304 | for (i = 0; attr[i]; i += 2) { |
| 3305 | if (strcmp(attr[i], "xml:id") == 0) { |
| 3306 | // DBG("xml:id ?\n"); |
| 3307 | strncpy(grad->id, attr[i+1], 63); |
| 3308 | grad->id[63] = '\0'; |
| 3309 | } else if (strcmp(attr[i], "id") == 0) { |
| 3310 | strncpy(grad->id, attr[i+1], 63); |
| 3311 | grad->id[63] = '\0'; |
| 3312 | } else if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { |
| 3313 | if (strcmp(attr[i], "gradientUnits") == 0) { |
| 3314 | if (strcmp(attr[i+1], "objectBoundingBox") == 0) |
| 3315 | grad->units = NSVG_OBJECT_SPACE; |
| 3316 | else |
| 3317 | grad->units = NSVG_USER_SPACE; |
| 3318 | } else if (strcmp(attr[i], "gradientTransform") == 0) { |
| 3319 | nsvg__parseTransform(grad->xform, attr[i + 1]); |
| 3320 | } else if (strcmp(attr[i], "cx") == 0) { |
| 3321 | grad->direction.radial.cx = nsvg__parseCoordinateRaw(attr[i + 1]); |
| 3322 | } else if (strcmp(attr[i], "cy") == 0) { |
| 3323 | grad->direction.radial.cy = nsvg__parseCoordinateRaw(attr[i + 1]); |
| 3324 | } else if (strcmp(attr[i], "r") == 0) { |
| 3325 | grad->direction.radial.r = nsvg__parseCoordinateRaw(attr[i + 1]); |
| 3326 | } else if (strcmp(attr[i], "fx") == 0) { |
| 3327 | grad->direction.radial.fx = nsvg__parseCoordinateRaw(attr[i + 1]); |
| 3328 | } else if (strcmp(attr[i], "fy") == 0) { |
| 3329 | grad->direction.radial.fy = nsvg__parseCoordinateRaw(attr[i + 1]); |
| 3330 | } else if (strcmp(attr[i], "x1") == 0) { |
| 3331 | grad->direction.linear.x1 = nsvg__parseCoordinateRaw(attr[i + 1]); |
| 3332 | } else if (strcmp(attr[i], "y1") == 0) { |
| 3333 | grad->direction.linear.y1 = nsvg__parseCoordinateRaw(attr[i + 1]); |
| 3334 | } else if (strcmp(attr[i], "x2") == 0) { |
| 3335 | grad->direction.linear.x2 = nsvg__parseCoordinateRaw(attr[i + 1]); |
no test coverage detected