1 module skia.SKShader; 2 3 import skia.SKObject; 4 import skia.SkiaApi; 5 import skia.SKColorFilter; 6 import skia.SKColor; 7 import skia.SKColorSpace; 8 import skia.SKBitmap; 9 import skia.SKColorF; 10 import skia.SKImage; 11 import skia.SKPicture; 12 import skia.SKMatrix; 13 import skia.Definitions; 14 import skia.MathTypes; 15 import skia.Exceptions; 16 17 18 class SKShader : SKObject 19 { 20 this (void* handle, bool owns) 21 { 22 super (handle, owns); 23 } 24 25 protected override void Dispose (bool disposing) 26 { 27 return super.Dispose (disposing); 28 } 29 30 override void Dispose() 31 { 32 return super.Dispose(); 33 } 34 35 36 // WithColorFilter 37 38 SKShader WithColorFilter (SKColorFilter filter) 39 { 40 if (filter is null) 41 throw new ArgumentNullException (filter.stringof); 42 43 return GetObject (SkiaApi.sk_shader_with_color_filter (cast(sk_shader_t*)Handle, cast(sk_colorfilter_t*)filter.Handle)); 44 } 45 46 // WithLocalMatrix 47 48 SKShader WithLocalMatrix (SKMatrix localMatrix) 49 { 50 return GetObject (SkiaApi.sk_shader_with_local_matrix (cast(sk_shader_t*)Handle, &localMatrix)); 51 } 52 53 54 // CreateEmpty 55 56 static SKShader CreateEmpty () 57 { 58 return GetObject (SkiaApi.sk_shader_new_empty ()); 59 } 60 61 62 // CreateColor 63 64 static SKShader CreateColor (SKColor color) 65 { 66 return GetObject (SkiaApi.sk_shader_new_color (cast(uint)color)); 67 68 } 69 70 static SKShader CreateColor (SKColorF color, SKColorSpace colorspace) 71 { 72 if (colorspace is null) 73 throw new ArgumentNullException (colorspace.stringof); 74 75 return GetObject (SkiaApi.sk_shader_new_color4f (&color, cast(sk_colorspace_t*)colorspace.Handle)); 76 } 77 78 // CreateBitmap 79 80 static SKShader CreateBitmap (SKBitmap src) 81 { 82 return CreateBitmap (src, SKShaderTileMode.Clamp, SKShaderTileMode.Clamp); 83 } 84 85 86 static SKShader CreateBitmap (SKBitmap src, SKShaderTileMode tmx, SKShaderTileMode tmy) 87 { 88 if (src is null) 89 throw new ArgumentNullException (src.stringof); 90 91 return src.ToShader (tmx, tmy); 92 } 93 94 static SKShader CreateBitmap (SKBitmap src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix localMatrix) 95 { 96 if (src is null) 97 throw new ArgumentNullException (src.stringof); 98 99 return src.ToShader (tmx, tmy, localMatrix); 100 } 101 102 // CreateImage 103 104 static SKShader CreateImage (SKImage src) 105 { 106 return CreateImage (src, SKShaderTileMode.Clamp, SKShaderTileMode.Clamp); 107 } 108 109 110 static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy) 111 { 112 if (src is null) 113 throw new ArgumentNullException (src.stringof); 114 115 return src.ToShader (tmx, tmy); 116 } 117 118 static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix localMatrix) 119 { 120 if (src is null) 121 throw new ArgumentNullException (src.stringof); 122 123 return src.ToShader (tmx, tmy, localMatrix); 124 } 125 126 // CreatePicture 127 128 static SKShader CreatePicture (SKPicture src) 129 { 130 return CreatePicture (src, SKShaderTileMode.Clamp, SKShaderTileMode.Clamp); 131 132 } 133 134 static SKShader CreatePicture (SKPicture src, SKShaderTileMode tmx, SKShaderTileMode tmy) 135 { 136 if (src is null) 137 throw new ArgumentNullException (src.stringof); 138 139 return src.ToShader (tmx, tmy); 140 } 141 142 static SKShader CreatePicture (SKPicture src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKRect tile) 143 { 144 if (src is null) 145 throw new ArgumentNullException (src.stringof); 146 147 return src.ToShader (tmx, tmy, tile); 148 } 149 150 static SKShader CreatePicture (SKPicture src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix localMatrix, SKRect tile) 151 { 152 if (src is null) 153 throw new ArgumentNullException (src.stringof); 154 155 return src.ToShader (tmx, tmy, localMatrix, tile); 156 } 157 158 // CreateLinearGradient 159 160 static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColor[] colors, SKShaderTileMode mode) 161 { 162 return CreateLinearGradient (start, end, colors, null, mode); 163 } 164 165 static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColor[] colors, float[] colorPos, SKShaderTileMode mode) 166 { 167 return null; 168 // auto points = new SKPoint[1]; 169 // SKColor* c = colors.ptr; 170 // float* cp = colorPos.ptr; 171 // return GetObject (SkiaApi.sk_shader_new_linear_gradient (points, cast(uint*)c, cp, cast(int)colors.length, mode, null)); 172 } 173 174 // static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColor[] colors, float[] colorPos, SKShaderTileMode mode) 175 // { 176 // if (colors is null) 177 // throw new ArgumentNullException (colors.stringof); 178 // if (colorPos !is null && colors.length != colorPos.length) 179 // throw new ArgumentException ("The number of colors must match the number of color positions."); 180 181 // auto points = stackalloc SKPoint[] { start, end }; 182 // SKColor* c = colors; 183 // float* cp = colorPos; 184 // return GetObject (SkiaApi.sk_shader_new_linear_gradient (points, cast(uint*)c, cp, colors.length, mode, null)); 185 // } 186 187 // static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColor[] colors, float[] colorPos, SKShaderTileMode mode, SKMatrix localMatrix) 188 // { 189 // if (colors is null) 190 // throw new ArgumentNullException (colors.stringof); 191 // if (colorPos !is null && colors.length != colorPos.length) 192 // throw new ArgumentException ("The number of colors must match the number of color positions."); 193 194 // auto points = stackalloc SKPoint[] { start, end }; 195 // SKColor* c = colors; 196 // float* cp = colorPos; 197 // return GetObject (SkiaApi.sk_shader_new_linear_gradient (points, cast(uint*)c, cp, colors.length, mode, &localMatrix)); 198 // } 199 200 static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColorF[] colors, SKColorSpace colorspace, SKShaderTileMode mode) 201 { 202 return CreateLinearGradient (start, end, colors, colorspace, null, mode); 203 } 204 205 206 static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode) 207 { 208 return null; 209 } 210 // static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode) 211 // { 212 // if (colors is null) 213 // throw new ArgumentNullException (colors.stringof); 214 // if (colorPos !is null && colors.length != colorPos.length) 215 // throw new ArgumentException ("The number of colors must match the number of color positions."); 216 217 // auto points = stackalloc SKPoint[] { start, end }; 218 // SKColorF* c = colors; 219 // float* cp = colorPos; 220 // return GetObject (SkiaApi.sk_shader_new_linear_gradient_color4f (points, c, colorspace?.Handle ?? null, cp, colors.length, mode, null)); 221 // } 222 223 // static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode, SKMatrix localMatrix) 224 // { 225 // if (colors is null) 226 // throw new ArgumentNullException (colors.stringof); 227 // if (colorPos !is null && colors.length != colorPos.length) 228 // throw new ArgumentException ("The number of colors must match the number of color positions."); 229 230 // auto points = stackalloc SKPoint[] { start, end }; 231 // SKColorF* c = colors; 232 // float* cp = colorPos; 233 // return GetObject (SkiaApi.sk_shader_new_linear_gradient_color4f (points, c, colorspace?.Handle ?? null, cp, colors.length, mode, &localMatrix)); 234 // } 235 236 // CreateRadialGradient 237 238 static SKShader CreateRadialGradient (SKPoint center, float radius, SKColor[] colors, SKShaderTileMode mode) 239 { 240 return CreateRadialGradient (center, radius, colors, null, mode); 241 } 242 243 static SKShader CreateRadialGradient (SKPoint center, float radius, SKColor[] colors, float[] colorPos, SKShaderTileMode mode) 244 { 245 if (colors is null) 246 throw new ArgumentNullException (colors.stringof); 247 if (colorPos !is null && colors.length != colorPos.length) 248 throw new ArgumentException ("The number of colors must match the number of color positions."); 249 250 SKColor* c = colors.ptr; 251 float* cp = colorPos.ptr; 252 return GetObject (SkiaApi.sk_shader_new_radial_gradient (¢er, radius, cast(uint*)c, cp, cast(int)colors.length, mode, null)); 253 } 254 255 static SKShader CreateRadialGradient (SKPoint center, float radius, SKColor[] colors, float[] colorPos, SKShaderTileMode mode, SKMatrix localMatrix) 256 { 257 if (colors is null) 258 throw new ArgumentNullException (colors.stringof); 259 if (colorPos !is null && colors.length != colorPos.length) 260 throw new ArgumentException ("The number of colors must match the number of color positions."); 261 262 SKColor* c = colors.ptr; 263 float* cp = colorPos.ptr; 264 return GetObject (SkiaApi.sk_shader_new_radial_gradient (¢er, radius, cast(uint*)c, cp, cast(int)colors.length, mode, &localMatrix)); 265 } 266 267 static SKShader CreateRadialGradient (SKPoint center, float radius, SKColorF[] colors, SKColorSpace colorspace, SKShaderTileMode mode) 268 { 269 return CreateRadialGradient (center, radius, colors, colorspace, null, mode); 270 } 271 272 273 static SKShader CreateRadialGradient (SKPoint center, float radius, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode) 274 { 275 if (colors is null) 276 throw new ArgumentNullException (colors.stringof); 277 if (colorPos !is null && colors.length != colorPos.length) 278 throw new ArgumentException ("The number of colors must match the number of color positions."); 279 280 SKColorF* c = colors.ptr; 281 float* cp = colorPos.ptr; 282 return GetObject (SkiaApi.sk_shader_new_radial_gradient_color4f (¢er, radius, c, cast(sk_colorspace_t*)(colorspace.Handle ? colorspace.Handle : null), cp, cast(int)colors.length, mode, null)); 283 } 284 285 static SKShader CreateRadialGradient (SKPoint center, float radius, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode, SKMatrix localMatrix) 286 { 287 if (colors is null) 288 throw new ArgumentNullException (colors.stringof); 289 if (colorPos !is null && colors.length != colorPos.length) 290 throw new ArgumentException ("The number of colors must match the number of color positions."); 291 292 SKColorF* c = colors.ptr; 293 float* cp = colorPos.ptr; 294 return GetObject (SkiaApi.sk_shader_new_radial_gradient_color4f (¢er, radius, c, cast(sk_colorspace_t*)(colorspace.Handle ? colorspace.Handle : null), cp, cast(int)colors.length, mode, &localMatrix)); 295 } 296 297 // CreateSweepGradient 298 299 static SKShader CreateSweepGradient (SKPoint center, SKColor[] colors) 300 { 301 return CreateSweepGradient (center, colors, null, SKShaderTileMode.Clamp, 0, 360); 302 } 303 304 static SKShader CreateSweepGradient (SKPoint center, SKColor[] colors, float[] colorPos) 305 { 306 return CreateSweepGradient (center, colors, colorPos, SKShaderTileMode.Clamp, 0, 360); 307 } 308 309 static SKShader CreateSweepGradient (SKPoint center, SKColor[] colors, float[] colorPos, SKMatrix localMatrix) 310 { 311 return CreateSweepGradient (center, colors, colorPos, SKShaderTileMode.Clamp, 0, 360, localMatrix); 312 } 313 314 static SKShader CreateSweepGradient (SKPoint center, SKColor[] colors, SKShaderTileMode tileMode, float startAngle, float endAngle) 315 { 316 return CreateSweepGradient (center, colors, null, tileMode, startAngle, endAngle); 317 } 318 319 static SKShader CreateSweepGradient (SKPoint center, SKColor[] colors, float[] colorPos, SKShaderTileMode tileMode, float startAngle, float endAngle) 320 { 321 if (colors is null) 322 throw new ArgumentNullException (colors.stringof); 323 if (colorPos !is null && colors.length != colorPos.length) 324 throw new ArgumentException ("The number of colors must match the number of color positions."); 325 326 SKColor* c = colors.ptr; 327 float* cp = colorPos.ptr; 328 return GetObject (SkiaApi.sk_shader_new_sweep_gradient (¢er, cast(uint*)c, cp, cast(int)colors.length, tileMode, startAngle, endAngle, null)); 329 } 330 331 static SKShader CreateSweepGradient (SKPoint center, SKColor[] colors, float[] colorPos, SKShaderTileMode tileMode, float startAngle, float endAngle, SKMatrix localMatrix) 332 { 333 if (colors is null) 334 throw new ArgumentNullException (colors.stringof); 335 if (colorPos !is null && colors.length != colorPos.length) 336 throw new ArgumentException ("The number of colors must match the number of color positions."); 337 338 SKColor* c = colors.ptr; 339 float* cp = colorPos.ptr; 340 return GetObject (SkiaApi.sk_shader_new_sweep_gradient (¢er, cast(uint*)c, cp, cast(int)colors.length, tileMode, startAngle, endAngle, &localMatrix)); 341 } 342 343 static SKShader CreateSweepGradient (SKPoint center, SKColorF[] colors, SKColorSpace colorspace) 344 { 345 return CreateSweepGradient (center, colors, colorspace, null, SKShaderTileMode.Clamp, 0, 360); 346 } 347 348 static SKShader CreateSweepGradient (SKPoint center, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos) 349 { 350 return CreateSweepGradient (center, colors, colorspace, colorPos, SKShaderTileMode.Clamp, 0, 360); 351 } 352 353 static SKShader CreateSweepGradient (SKPoint center, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKMatrix localMatrix) 354 { 355 return CreateSweepGradient (center, colors, colorspace, colorPos, SKShaderTileMode.Clamp, 0, 360, localMatrix); 356 } 357 358 static SKShader CreateSweepGradient (SKPoint center, SKColorF[] colors, SKColorSpace colorspace, SKShaderTileMode tileMode, float startAngle, float endAngle) 359 { 360 return CreateSweepGradient (center, colors, colorspace, null, tileMode, startAngle, endAngle); 361 } 362 363 static SKShader CreateSweepGradient (SKPoint center, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode tileMode, float startAngle, float endAngle) 364 { 365 if (colors is null) 366 throw new ArgumentNullException (colors.stringof); 367 if (colorPos !is null && colors.length != colorPos.length) 368 throw new ArgumentException ("The number of colors must match the number of color positions."); 369 370 SKColorF* c = colors.ptr; 371 float* cp = colorPos.ptr; 372 return GetObject (SkiaApi.sk_shader_new_sweep_gradient_color4f (¢er, c, cast(sk_colorspace_t*)(colorspace.Handle ? colorspace.Handle : null), cp, cast(int)colors.length, tileMode, startAngle, endAngle, null)); 373 } 374 375 static SKShader CreateSweepGradient (SKPoint center, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode tileMode, float startAngle, float endAngle, SKMatrix localMatrix) 376 { 377 if (colors is null) 378 throw new ArgumentNullException (colors.stringof); 379 if (colorPos !is null && colors.length != colorPos.length) 380 throw new ArgumentException ("The number of colors must match the number of color positions."); 381 382 SKColorF* c = colors.ptr; 383 float* cp = colorPos.ptr; 384 return GetObject (SkiaApi.sk_shader_new_sweep_gradient_color4f (¢er, c, cast(sk_colorspace_t*)(colorspace.Handle ? colorspace.Handle : null), cp, cast(int)colors.length, tileMode, startAngle, endAngle, &localMatrix)); 385 } 386 387 // CreateTwoPointConicalGradient 388 389 static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColor[] colors, SKShaderTileMode mode) 390 { 391 return CreateTwoPointConicalGradient (start, startRadius, end, endRadius, colors, null, mode); 392 } 393 394 395 static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColor[] colors, float[] colorPos, SKShaderTileMode mode) 396 { 397 if (colors is null) 398 throw new ArgumentNullException (colors.stringof); 399 if (colorPos !is null && colors.length != colorPos.length) 400 throw new ArgumentException ("The number of colors must match the number of color positions."); 401 402 SKColor* c = colors.ptr; 403 float* cp = colorPos.ptr; 404 return GetObject (SkiaApi.sk_shader_new_two_point_conical_gradient (&start, startRadius, &end, endRadius, cast(uint*)c, cp, cast(int)colors.length, mode, null)); 405 } 406 407 static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColor[] colors, float[] colorPos, SKShaderTileMode mode, SKMatrix localMatrix) 408 { 409 if (colors is null) 410 throw new ArgumentNullException (colors.stringof); 411 if (colorPos !is null && colors.length != colorPos.length) 412 throw new ArgumentException ("The number of colors must match the number of color positions."); 413 414 SKColor* c = colors.ptr; 415 float* cp = colorPos.ptr; 416 return GetObject (SkiaApi.sk_shader_new_two_point_conical_gradient (&start, startRadius, &end, endRadius, cast(uint*)c, cp, cast(int)colors.length, mode, &localMatrix)); 417 } 418 419 static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColorF[] colors, SKColorSpace colorspace, SKShaderTileMode mode) 420 { 421 return CreateTwoPointConicalGradient (start, startRadius, end, endRadius, colors, colorspace, null, mode); 422 } 423 424 425 static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode) 426 { 427 if (colors is null) 428 throw new ArgumentNullException (colors.stringof); 429 if (colorPos !is null && colors.length != colorPos.length) 430 throw new ArgumentException ("The number of colors must match the number of color positions."); 431 432 SKColorF* c = colors.ptr; 433 float* cp = colorPos.ptr; 434 return GetObject (SkiaApi.sk_shader_new_two_point_conical_gradient_color4f (&start, startRadius, &end, endRadius, c, cast(sk_colorspace_t*)(colorspace.Handle ? colorspace.Handle : null), cp, cast(int)colors.length, mode, null)); 435 } 436 437 static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode, SKMatrix localMatrix) 438 { 439 if (colors is null) 440 throw new ArgumentNullException (colors.stringof); 441 if (colorPos !is null && colors.length != colorPos.length) 442 throw new ArgumentException ("The number of colors must match the number of color positions."); 443 444 SKColorF* c = colors.ptr; 445 float* cp = colorPos.ptr; 446 return GetObject (SkiaApi.sk_shader_new_two_point_conical_gradient_color4f (&start, startRadius, &end, endRadius, c, cast(sk_colorspace_t*)(colorspace.Handle ? colorspace.Handle : null), cp, cast(int)colors.length, mode, &localMatrix)); 447 } 448 449 // CreatePerlinNoiseFractalNoise 450 451 static SKShader CreatePerlinNoiseFractalNoise (float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed) 452 { 453 return GetObject (SkiaApi.sk_shader_new_perlin_noise_fractal_noise (baseFrequencyX, baseFrequencyY, numOctaves, seed, null)); 454 } 455 456 static SKShader CreatePerlinNoiseFractalNoise (float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, SKPointI tileSize) 457 { 458 return CreatePerlinNoiseFractalNoise (baseFrequencyX, baseFrequencyY, numOctaves, seed, cast(SKSizeI)tileSize); 459 } 460 461 static SKShader CreatePerlinNoiseFractalNoise (float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, SKSizeI tileSize) 462 { 463 return GetObject (SkiaApi.sk_shader_new_perlin_noise_fractal_noise (baseFrequencyX, baseFrequencyY, numOctaves, seed, &tileSize)); 464 } 465 466 // CreatePerlinNoiseImprovedNoise 467 468 static SKShader CreatePerlinNoiseImprovedNoise (float baseFrequencyX, float baseFrequencyY, int numOctaves, float z) 469 { 470 return GetObject (SkiaApi.sk_shader_new_perlin_noise_improved_noise (baseFrequencyX, baseFrequencyY, numOctaves, z)); 471 } 472 473 474 // CreatePerlinNoiseTurbulence 475 476 static SKShader CreatePerlinNoiseTurbulence (float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed) 477 { 478 return GetObject (SkiaApi.sk_shader_new_perlin_noise_turbulence (baseFrequencyX, baseFrequencyY, numOctaves, seed, null)); 479 } 480 481 static SKShader CreatePerlinNoiseTurbulence (float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, SKPointI tileSize) 482 { 483 return CreatePerlinNoiseTurbulence (baseFrequencyX, baseFrequencyY, numOctaves, seed, cast(SKSizeI)tileSize); 484 } 485 486 static SKShader CreatePerlinNoiseTurbulence (float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, SKSizeI tileSize) 487 { 488 return GetObject (SkiaApi.sk_shader_new_perlin_noise_turbulence (baseFrequencyX, baseFrequencyY, numOctaves, seed, &tileSize)); 489 } 490 491 // CreateCompose 492 493 static SKShader CreateCompose (SKShader shaderA, SKShader shaderB) 494 { 495 return CreateCompose (shaderA, shaderB, SKBlendMode.SrcOver); 496 } 497 498 499 static SKShader CreateCompose (SKShader shaderA, SKShader shaderB, SKBlendMode mode) 500 { 501 if (shaderA is null) 502 throw new ArgumentNullException (shaderA.stringof); 503 if (shaderB is null) 504 throw new ArgumentNullException (shaderB.stringof); 505 506 return GetObject (SkiaApi.sk_shader_new_blend (mode,cast(sk_shader_t*)shaderA.Handle, cast(sk_shader_t*)shaderB.Handle)); 507 } 508 509 // CreateLerp 510 511 static SKShader CreateLerp (float weight, SKShader dst, SKShader src) 512 { 513 if (dst is null) 514 throw new ArgumentNullException (dst.stringof); 515 if (src is null) 516 throw new ArgumentNullException (src.stringof); 517 518 return GetObject (SkiaApi.sk_shader_new_lerp (weight, cast(sk_shader_t*)dst.Handle, cast(sk_shader_t*)src.Handle)); 519 } 520 521 // CreateColorFilter 522 523 static SKShader CreateColorFilter (SKShader shader, SKColorFilter filter) 524 { 525 if (shader is null) 526 throw new ArgumentNullException (shader.stringof); 527 if (filter is null) 528 throw new ArgumentNullException (filter.stringof); 529 530 return shader.WithColorFilter (filter); 531 } 532 533 // CreateLocalMatrix 534 535 static SKShader CreateLocalMatrix (SKShader shader, SKMatrix localMatrix) 536 { 537 if (shader is null) 538 throw new ArgumentNullException (shader.stringof); 539 540 return shader.WithLocalMatrix (localMatrix); 541 } 542 543 static SKShader GetObject (void* handle) 544 { 545 // return GetOrAddObject (handle, (h, o){return new SKShader (h, o);}); 546 return GetOrAddObject!(SKShader)(handle, delegate SKShader (h, o) { return new SKShader (h, o);}); 547 } 548 549 }