OLD | NEW |
1 SkPaint | 1 SkPaint |
2 ======= | 2 ======= |
3 | 3 |
4 *color, stroke, font, effects* | 4 *color, stroke, font, effects* |
5 | 5 |
6 - [SkXfermode](#SkXfermode) - transfer modes | 6 - [SkXfermode](#SkXfermode) - transfer modes |
7 - [ShShader](#ShShader) - gradients and patterns | 7 - [ShShader](#ShShader) - gradients and patterns |
8 - [SkMaskFilter](#SkMaskFilter) - modifications to the alpha mask | 8 - [SkMaskFilter](#SkMaskFilter) - modifications to the alpha mask |
9 - [SkColorFilter](#SkColorFilter) - modify the source color before applying th
e | 9 - [SkColorFilter](#SkColorFilter) - modify the source color before applying th
e |
10 - [SkPathEffect](#SkPathEffect) - modify to the geometry before it | 10 - [SkPathEffect](#SkPathEffect) - modify to the geometry before it |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 <!--?prettify lang=cc?--> | 26 <!--?prettify lang=cc?--> |
27 | 27 |
28 void draw(SkCanvas* canvas) { | 28 void draw(SkCanvas* canvas) { |
29 canvas->clear(SK_ColorWHITE); | 29 canvas->clear(SK_ColorWHITE); |
30 | 30 |
31 SkPaint paint1, paint2, paint3; | 31 SkPaint paint1, paint2, paint3; |
32 | 32 |
33 paint1.setTextSize(64.0f); | 33 paint1.setTextSize(64.0f); |
34 paint1.setAntiAlias(true); | 34 paint1.setAntiAlias(true); |
35 paint1.setColor(0xFFFF0000); | 35 paint1.setColor(SkColorSetRGB(255, 0, 0); |
36 paint1.setStyle(SkPaint::kFill_Style); | 36 paint1.setStyle(SkPaint::kFill_Style); |
37 | 37 |
38 paint2.setTextSize(64.f); | 38 paint2.setTextSize(64.f); |
39 paint2.setAntiAlias(true); | 39 paint2.setAntiAlias(true); |
40 paint2.setColor(0xFF008800); | 40 paint2.setColor(SkColorSetRGB(0, 136, 0); |
41 paint2.setStyle(SkPaint::kStroke_Style); | 41 paint2.setStyle(SkPaint::kStroke_Style); |
42 paint2.setStrokeWidth(SkIntToScalar(3)); | 42 paint2.setStrokeWidth(SkIntToScalar(3)); |
43 | 43 |
44 paint3.setTextSize(64.0f); | 44 paint3.setTextSize(64.0f); |
45 paint3.setAntiAlias(true); | 45 paint3.setAntiAlias(true); |
46 paint3.setColor(0xFF888888); | 46 paint3.setColor(SkColorSetRGB(136, 136, 136)); |
47 paint3.setTextScaleX(SkFloatToScalar(1.5f)); | 47 paint3.setTextScaleX(SkFloatToScalar(1.5f)); |
48 | 48 |
49 const char text[] = "Skia!"; | 49 const char text[] = "Skia!"; |
50 canvas->drawText(text, strlen(text), 20.0f, 64.0f, paint1); | 50 canvas->drawText(text, strlen(text), 20.0f, 64.0f, paint1); |
51 canvas->drawText(text, strlen(text), 20.0f, 144.0f, paint2); | 51 canvas->drawText(text, strlen(text), 20.0f, 144.0f, paint2); |
52 canvas->drawText(text, strlen(text), 20.0f, 224.0f, paint3); | 52 canvas->drawText(text, strlen(text), 20.0f, 224.0f, paint3); |
53 } | 53 } |
54 | 54 |
55 <a href="https://fiddle.skia.org/c/b8e7991ede1ca88e5458aa1f0039caf9"> | 55 <a href="https://fiddle.skia.org/c/c4cfc71ed9232dac9c0d6518311b386e"> |
56 <img src="https://fiddle.skia.org/i/b8e7991ede1ca88e5458aa1f0039caf9_raster.png"
></a> | 56 <img src="https://fiddle.skia.org/i/c4cfc71ed9232dac9c0d6518311b386e_raster.png"
></a> |
57 | 57 |
58 This shows three different paints, each set up to draw in a different | 58 This shows three different paints, each set up to draw in a different |
59 style. Now the caller can intermix these paints freely, either using | 59 style. Now the caller can intermix these paints freely, either using |
60 them as is, or modifying them as the drawing proceeds. | 60 them as is, or modifying them as the drawing proceeds. |
61 | 61 |
62 <!--?prettify lang=cc?--> | 62 <!--?prettify lang=cc?--> |
63 | 63 |
64 SkPaint paint1, paint2, paint3; | 64 SkPaint paint1, paint2, paint3; |
65 paint2.setStyle(SkPaint::kStroke_Style); | 65 paint2.setStyle(SkPaint::kStroke_Style); |
66 paint2.setStrokeWidth(3); | 66 paint2.setStrokeWidth(3); |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 * SkArcToPathEffect | 597 * SkArcToPathEffect |
598 | 598 |
599 The following few examples use this function: | 599 The following few examples use this function: |
600 | 600 |
601 <!--?prettify lang=cc?--> | 601 <!--?prettify lang=cc?--> |
602 | 602 |
603 SkPath star() { | 603 SkPath star() { |
604 const SkScalar R = 115.2f, C = 128.0f; | 604 const SkScalar R = 115.2f, C = 128.0f; |
605 SkPath path; | 605 SkPath path; |
606 path.moveTo(C + R, C); | 606 path.moveTo(C + R, C); |
607 for (int i = 1; i < 8; ++i) { | 607 for (int i = 1; i < 7; ++i) { |
608 SkScalar a = 2.6927937f * i; | 608 SkScalar a = 2.6927937f * i; |
609 path.lineTo(C + R * cos(a), C + R * sin(a)); | 609 path.lineTo(C + R * cos(a), C + R * sin(a)); |
610 } | 610 } |
| 611 path.close(); |
611 return path; | 612 return path; |
612 } | 613 } |
613 | 614 |
614 <!--?prettify lang=cc?--> | 615 <!--?prettify lang=cc?--> |
615 | 616 |
616 void draw(SkCanvas* canvas) { | 617 void draw(SkCanvas* canvas) { |
617 SkPaint paint; | 618 SkPaint paint; |
618 SkAutoTUnref<SkPathEffect> pe( | 619 SkAutoTUnref<SkPathEffect> pe( |
619 SkArcToPathEffect::Create(8.0f)); | 620 SkArcToPathEffect::Create(8.0f)); |
620 paint.setPathEffect(pe); | 621 paint.setPathEffect(pe); |
(...skipping 17 matching lines...) Expand all Loading... |
638 SkCornerPathEffect::Create(32.0f)); | 639 SkCornerPathEffect::Create(32.0f)); |
639 paint.setPathEffect(pe); | 640 paint.setPathEffect(pe); |
640 paint.setStyle(SkPaint::kStroke_Style); | 641 paint.setStyle(SkPaint::kStroke_Style); |
641 paint.setAntiAlias(true); | 642 paint.setAntiAlias(true); |
642 canvas->clear(SK_ColorWHITE); | 643 canvas->clear(SK_ColorWHITE); |
643 const SkScalar R = 115.2f; | 644 const SkScalar R = 115.2f; |
644 SkPath path(star()); | 645 SkPath path(star()); |
645 canvas->drawPath(path, paint); | 646 canvas->drawPath(path, paint); |
646 } | 647 } |
647 | 648 |
648 <a href="https://fiddle.skia.org/c/272c7c17e295747338200ab62e2051e7"><img sr
c="https://fiddle.skia.org/i/272c7c17e295747338200ab62e2051e7_raster.png" alt=""
></a> | 649 <a href="https://fiddle.skia.org/c/f5361bbb33ad43c656dd40bb03ee2114"><img sr
c="https://fiddle.skia.org/i/f5361bbb33ad43c656dd40bb03ee2114_raster.png" alt=""
></a> |
649 | 650 |
650 * SkDashPathEffect: a path effect that implements dashing. | 651 * SkDashPathEffect: a path effect that implements dashing. |
651 | 652 |
652 <!--?prettify lang=cc?--> | 653 <!--?prettify lang=cc?--> |
653 | 654 |
654 void draw(SkCanvas* canvas) { | 655 void draw(SkCanvas* canvas) { |
655 const SkScalar intervals[] = { 10.0f, 5.0f, 2.0f, 5.0f }; | 656 const SkScalar intervals[] = { 10.0f, 5.0f, 2.0f, 5.0f }; |
656 size_t count = sizeof(intervals) / sizeof(intervals[0]); | 657 size_t count = sizeof(intervals) / sizeof(intervals[0]); |
657 SkAutoTUnref<SkPathEffect> pe( | 658 SkAutoTUnref<SkPathEffect> pe( |
658 SkDashPathEffect::Create(intervals, count, 0.0f)); | 659 SkDashPathEffect::Create(intervals, count, 0.0f)); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 SkPath path(star()); | 737 SkPath path(star()); |
737 canvas->drawPath(path, paint); | 738 canvas->drawPath(path, paint); |
738 } | 739 } |
739 | 740 |
740 <a href="https://fiddle.skia.org/c/e5f7861072893bd08c305a076bf32958"><img sr
c="https://fiddle.skia.org/i/e5f7861072893bd08c305a076bf32958_raster.png" alt=""
></a> | 741 <a href="https://fiddle.skia.org/c/e5f7861072893bd08c305a076bf32958"><img sr
c="https://fiddle.skia.org/i/e5f7861072893bd08c305a076bf32958_raster.png" alt=""
></a> |
741 | 742 |
742 <!-- | 743 <!-- |
743 <a href="https://fiddle.skia.org/c/"><img src="https://fiddle.skia.org/i/_ra
ster.png" alt=""></a> | 744 <a href="https://fiddle.skia.org/c/"><img src="https://fiddle.skia.org/i/_ra
ster.png" alt=""></a> |
744 --> | 745 --> |
745 | 746 |
OLD | NEW |