Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1 | SkPaint Reference |
| 2 | === |
| 3 | |
| 4 | # <a name="Paint"></a> Paint |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5 | <a href="SkPaint_Reference#Paint">Paint</a> controls options applied when drawing and measuring. <a href="SkPaint_Reference#Paint">Paint</a> collects all |
| 6 | options outside of the <a href="SkCanvas_Reference#Clip">Canvas Clip</a> and <a href="SkCanvas_Reference#Matrix">Canvas Matrix</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 7 | |
| 8 | Various options apply to text, strokes and fills, and images. |
| 9 | |
| 10 | Some options may not be implemented on all platforms; in these cases, setting |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 11 | the option has no effect. Some options are conveniences that duplicate <a href="SkCanvas_Reference#Canvas">Canvas</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 12 | functionality; for instance, text size is identical to matrix scale. |
| 13 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 14 | <a href="SkPaint_Reference#Paint">Paint</a> options are rarely exclusive; each option modifies a stage of the drawing |
| 15 | pipeline and multiple pipeline stages may be affected by a single <a href="SkPaint_Reference#Paint">Paint</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 16 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 17 | <a href="SkPaint_Reference#Paint">Paint</a> collects effects and filters that describe single-pass and multiple-pass |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 18 | algorithms that alter the drawing geometry, color, and transparency. For instance, |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 19 | <a href="SkPaint_Reference#Paint">Paint</a> does not directly implement dashing or blur, but contains the objects that do so. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 20 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 21 | The objects contained by <a href="SkPaint_Reference#Paint">Paint</a> are opaque, and cannot be edited outside of the <a href="SkPaint_Reference#Paint">Paint</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 22 | to affect it. The implementation is free to defer computations associated with the |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 23 | <a href="SkPaint_Reference#Paint">Paint</a>, or ignore them altogether. For instance, some <a href="undocumented#GPU">GPU</a> implementations draw all |
| 24 | <a href="SkPath_Reference#Path">Path</a> geometries with anti-aliasing, regardless of how <a href="SkPaint_Reference#kAntiAlias_Flag">SkPaint::kAntiAlias Flag</a> |
| 25 | is set in <a href="SkPaint_Reference#Paint">Paint</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 26 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 27 | <a href="SkPaint_Reference#Paint">Paint</a> describes a single color, a single font, a single image quality, and so on. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 28 | Multiple colors are drawn either by using multiple paints or with objects like |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 29 | <a href="undocumented#Shader">Shader</a> attached to <a href="SkPaint_Reference#Paint">Paint</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 30 | |
| 31 | # <a name="SkPaint"></a> Class SkPaint |
| 32 | |
| 33 | # <a name="Overview"></a> Overview |
| 34 | |
| 35 | ## <a name="Subtopics"></a> Subtopics |
| 36 | |
| 37 | | topics | description | |
| 38 | | --- | --- | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 39 | | <a href="SkPaint_Reference#Initializers">Initializers</a> | Constructors and initialization. | |
| 40 | | <a href="SkPaint_Reference#Destructor">Destructor</a> | <a href="SkPaint_Reference#Paint">Paint</a> termination. | |
| 41 | | <a href="SkPaint_Reference#Management">Management</a> | <a href="SkPaint_Reference#Paint">Paint</a> copying, moving, comparing. | |
| 42 | | <a href="SkPaint_Reference#Hinting">Hinting</a> | <a href="undocumented#Glyph">Glyph</a> outline adjustment. | |
| 43 | | <a href="SkPaint_Reference#Flags">Flags</a> | Attributes represented by single bits. | |
| 44 | | <a href="SkPaint_Reference#Anti_alias">Anti-alias</a> | Approximating coverage with transparency. | |
| 45 | | <a href="SkPaint_Reference#Dither">Dither</a> | Distributing color error. | |
| 46 | | <a href="SkPaint_Reference#Device_Text">Device Text</a> | Increase precision of glyph position. | |
| 47 | | <a href="SkPaint_Reference#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a> | Custom-sized bitmap glyphs. | |
| 48 | | <a href="SkPaint_Reference#Automatic_Hinting">Automatic Hinting</a> | Always adjust glyph paths. | |
| 49 | | <a href="SkPaint_Reference#Vertical_Text">Vertical Text</a> | Orient text from top to bottom. | |
| 50 | | <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a> | Approximate font styles. | |
| 51 | | <a href="SkPaint_Reference#Full_Hinting_Spacing">Full Hinting Spacing</a> | <a href="undocumented#Glyph">Glyph</a> spacing affected by hinting. | |
| 52 | | <a href="SkPaint_Reference#Filter_Quality_Methods">Filter Quality Methods</a> | Get and set <a href="undocumented#Filter_Quality">Filter Quality</a>. | |
| 53 | | <a href="SkPaint_Reference#Color_Methods">Color Methods</a> | Get and set <a href="undocumented#Color">Color</a>. | |
| 54 | | <a href="SkPaint_Reference#Style">Style</a> | Geometry filling, stroking. | |
| 55 | | <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> | Thickness perpendicular to geometry. | |
| 56 | | <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a> | Maximum length of stroked corners. | |
| 57 | | <a href="SkPaint_Reference#Stroke_Cap">Stroke Cap</a> | Decorations at ends of open strokes. | |
| 58 | | <a href="SkPaint_Reference#Stroke_Join">Stroke Join</a> | Decoration at corners of strokes. | |
| 59 | | <a href="SkPaint_Reference#Fill_Path">Fill Path</a> | Make <a href="SkPath_Reference#Path">Path</a> from <a href="undocumented#Path_Effect">Path Effect</a>, stroking. | |
| 60 | | <a href="SkPaint_Reference#Shader_Methods">Shader Methods</a> | Get and set <a href="undocumented#Shader">Shader</a>. | |
| 61 | | <a href="SkPaint_Reference#Color_Filter_Methods">Color Filter Methods</a> | Get and set <a href="undocumented#Color_Filter">Color Filter</a>. | |
| 62 | | <a href="SkPaint_Reference#Blend_Mode_Methods">Blend Mode Methods</a> | Get and set <a href="undocumented#Blend_Mode">Blend Mode</a>. | |
| 63 | | <a href="SkPaint_Reference#Path_Effect_Methods">Path Effect Methods</a> | Get and set <a href="undocumented#Path_Effect">Path Effect</a>. | |
| 64 | | <a href="SkPaint_Reference#Mask_Filter_Methods">Mask Filter Methods</a> | Get and set <a href="undocumented#Mask_Filter">Mask Filter</a>. | |
| 65 | | <a href="SkPaint_Reference#Typeface_Methods">Typeface Methods</a> | Get and set <a href="undocumented#Typeface">Typeface</a>. | |
| 66 | | <a href="SkPaint_Reference#Rasterizer_Methods">Rasterizer Methods</a> | Get and set <a href="undocumented#Rasterizer">Rasterizer</a>. | |
| 67 | | <a href="SkPaint_Reference#Image_Filter_Methods">Image Filter Methods</a> | Get and set <a href="undocumented#Image_Filter">Image Filter</a>. | |
| 68 | | <a href="SkPaint_Reference#Draw_Looper_Methods">Draw Looper Methods</a> | Get and set <a href="undocumented#Draw_Looper">Draw Looper</a>. | |
| 69 | | <a href="SkPaint_Reference#Text_Align">Text Align</a> | <a href="undocumented#Text">Text</a> placement relative to position. | |
| 70 | | <a href="SkPaint_Reference#Text_Size">Text Size</a> | Overall height in points. | |
| 71 | | <a href="SkPaint_Reference#Text_Scale_X">Text Scale X</a> | <a href="undocumented#Text">Text</a> horizontal scale. | |
| 72 | | <a href="SkPaint_Reference#Text_Skew_X">Text Skew X</a> | <a href="undocumented#Text">Text</a> horizontal slant. | |
| 73 | | <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> | <a href="undocumented#Text">Text</a> encoded as characters or glyphs. | |
| 74 | | <a href="SkPaint_Reference#Font_Metrics">Font Metrics</a> | Common glyph dimensions. | |
| 75 | | <a href="SkPaint_Reference#Measure_Text">Measure Text</a> | Width, height, bounds of text. | |
| 76 | | <a href="SkPaint_Reference#Text_Path">Text Path</a> | Geometry of glyphs. | |
| 77 | | <a href="SkPaint_Reference#Text_Intercepts">Text Intercepts</a> | Advanced underline, strike through. | |
| 78 | | <a href="SkPaint_Reference#Fast_Bounds">Fast Bounds</a> | Appproxiate area required by <a href="SkPaint_Reference#Paint">Paint</a>. | |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 79 | |
| 80 | ## <a name="Constants"></a> Constants |
| 81 | |
| 82 | | constants | description | |
| 83 | | --- | --- | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 84 | | <a href="SkPaint_Reference#Align">Align</a> | <a href="undocumented#Glyph">Glyph</a> locations relative to text position. | |
| 85 | | <a href="SkPaint_Reference#Cap">Cap</a> | Start and end geometry on stroked shapes. | |
| 86 | | <a href="SkPaint_Reference#Flags">Flags</a> | Values described by bits and masks. | |
| 87 | | <a href="SkPaint_Reference#FontMetrics_FontMetricsFlags">FontMetrics::FontMetricsFlags</a> | Valid <a href="SkPaint_Reference#Font_Metrics">Font Metrics</a>. | |
| 88 | | <a href="SkPaint_Reference#Hinting">Hinting</a> | Level of glyph outline adjustment. | |
| 89 | | <a href="SkPaint_Reference#Join">Join</a> | Corner geometry on stroked shapes. | |
| 90 | | <a href="SkPaint_Reference#Style">Style</a> | Stroke, fill, or both. | |
| 91 | | <a href="SkPaint_Reference#TextEncoding">TextEncoding</a> | Character or glyph encoding size. | |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 92 | |
| 93 | ## <a name="Structs"></a> Structs |
| 94 | |
| 95 | | struct | description | |
| 96 | | --- | --- | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 97 | | <a href="SkPaint_Reference#FontMetrics">FontMetrics</a> | <a href="undocumented#Typeface">Typeface</a> values. | |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 98 | |
| 99 | ## <a name="Constructors"></a> Constructors |
| 100 | |
| 101 | | | description | |
| 102 | | --- | --- | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 103 | | <a href="SkPaint_Reference#empty_constructor">SkPaint()</a> | Constructs with default values. | |
| 104 | | <a href="SkPaint_Reference#copy_constructor">SkPaint(const SkPaint& paint)</a> | Makes a shallow copy. | |
| 105 | | <a href="SkPaint_Reference#move_constructor">SkPaint(SkPaint&& paint)</a> | Moves paint without copying it. | |
| 106 | | | Decreases <a href="undocumented#Reference_Count">Reference Count</a> of owned objects. | |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 107 | |
| 108 | ## <a name="Operators"></a> Operators |
| 109 | |
| 110 | | operator | description | |
| 111 | | --- | --- | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 112 | | <a href="SkPaint_Reference#copy_assignment_operator">operator=(const SkPaint& paint)</a> | Makes a shallow copy. | |
| 113 | | <a href="SkPaint_Reference#move_assignment_operator">operator=(SkPaint&& paint)</a> | Moves paint without copying it. | |
| 114 | | <a href="SkPaint_Reference#equal_operator">operator==(const SkPaint& a, const SkPaint& b)</a> | Compares paints for equality. | |
| 115 | | <a href="SkPaint_Reference#not_equal_operator">operator!=(const SkPaint& a, const SkPaint& b)</a> | Compares paints for inequality. | |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 116 | |
| 117 | ## <a name="Member_Functions"></a> Member Functions |
| 118 | |
| 119 | | function | description | |
| 120 | | --- | --- | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 121 | | <a href="SkPaint_Reference#breakText">breakText</a> | Returns text that fits in a width. | |
| 122 | | <a href="SkPaint_Reference#canComputeFastBounds">canComputeFastBounds</a> | Returns true if settings allow for fast bounds computation. | |
| 123 | | <a href="SkPaint_Reference#computeFastBounds">computeFastBounds</a> | Returns fill bounds for quick reject tests. | |
| 124 | | <a href="SkPaint_Reference#computeFastStrokeBounds">computeFastStrokeBounds</a> | Returns stroke bounds for quick reject tests. | |
| 125 | | <a href="SkPaint_Reference#containsText">containsText</a> | Returns if all text corresponds to glyphs. | |
| 126 | | <a href="SkPaint_Reference#countText">countText</a> | Returns number of glyphs in text. | |
| 127 | | <a href="SkPaint_Reference#doComputeFastBounds">doComputeFastBounds</a> | Returns bounds for quick reject tests. | |
| 128 | | <a href="SkPaint_Reference#flatten">flatten</a> | Serializes into a buffer. | |
| 129 | | <a href="SkPaint_Reference#getAlpha">getAlpha</a> | Returns <a href="undocumented#Alpha">Color Alpha</a>, color opacity. | |
| 130 | | <a href="SkPaint_Reference#getBlendMode">getBlendMode</a> | Returns <a href="undocumented#Blend_Mode">Blend Mode</a>, how colors combine with dest. | |
| 131 | | <a href="SkPaint_Reference#getColor">getColor</a> | Returns <a href="undocumented#Alpha">Color Alpha</a> and <a href="undocumented#RGB">Color RGB</a>, one drawing color. | |
| 132 | | <a href="SkPaint_Reference#getColorFilter">getColorFilter</a> | Returns <a href="undocumented#Color_Filter">Color Filter</a>, how colors are altered. | |
| 133 | | <a href="SkPaint_Reference#getDrawLooper">getDrawLooper</a> | Returns <a href="undocumented#Draw_Looper">Draw Looper</a>, multiple layers. | |
| 134 | | <a href="SkPaint_Reference#getFillPath">getFillPath</a> | Returns fill path equivalent to stroke. | |
| 135 | | <a href="SkPaint_Reference#getFilterQuality">getFilterQuality</a> | Returns <a href="undocumented#Filter_Quality">Filter Quality</a>, image filtering level. | |
| 136 | | <a href="SkPaint_Reference#getFlags">getFlags</a> | Returns <a href="SkPaint_Reference#Flags">Flags</a> stored in a bit field. | |
| 137 | | <a href="SkPaint_Reference#getFontBounds">getFontBounds</a> | Returns union all glyph bounds. | |
| 138 | | <a href="SkPaint_Reference#getFontMetrics">getFontMetrics</a> | Returns <a href="undocumented#Typeface">Typeface</a> metrics scaled by text size. | |
| 139 | | <a href="SkPaint_Reference#getFontSpacing">getFontSpacing</a> | Returns recommended spacing between lines. | |
| 140 | | <a href="SkPaint_Reference#getHash">getHash</a> | Returns a shallow hash for equality checks. | |
| 141 | | <a href="SkPaint_Reference#getHinting">getHinting</a> | Returns <a href="SkPaint_Reference#Hinting">Hinting</a>, glyph outline adjustment level. | |
| 142 | | <a href="SkPaint_Reference#getImageFilter">getImageFilter</a> | Returns <a href="undocumented#Image_Filter">Image Filter</a>, alter pixels; blur. | |
| 143 | | <a href="SkPaint_Reference#getMaskFilter">getMaskFilter</a> | Returns <a href="undocumented#Mask_Filter">Mask Filter</a>, alterations to <a href="undocumented#Mask_Alpha">Mask Alpha</a>. | |
| 144 | | <a href="SkPaint_Reference#getPathEffect">getPathEffect</a> | Returns <a href="undocumented#Path_Effect">Path Effect</a>, modifications to path geometry; dashing. | |
| 145 | | <a href="SkPaint_Reference#getPosTextPath">getPosTextPath</a> | Returns <a href="SkPath_Reference#Path">Path</a> equivalent to positioned text. | |
| 146 | | <a href="SkPaint_Reference#getPosTextIntercepts">getPosTextIntercepts</a> | Returns where lines intersect positioned text; underlines. | |
| 147 | | <a href="SkPaint_Reference#getPosTextHIntercepts">getPosTextHIntercepts</a> | Returns where lines intersect horizontally positioned text; underlines. | |
| 148 | | <a href="SkPaint_Reference#getRasterizer">getRasterizer</a> | Returns <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Alpha">Mask Alpha</a> generation from <a href="SkPath_Reference#Path">Path</a>. | |
| 149 | | <a href="SkPaint_Reference#getShader">getShader</a> | Returns <a href="undocumented#Shader">Shader</a>, multiple drawing colors; gradients. | |
| 150 | | <a href="SkPaint_Reference#getStrokeCap">getStrokeCap</a> | Returns <a href="SkPaint_Reference#Cap">Cap</a>, the area drawn at path ends. | |
| 151 | | <a href="SkPaint_Reference#getStrokeJoin">getStrokeJoin</a> | Returns <a href="SkPaint_Reference#Join">Join</a>, geometry on path corners. | |
| 152 | | <a href="SkPaint_Reference#getStrokeMiter">getStrokeMiter</a> | Returns <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a>, angles with sharp corners. | |
| 153 | | <a href="SkPaint_Reference#getStrokeWidth">getStrokeWidth</a> | Returns thickness of the stroke. | |
| 154 | | <a href="SkPaint_Reference#getStyle">getStyle</a> | Returns <a href="SkPaint_Reference#Style">Style</a>: stroke, fill, or both. | |
| 155 | | <a href="SkPaint_Reference#getTextAlign">getTextAlign</a> | Returns <a href="SkPaint_Reference#Align">Align</a>: left, center, or right. | |
| 156 | | <a href="SkPaint_Reference#getTextBlobIntercepts">getTextBlobIntercepts</a> | Returns where lines intersect <a href="undocumented#Text_Blob">Text Blob</a>; underlines. | |
| 157 | | <a href="SkPaint_Reference#getTextEncoding">getTextEncoding</a> | Returns character or glyph encoding size. | |
| 158 | | <a href="SkPaint_Reference#getTextIntercepts">getTextIntercepts</a> | Returns where lines intersect text; underlines. | |
| 159 | | <a href="SkPaint_Reference#getTextPath">getTextPath</a> | Returns <a href="SkPath_Reference#Path">Path</a> equivalent to text. | |
| 160 | | <a href="SkPaint_Reference#getTextScaleX">getTextScaleX</a> | Returns the text horizontal scale; condensed text. | |
| 161 | | <a href="SkPaint_Reference#getTextSkewX">getTextSkewX</a> | Returns the text horizontal skew; oblique text. | |
| 162 | | <a href="SkPaint_Reference#getTextSize">getTextSize</a> | Returns text size in points. | |
| 163 | | <a href="SkPaint_Reference#getTextWidths">getTextWidths</a> | Returns advance and bounds for each glyph in text. | |
| 164 | | <a href="SkPaint_Reference#getTypeface">getTypeface</a> | Returns <a href="undocumented#Typeface">Typeface</a>, font description. | |
| 165 | | <a href="SkPaint_Reference#glyphsToUnichars">glyphsToUnichars</a> | Converts glyphs into text. | |
| 166 | | <a href="SkPaint_Reference#isAntiAlias">isAntiAlias</a> | Returns true if <a href="SkPaint_Reference#Anti_alias">Anti-alias</a> is set. | |
| 167 | | <a href="SkPaint_Reference#isAutohinted">isAutohinted</a> | Returns true if glyphs are always hinted. | |
| 168 | | <a href="SkPaint_Reference#isDevKernText">isDevKernText</a> | Returns true if <a href="SkPaint_Reference#Full_Hinting_Spacing">Full Hinting Spacing</a> is set. | |
| 169 | | <a href="SkPaint_Reference#isDither">isDither</a> | Returns true if <a href="SkPaint_Reference#Dither">Dither</a> is set. | |
| 170 | | <a href="SkPaint_Reference#isEmbeddedBitmapText">isEmbeddedBitmapText</a> | Returns true if <a href="SkPaint_Reference#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a> is set. | |
| 171 | | <a href="SkPaint_Reference#isFakeBoldText">isFakeBoldText</a> | Returns true if <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a> is set. | |
| 172 | | <a href="SkPaint_Reference#isLCDRenderText">isLCDRenderText</a> | Returns true if <a href="SkPaint_Reference#LCD_Text">LCD Text</a> is set. | |
| 173 | | <a href="SkPaint_Reference#isSrcOver">isSrcOver</a> | Returns true if <a href="undocumented#Blend_Mode">Blend Mode</a> is <a href="undocumented#kSrcOver">SkBlendMode::kSrcOver</a>. | |
| 174 | | <a href="SkPaint_Reference#isSubpixelText">isSubpixelText</a> | Returns true if <a href="SkPaint_Reference#Subpixel_Text">Subpixel Text</a> is set. | |
| 175 | | <a href="SkPaint_Reference#isVerticalText">isVerticalText</a> | Returns true if <a href="SkPaint_Reference#Vertical_Text">Vertical Text</a> is set. | |
| 176 | | <a href="SkPaint_Reference#measureText">measureText</a> | Returns advance width and bounds of text. | |
| 177 | | <a href="SkPaint_Reference#nothingToDraw">nothingToDraw</a> | Returns true if <a href="SkPaint_Reference#Paint">Paint</a> prevents all drawing. | |
| 178 | | <a href="SkPaint_Reference#refColorFilter">refColorFilter</a> | References <a href="undocumented#Color_Filter">Color Filter</a>, how colors are altered. | |
| 179 | | <a href="SkPaint_Reference#refDrawLooper">refDrawLooper</a> | References <a href="undocumented#Draw_Looper">Draw Looper</a>, multiple layers. | |
| 180 | | <a href="SkPaint_Reference#refImageFilter">refImageFilter</a> | References <a href="undocumented#Image_Filter">Image Filter</a>, alter pixels; blur. | |
| 181 | | <a href="SkPaint_Reference#refMaskFilter">refMaskFilter</a> | References <a href="undocumented#Mask_Filter">Mask Filter</a>, alterations to <a href="undocumented#Mask_Alpha">Mask Alpha</a>. | |
| 182 | | <a href="SkPaint_Reference#refPathEffect">refPathEffect</a> | References <a href="undocumented#Path_Effect">Path Effect</a>, modifications to path geometry; dashing. | |
| 183 | | <a href="SkPaint_Reference#refRasterizer">refRasterizer</a> | References <a href="undocumented#Rasterizer">Rasterizer</a>, mask generation from path. | |
| 184 | | <a href="SkPaint_Reference#refShader">refShader</a> | References <a href="undocumented#Shader">Shader</a>, multiple drawing colors; gradients. | |
| 185 | | <a href="SkPaint_Reference#refTypeface">refTypeface</a> | References <a href="undocumented#Typeface">Typeface</a>, font description. | |
| 186 | | <a href="SkPaint_Reference#reset">reset</a> | Sets to default values. | |
| 187 | | <a href="SkPaint_Reference#setAlpha">setAlpha</a> | Sets <a href="undocumented#Alpha">Color Alpha</a>, color opacity. | |
| 188 | | <a href="SkPaint_Reference#setAntiAlias">setAntiAlias</a> | Sets or clears <a href="SkPaint_Reference#Anti_alias">Anti-alias</a>. | |
| 189 | | <a href="SkPaint_Reference#setARGB">setARGB</a> | Sets color by component. | |
| 190 | | <a href="SkPaint_Reference#setAutohinted">setAutohinted</a> | Sets glyphs to always be hinted. | |
| 191 | | <a href="SkPaint_Reference#setBlendMode">setBlendMode</a> | Sets <a href="undocumented#Blend_Mode">Blend Mode</a>, how colors combine with destination. | |
| 192 | | <a href="SkPaint_Reference#setColor">setColor</a> | Sets <a href="undocumented#Alpha">Color Alpha</a> and <a href="undocumented#RGB">Color RGB</a>, one drawing color. | |
| 193 | | <a href="SkPaint_Reference#setColorFilter">setColorFilter</a> | Sets <a href="undocumented#Color_Filter">Color Filter</a>, alters color. | |
| 194 | | <a href="SkPaint_Reference#setDevKernText">setDevKernText</a> | Sets or clears <a href="SkPaint_Reference#Full_Hinting_Spacing">Full Hinting Spacing</a>. | |
| 195 | | <a href="SkPaint_Reference#setDither">setDither</a> | Sets or clears <a href="SkPaint_Reference#Dither">Dither</a>. | |
| 196 | | <a href="SkPaint_Reference#setDrawLooper">setDrawLooper</a> | Sets <a href="undocumented#Draw_Looper">Draw Looper</a>, multiple layers. | |
| 197 | | <a href="SkPaint_Reference#setEmbeddedBitmapText">setEmbeddedBitmapText</a> | Sets or clears <a href="SkPaint_Reference#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a>. | |
| 198 | | <a href="SkPaint_Reference#setFakeBoldText">setFakeBoldText</a> | Sets or clears <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a>. | |
| 199 | | <a href="SkPaint_Reference#setFilterQuality">setFilterQuality</a> | Sets <a href="undocumented#Filter_Quality">Filter Quality</a>, the image filtering level. | |
| 200 | | <a href="SkPaint_Reference#setFlags">setFlags</a> | Sets multiple <a href="SkPaint_Reference#Flags">Flags</a> in a bit field. | |
| 201 | | <a href="SkPaint_Reference#setHinting">setHinting</a> | Sets <a href="SkPaint_Reference#Hinting">Hinting</a>, glyph outline adjustment level. | |
| 202 | | <a href="SkPaint_Reference#setLCDRenderText">setLCDRenderText</a> | Sets or clears <a href="SkPaint_Reference#LCD_Text">LCD Text</a>. | |
| 203 | | <a href="SkPaint_Reference#setMaskFilter">setMaskFilter</a> | Sets <a href="undocumented#Mask_Filter">Mask Filter</a>, alterations to <a href="undocumented#Mask_Alpha">Mask Alpha</a>. | |
| 204 | | <a href="SkPaint_Reference#setPathEffect">setPathEffect</a> | Sets <a href="undocumented#Path_Effect">Path Effect</a>, modifications to path geometry; dashing. | |
| 205 | | <a href="SkPaint_Reference#setRasterizer">setRasterizer</a> | Sets <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Alpha">Mask Alpha</a> generation from <a href="SkPath_Reference#Path">Path</a>. | |
| 206 | | <a href="SkPaint_Reference#setImageFilter">setImageFilter</a> | Sets <a href="undocumented#Image_Filter">Image Filter</a>, alter pixels; blur. | |
| 207 | | <a href="SkPaint_Reference#setShader">setShader</a> | Sets <a href="undocumented#Shader">Shader</a>, multiple drawing colors; gradients. | |
| 208 | | <a href="SkPaint_Reference#setStrokeCap">setStrokeCap</a> | Sets <a href="SkPaint_Reference#Cap">Cap</a>, the area drawn at path ends. | |
| 209 | | <a href="SkPaint_Reference#setStrokeJoin">setStrokeJoin</a> | Sets <a href="SkPaint_Reference#Join">Join</a>, geometry on path corners. | |
| 210 | | <a href="SkPaint_Reference#setStrokeMiter">setStrokeMiter</a> | Sets <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a>, angles with sharp corners. | |
| 211 | | <a href="SkPaint_Reference#setStrokeWidth">setStrokeWidth</a> | Sets thickness of the stroke. | |
| 212 | | <a href="SkPaint_Reference#setStyle">setStyle</a> | Sets <a href="SkPaint_Reference#Style">Style</a>: stroke, fill, or both. | |
| 213 | | <a href="SkPaint_Reference#setSubpixelText">setSubpixelText</a> | Sets or clears <a href="SkPaint_Reference#Subpixel_Text">Subpixel Text</a>. | |
| 214 | | <a href="SkPaint_Reference#setTextAlign">setTextAlign</a> | Sets <a href="SkPaint_Reference#Align">Align</a>: left, center, or right. | |
| 215 | | <a href="SkPaint_Reference#setTextEncoding">setTextEncoding</a> | Sets character or glyph encoding size. | |
| 216 | | <a href="SkPaint_Reference#setTextScaleX">setTextScaleX</a> | Sets the text horizontal scale; condensed text. | |
| 217 | | <a href="SkPaint_Reference#setTextSkewX">setTextSkewX</a> | Sets the text horizontal skew; oblique text. | |
| 218 | | <a href="SkPaint_Reference#setTextSize">setTextSize</a> | Sets text size in points. | |
| 219 | | <a href="SkPaint_Reference#setTypeface">setTypeface</a> | Sets <a href="undocumented#Typeface">Typeface</a>, font description. | |
| 220 | | <a href="SkPaint_Reference#setVerticalText">setVerticalText</a> | Sets or clears <a href="SkPaint_Reference#Vertical_Text">Vertical Text</a>. | |
| 221 | | <a href="SkPaint_Reference#textToGlyphs">textToGlyphs</a> | Converts text into glyph indices. | |
| 222 | | <a href="SkPaint_Reference#toString">toString</a> | Converts <a href="SkPaint_Reference#Paint">Paint</a> to machine parsable form (<a href="undocumented#Developer_Mode">Developer Mode</a>) | |
| 223 | | <a href="SkPaint_Reference#unflatten">unflatten</a> | Populates from a serialized stream. | |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 224 | |
| 225 | # <a name="Initializers"></a> Initializers |
| 226 | |
| 227 | <a name="empty_constructor"></a> |
| 228 | ## SkPaint |
| 229 | |
| 230 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 231 | SkPaint() |
| 232 | </pre> |
| 233 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 234 | Constructs <a href="SkPaint_Reference#Paint">Paint</a> with default values. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 235 | |
| 236 | | attribute | default value | |
| 237 | | --- | --- | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 238 | | <a href="SkPaint_Reference#Anti_alias">Anti-alias</a> | false | |
| 239 | | <a href="undocumented#Blend_Mode">Blend Mode</a> | <a href="undocumented#kSrcOver">SkBlendMode::kSrcOver</a> | |
| 240 | | <a href="undocumented#Color">Color</a> | <a href="undocumented#SK_ColorBLACK">SK ColorBLACK</a> | |
| 241 | | <a href="undocumented#Alpha">Color Alpha</a> | 255 | |
| 242 | | <a href="undocumented#Color_Filter">Color Filter</a> | nullptr | |
| 243 | | <a href="SkPaint_Reference#Dither">Dither</a> | false | |
| 244 | | <a href="undocumented#Draw_Looper">Draw Looper</a> | nullptr | |
| 245 | | <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a> | false | |
| 246 | | <a href="undocumented#Filter_Quality">Filter Quality</a> | <a href="undocumented#SkFilterQuality">kNone SkFilterQuality</a> | |
| 247 | | <a href="SkPaint_Reference#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a> | false | |
| 248 | | <a href="SkPaint_Reference#Automatic_Hinting">Automatic Hinting</a> | false | |
| 249 | | <a href="SkPaint_Reference#Full_Hinting_Spacing">Full Hinting Spacing</a> | false | |
| 250 | | <a href="SkPaint_Reference#Hinting">Hinting</a> | <a href="SkPaint_Reference#kNormal_Hinting">kNormal Hinting</a> | |
| 251 | | <a href="undocumented#Image_Filter">Image Filter</a> | nullptr | |
| 252 | | <a href="SkPaint_Reference#LCD_Text">LCD Text</a> | false | |
| 253 | | <a href="SkPaint_Reference#Linear_Text">Linear Text</a> | false | |
| 254 | | <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a> | 4 | |
| 255 | | <a href="undocumented#Mask_Filter">Mask Filter</a> | nullptr | |
| 256 | | <a href="undocumented#Path_Effect">Path Effect</a> | nullptr | |
| 257 | | <a href="undocumented#Rasterizer">Rasterizer</a> | nullptr | |
| 258 | | <a href="undocumented#Shader">Shader</a> | nullptr | |
| 259 | | <a href="SkPaint_Reference#Style">Style</a> | <a href="SkPaint_Reference#kFill_Style">kFill Style</a> | |
| 260 | | <a href="SkPaint_Reference#Text_Align">Text Align</a> | <a href="SkPaint_Reference#kLeft_Align">kLeft Align</a> | |
| 261 | | <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> | <a href="SkPaint_Reference#kUTF8_TextEncoding">kUTF8 TextEncoding</a> | |
| 262 | | <a href="SkPaint_Reference#Text_Scale_X">Text Scale X</a> | 1 | |
| 263 | | <a href="SkPaint_Reference#Text_Size">Text Size</a> | 12 | |
| 264 | | <a href="SkPaint_Reference#Text_Skew_X">Text Skew X</a> | 0 | |
| 265 | | <a href="undocumented#Typeface">Typeface</a> | nullptr | |
| 266 | | <a href="SkPaint_Reference#Stroke_Cap">Stroke Cap</a> | <a href="SkPaint_Reference#kButt_Cap">kButt Cap</a> | |
| 267 | | <a href="SkPaint_Reference#Stroke_Join">Stroke Join</a> | <a href="SkPaint_Reference#kMiter_Join">kMiter Join</a> | |
| 268 | | <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> | 0 | |
| 269 | | <a href="SkPaint_Reference#Subpixel_Text">Subpixel Text</a> | false | |
| 270 | | <a href="SkPaint_Reference#Vertical_Text">Vertical Text</a> | false | |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 271 | |
| 272 | The flags, text size, hinting, and miter limit may be overridden at compile time by defining |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 273 | paint default values. The overrides may be included in <a href="undocumented#SkUserConfig.h">SkUserConfig.h</a> or predefined by the |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 274 | build system. |
| 275 | |
| 276 | ### Return Value |
| 277 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 278 | default initialized <a href="SkPaint_Reference#Paint">Paint</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 279 | |
| 280 | ### Example |
| 281 | |
| 282 | <div><fiddle-embed name="c4b2186d85c142a481298f7144295ffd"></fiddle-embed></div> |
| 283 | |
| 284 | --- |
| 285 | |
| 286 | <a name="copy_constructor"></a> |
| 287 | ## SkPaint |
| 288 | |
| 289 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 290 | SkPaint(const SkPaint& paint) |
| 291 | </pre> |
| 292 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 293 | Makes a shallow copy of <a href="SkPaint_Reference#Paint">Paint</a>. <a href="undocumented#Typeface">Typeface</a>, <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Shader">Shader</a>, |
| 294 | <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Draw_Looper">Draw Looper</a>, and <a href="undocumented#Image_Filter">Image Filter</a> are shared |
| 295 | between the original <a href="SkPaint_Reference#paint">paint</a> and the copy. Objects containing <a href="undocumented#Reference_Count">Reference Count</a> increment |
Cary Clark | bad5ad7 | 2017-08-03 17:14:08 -0400 | [diff] [blame] | 296 | their references by one. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 297 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 298 | The referenced objects <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, |
| 299 | <a href="undocumented#Draw_Looper">Draw Looper</a>, and <a href="undocumented#Image_Filter">Image Filter</a> cannot be modified after they are created. |
| 300 | This prevents objects with <a href="undocumented#Reference_Count">Reference Count</a> from being modified once <a href="SkPaint_Reference#Paint">Paint</a> refers to them. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 301 | |
| 302 | ### Parameters |
| 303 | |
| 304 | <table> <tr> <td><code><strong>paint </strong></code></td> <td> |
| 305 | original to copy</td> |
| 306 | </tr> |
| 307 | </table> |
| 308 | |
| 309 | ### Return Value |
| 310 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 311 | shallow copy of <a href="SkPaint_Reference#paint">paint</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 312 | |
| 313 | ### Example |
| 314 | |
| 315 | <div><fiddle-embed name="b99971ad0ef243d617925289d963b62d"> |
| 316 | |
| 317 | #### Example Output |
| 318 | |
| 319 | ~~~~ |
| 320 | SK_ColorRED == paint1.getColor() |
| 321 | SK_ColorBLUE == paint2.getColor() |
| 322 | ~~~~ |
| 323 | |
| 324 | </fiddle-embed></div> |
| 325 | |
| 326 | --- |
| 327 | |
| 328 | <a name="move_constructor"></a> |
| 329 | ## SkPaint |
| 330 | |
| 331 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 332 | SkPaint(SkPaint&& paint) |
| 333 | </pre> |
| 334 | |
| 335 | Implements a move constructor to avoid incrementing the reference counts |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 336 | of objects referenced by the <a href="SkPaint_Reference#paint">paint</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 337 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 338 | After the call, <a href="SkPaint_Reference#paint">paint</a> is undefined, and can be safely destructed. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 339 | |
| 340 | ### Parameters |
| 341 | |
| 342 | <table> <tr> <td><code><strong>paint </strong></code></td> <td> |
| 343 | original to move</td> |
| 344 | </tr> |
| 345 | </table> |
| 346 | |
| 347 | ### Return Value |
| 348 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 349 | content of <a href="SkPaint_Reference#paint">paint</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 350 | |
| 351 | ### Example |
| 352 | |
| 353 | <div><fiddle-embed name="8ed1488a503cd5282b86a51614aa90b1"> |
| 354 | |
| 355 | #### Example Output |
| 356 | |
| 357 | ~~~~ |
| 358 | path effect unique: true |
| 359 | ~~~~ |
| 360 | |
| 361 | </fiddle-embed></div> |
| 362 | |
| 363 | --- |
| 364 | |
| 365 | <a name="reset"></a> |
| 366 | ## reset |
| 367 | |
| 368 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 369 | void reset() |
| 370 | </pre> |
| 371 | |
| 372 | Sets all paint's contents to their initial values. This is equivalent to replacing |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 373 | the paint with the result of <a href="SkPaint_Reference#empty_constructor">SkPaint()</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 374 | |
| 375 | ### Example |
| 376 | |
| 377 | <div><fiddle-embed name="ef269937ade7e7353635121d9a64f9f7"> |
| 378 | |
| 379 | #### Example Output |
| 380 | |
| 381 | ~~~~ |
| 382 | paint1 == paint2 |
| 383 | ~~~~ |
| 384 | |
| 385 | </fiddle-embed></div> |
| 386 | |
| 387 | --- |
| 388 | |
| 389 | # <a name="Destructor"></a> Destructor |
| 390 | |
| 391 | <a name="destructor"></a> |
| 392 | ## ~SkPaint |
| 393 | |
| 394 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 395 | ~SkPaint() |
| 396 | </pre> |
| 397 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 398 | Decreases <a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Reference_Count">Reference Count</a> of owned objects: <a href="undocumented#Typeface">Typeface</a>, <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Shader">Shader</a>, |
| 399 | <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Draw_Looper">Draw Looper</a>, and <a href="undocumented#Image_Filter">Image Filter</a>. If the |
| 400 | objects containing <a href="undocumented#Reference_Count">Reference Count</a> go to zero, they are deleted. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 401 | |
| 402 | --- |
| 403 | |
| 404 | # <a name="Management"></a> Management |
| 405 | |
| 406 | <a name="copy_assignment_operator"></a> |
| 407 | ## operator= |
| 408 | |
| 409 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 410 | SkPaint& operator=(const SkPaint& paint) |
| 411 | </pre> |
| 412 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 413 | Makes a shallow copy of <a href="SkPaint_Reference#Paint">Paint</a>. <a href="undocumented#Typeface">Typeface</a>, <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Shader">Shader</a>, |
| 414 | <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Draw_Looper">Draw Looper</a>, and <a href="undocumented#Image_Filter">Image Filter</a> are shared |
| 415 | between the original <a href="SkPaint_Reference#paint">paint</a> and the copy. Objects containing <a href="undocumented#Reference_Count">Reference Count</a> in the |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 416 | prior destination are decreased by one, and the referenced objects are deleted if the |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 417 | resulting count is zero. Objects containing <a href="undocumented#Reference_Count">Reference Count</a> in the parameter <a href="SkPaint_Reference#paint">paint</a> |
| 418 | are increased by one. <a href="SkPaint_Reference#paint">paint</a> is unmodified. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 419 | |
| 420 | ### Parameters |
| 421 | |
| 422 | <table> <tr> <td><code><strong>paint </strong></code></td> <td> |
| 423 | original to copy</td> |
| 424 | </tr> |
| 425 | </table> |
| 426 | |
| 427 | ### Return Value |
| 428 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 429 | content of <a href="SkPaint_Reference#paint">paint</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 430 | |
| 431 | ### Example |
| 432 | |
| 433 | <div><fiddle-embed name="b476a9088f80dece176ed577807d3992"> |
| 434 | |
| 435 | #### Example Output |
| 436 | |
| 437 | ~~~~ |
| 438 | SK_ColorRED == paint1.getColor() |
| 439 | SK_ColorRED == paint2.getColor() |
| 440 | ~~~~ |
| 441 | |
| 442 | </fiddle-embed></div> |
| 443 | |
| 444 | --- |
| 445 | |
| 446 | <a name="move_assignment_operator"></a> |
| 447 | ## operator= |
| 448 | |
| 449 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 450 | SkPaint& operator=(SkPaint&& paint) |
| 451 | </pre> |
| 452 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 453 | Moves the <a href="SkPaint_Reference#paint">paint</a> to avoid incrementing the reference counts |
| 454 | of objects referenced by the <a href="SkPaint_Reference#paint">paint</a> parameter. Objects containing <a href="undocumented#Reference_Count">Reference Count</a> in the |
Cary Clark | bad5ad7 | 2017-08-03 17:14:08 -0400 | [diff] [blame] | 455 | prior destination are decreased by one; those objects are deleted if the resulting count |
| 456 | is zero. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 457 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 458 | After the call, <a href="SkPaint_Reference#paint">paint</a> is undefined, and can be safely destructed. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 459 | |
| 460 | ### Parameters |
| 461 | |
| 462 | <table> <tr> <td><code><strong>paint </strong></code></td> <td> |
| 463 | original to move</td> |
| 464 | </tr> |
| 465 | </table> |
| 466 | |
| 467 | ### Return Value |
| 468 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 469 | content of <a href="SkPaint_Reference#paint">paint</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 470 | |
| 471 | ### Example |
| 472 | |
| 473 | <div><fiddle-embed name="9fb7459b097d713f5f1fe5675afe14f5"> |
| 474 | |
| 475 | #### Example Output |
| 476 | |
| 477 | ~~~~ |
| 478 | SK_ColorRED == paint2.getColor() |
| 479 | ~~~~ |
| 480 | |
| 481 | </fiddle-embed></div> |
| 482 | |
| 483 | --- |
| 484 | |
| 485 | <a name="equal_operator"></a> |
| 486 | ## operator== |
| 487 | |
| 488 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 489 | bool operator==(const SkPaint& a, const SkPaint& b) |
| 490 | </pre> |
| 491 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 492 | Compares <a href="SkPaint_Reference#a">a</a> and <a href="SkPaint_Reference#b">b</a>, and returns true if <a href="SkPaint_Reference#a">a</a> and <a href="SkPaint_Reference#b">b</a> are equivalent. May return false |
| 493 | if <a href="undocumented#Typeface">Typeface</a>, <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, |
| 494 | <a href="undocumented#Draw_Looper">Draw Looper</a>, or <a href="undocumented#Image_Filter">Image Filter</a> have identical contents but different pointers. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 495 | |
| 496 | ### Parameters |
| 497 | |
| 498 | <table> <tr> <td><code><strong>a </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 499 | <a href="SkPaint_Reference#Paint">Paint</a> to compare</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 500 | </tr> <tr> <td><code><strong>b </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 501 | <a href="SkPaint_Reference#Paint">Paint</a> to compare</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 502 | </tr> |
| 503 | </table> |
| 504 | |
| 505 | ### Return Value |
| 506 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 507 | true if <a href="SkPaint_Reference#Paint">Paint</a> pair are equivalent |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 508 | |
| 509 | ### Example |
| 510 | |
| 511 | <div><fiddle-embed name="7481a948e34672720337a631830586dd"> |
| 512 | |
| 513 | #### Example Output |
| 514 | |
| 515 | ~~~~ |
| 516 | paint1 == paint2 |
| 517 | paint1 != paint2 |
| 518 | ~~~~ |
| 519 | |
| 520 | </fiddle-embed></div> |
| 521 | |
| 522 | --- |
| 523 | |
| 524 | <a name="not_equal_operator"></a> |
| 525 | ## operator!= |
| 526 | |
| 527 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 528 | bool operator!=(const SkPaint& a, const SkPaint& b) |
| 529 | </pre> |
| 530 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 531 | Compares <a href="SkPaint_Reference#a">a</a> and <a href="SkPaint_Reference#b">b</a>, and returns true if <a href="SkPaint_Reference#a">a</a> and <a href="SkPaint_Reference#b">b</a> are not equivalent. May return true |
| 532 | if <a href="undocumented#Typeface">Typeface</a>, <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, |
| 533 | <a href="undocumented#Draw_Looper">Draw Looper</a>, or <a href="undocumented#Image_Filter">Image Filter</a> have identical contents but different pointers. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 534 | |
| 535 | ### Parameters |
| 536 | |
| 537 | <table> <tr> <td><code><strong>a </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 538 | <a href="SkPaint_Reference#Paint">Paint</a> to compare</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 539 | </tr> <tr> <td><code><strong>b </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 540 | <a href="SkPaint_Reference#Paint">Paint</a> to compare</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 541 | </tr> |
| 542 | </table> |
| 543 | |
| 544 | ### Return Value |
| 545 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 546 | true if <a href="SkPaint_Reference#Paint">Paint</a> pair are not equivalent |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 547 | |
| 548 | ### Example |
| 549 | |
| 550 | <div><fiddle-embed name="b6c8484b1187f555b435ad5369833be4"> |
| 551 | |
| 552 | #### Example Output |
| 553 | |
| 554 | ~~~~ |
| 555 | paint1 == paint2 |
| 556 | paint1 == paint2 |
| 557 | ~~~~ |
| 558 | |
| 559 | </fiddle-embed></div> |
| 560 | |
| 561 | --- |
| 562 | |
| 563 | <a name="getHash"></a> |
| 564 | ## getHash |
| 565 | |
| 566 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 567 | uint32_t getHash() const |
| 568 | </pre> |
| 569 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 570 | Returns a hash generated from <a href="SkPaint_Reference#Paint">Paint</a> values and pointers. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 571 | Identical hashes guarantee that the paints are |
| 572 | equivalent, but differing hashes do not guarantee that the paints have differing |
| 573 | contents. |
| 574 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 575 | If <a href="SkPaint_Reference#equal_operator">operator==(const SkPaint& a, const SkPaint& b)</a> returns true for two paints, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 576 | their hashes are also equal. |
| 577 | |
| 578 | The hash returned is platform and implementation specific. |
| 579 | |
| 580 | ### Return Value |
| 581 | |
| 582 | a shallow hash |
| 583 | |
| 584 | ### Example |
| 585 | |
| 586 | <div><fiddle-embed name="7f7e1b701361912b344f90ae6b530393"> |
| 587 | |
| 588 | #### Example Output |
| 589 | |
| 590 | ~~~~ |
| 591 | paint1 == paint2 |
| 592 | paint1.getHash() == paint2.getHash() |
| 593 | ~~~~ |
| 594 | |
| 595 | </fiddle-embed></div> |
| 596 | |
| 597 | --- |
| 598 | |
| 599 | <a name="flatten"></a> |
| 600 | ## flatten |
| 601 | |
| 602 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 603 | void flatten(SkWriteBuffer& buffer) const |
| 604 | </pre> |
| 605 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 606 | Serializes <a href="SkPaint_Reference#Paint">Paint</a> into a <a href="SkPaint_Reference#buffer">buffer</a>. A companion <a href="SkPaint_Reference#unflatten">unflatten</a> call |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 607 | can reconstitute the paint at a later time. |
| 608 | |
| 609 | ### Parameters |
| 610 | |
| 611 | <table> <tr> <td><code><strong>buffer </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 612 | <a href="undocumented#Write_Buffer">Write Buffer</a> receiving the flattened <a href="SkPaint_Reference#Paint">Paint</a> data</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 613 | </tr> |
| 614 | </table> |
| 615 | |
| 616 | ### Example |
| 617 | |
| 618 | <div><fiddle-embed name="670672b146b50eced4d3dd10c701e0a7"> |
| 619 | |
| 620 | #### Example Output |
| 621 | |
| 622 | ~~~~ |
| 623 | color = 0xffff0000 |
| 624 | ~~~~ |
| 625 | |
| 626 | </fiddle-embed></div> |
| 627 | |
| 628 | --- |
| 629 | |
| 630 | <a name="unflatten"></a> |
| 631 | ## unflatten |
| 632 | |
| 633 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 634 | void unflatten(SkReadBuffer& buffer) |
| 635 | </pre> |
| 636 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 637 | Populates <a href="SkPaint_Reference#Paint">Paint</a>, typically from a serialized stream, created by calling |
| 638 | <a href="SkPaint_Reference#flatten">flatten</a> at an earlier time. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 639 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 640 | <a href="undocumented#SkReadBuffer">SkReadBuffer</a> class is not public, so <a href="SkPaint_Reference#unflatten">unflatten</a> cannot be meaningfully called |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 641 | by the client. |
| 642 | |
| 643 | ### Parameters |
| 644 | |
| 645 | <table> <tr> <td><code><strong>buffer </strong></code></td> <td> |
| 646 | serialized data to unflatten</td> |
| 647 | </tr> |
| 648 | </table> |
| 649 | |
| 650 | --- |
| 651 | |
| 652 | # <a name="Hinting"></a> Hinting |
| 653 | |
| 654 | ## <a name="SkPaint::Hinting"></a> Enum SkPaint::Hinting |
| 655 | |
| 656 | <pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0"> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 657 | enum <a href="SkPaint_Reference#Hinting">Hinting</a> { |
| 658 | <a href="SkPaint_Reference#kNo_Hinting">kNo Hinting</a> = 0, |
| 659 | <a href="SkPaint_Reference#kSlight_Hinting">kSlight Hinting</a> = 1, |
| 660 | <a href="SkPaint_Reference#kNormal_Hinting">kNormal Hinting</a> = 2, |
| 661 | <a href="SkPaint_Reference#kFull_Hinting">kFull Hinting</a> = 3, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 662 | };</pre> |
| 663 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 664 | <a href="SkPaint_Reference#Hinting">Hinting</a> adjusts the glyph outlines so that the shape provides a uniform |
| 665 | look at a given point size on font engines that support it. <a href="SkPaint_Reference#Hinting">Hinting</a> may have a |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 666 | muted effect or no effect at all depending on the platform. |
| 667 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 668 | The four levels roughly control corresponding features on platforms that use <a href="undocumented#FreeType">FreeType</a> |
| 669 | as the <a href="undocumented#Engine">Font Engine</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 670 | |
| 671 | ### Constants |
| 672 | |
| 673 | <table> |
| 674 | <tr> |
| 675 | <td><a name="SkPaint::kNo_Hinting"></a> <code><strong>SkPaint::kNo_Hinting </strong></code></td><td>0</td><td>Leaves glyph outlines unchanged from their native representation. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 676 | With <a href="undocumented#FreeType">FreeType</a>, this is equivalent to the <a href="undocumented#FT_LOAD_NO_HINTING">FT LOAD NO HINTING</a> |
| 677 | bit-field constant supplied to <a href="undocumented#FT_Load_Glyph">FT Load Glyph</a>, which indicates that the vector |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 678 | outline being loaded should not be fitted to the pixel grid but simply scaled |
| 679 | to 26.6 fractional pixels.</td> |
| 680 | </tr> |
| 681 | <tr> |
| 682 | <td><a name="SkPaint::kSlight_Hinting"></a> <code><strong>SkPaint::kSlight_Hinting </strong></code></td><td>1</td><td>Modifies glyph outlines minimally to improve constrast. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 683 | With <a href="undocumented#FreeType">FreeType</a>, this is equivalent in spirit to the |
| 684 | <a href="undocumented#FT_LOAD_TARGET_LIGHT">FT LOAD TARGET LIGHT</a> value supplied to <a href="undocumented#FT_Load_Glyph">FT Load Glyph</a>. It chooses a |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 685 | lighter hinting algorithm for non-monochrome modes. |
| 686 | Generated glyphs may be fuzzy but better resemble their original shape.</td> |
| 687 | </tr> |
| 688 | <tr> |
| 689 | <td><a name="SkPaint::kNormal_Hinting"></a> <code><strong>SkPaint::kNormal_Hinting </strong></code></td><td>2</td><td>Modifies glyph outlines to improve constrast. This is the default. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 690 | With <a href="undocumented#FreeType">FreeType</a>, this supplies <a href="undocumented#FT_LOAD_TARGET_NORMAL">FT LOAD TARGET NORMAL</a> to <a href="undocumented#FT_Load_Glyph">FT Load Glyph</a>, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 691 | choosing the default hinting algorithm, which is optimized for standard |
| 692 | gray-level rendering.</td> |
| 693 | </tr> |
| 694 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 695 | <td><a name="SkPaint::kFull_Hinting"></a> <code><strong>SkPaint::kFull_Hinting </strong></code></td><td>3</td><td>Modifies glyph outlines for maxiumum constrast. With <a href="undocumented#FreeType">FreeType</a>, this selects |
| 696 | <a href="undocumented#FT_LOAD_TARGET_LCD">FT LOAD TARGET LCD</a> or <a href="undocumented#FT_LOAD_TARGET_LCD_V">FT LOAD TARGET LCD V</a> if <a href="SkPaint_Reference#kLCDRenderText_Flag">kLCDRenderText Flag</a> is set. |
| 697 | <a href="undocumented#FT_LOAD_TARGET_LCD">FT LOAD TARGET LCD</a> is a variant of <a href="undocumented#FT_LOAD_TARGET_NORMAL">FT LOAD TARGET NORMAL</a> optimized for |
| 698 | horizontally decimated <a href="undocumented#LCD">LCD</a> displays; <a href="undocumented#FT_LOAD_TARGET_LCD_V">FT LOAD TARGET LCD V</a> is a |
| 699 | variant of <a href="undocumented#FT_LOAD_TARGET_NORMAL">FT LOAD TARGET NORMAL</a> optimized for vertically decimated <a href="undocumented#LCD">LCD</a> displays.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 700 | </tr> |
| 701 | </table> |
| 702 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 703 | On <a href="undocumented#Windows">Windows</a> with <a href="undocumented#DirectWrite">DirectWrite</a>, <a href="SkPaint_Reference#Hinting">Hinting</a> has no effect. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 704 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 705 | <a href="SkPaint_Reference#Hinting">Hinting</a> defaults to <a href="SkPaint_Reference#kNormal_Hinting">kNormal Hinting</a>. |
| 706 | Set <a href="undocumented#SkPaintDefaults_Hinting">SkPaintDefaults Hinting</a> at compile time to change the default setting. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 707 | |
| 708 | |
| 709 | |
| 710 | <a name="getHinting"></a> |
| 711 | ## getHinting |
| 712 | |
| 713 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 714 | Hinting getHinting() const |
| 715 | </pre> |
| 716 | |
| 717 | Returns level of glyph outline adjustment. |
| 718 | |
| 719 | ### Return Value |
| 720 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 721 | one of: <a href="SkPaint_Reference#kNo_Hinting">kNo Hinting</a>, <a href="SkPaint_Reference#kSlight_Hinting">kSlight Hinting</a>, <a href="SkPaint_Reference#kNormal_Hinting">kNormal Hinting</a>, <a href="SkPaint_Reference#kFull_Hinting">kFull Hinting</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 722 | |
| 723 | ### Example |
| 724 | |
| 725 | <div><fiddle-embed name="329e2e5a5919ac431e1c58878a5b99e0"> |
| 726 | |
| 727 | #### Example Output |
| 728 | |
| 729 | ~~~~ |
| 730 | SkPaint::kNormal_Hinting == paint.getHinting() |
| 731 | ~~~~ |
| 732 | |
| 733 | </fiddle-embed></div> |
| 734 | |
| 735 | --- |
| 736 | |
| 737 | <a name="setHinting"></a> |
| 738 | ## setHinting |
| 739 | |
| 740 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 741 | void setHinting(Hinting hintingLevel) |
| 742 | </pre> |
| 743 | |
| 744 | Sets level of glyph outline adjustment. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 745 | Does not check for valid values of <a href="SkPaint_Reference#hintingLevel">hintingLevel</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 746 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 747 | | <a href="SkPaint_Reference#Hinting">Hinting</a> | value | effect on generated glyph outlines | |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 748 | | --- | --- | --- | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 749 | | <a href="SkPaint_Reference#kNo_Hinting">kNo Hinting</a> | 0 | leaves glyph outlines unchanged from their native representation | |
| 750 | | <a href="SkPaint_Reference#kSlight_Hinting">kSlight Hinting</a> | 1 | modifies glyph outlines minimally to improve constrast | |
| 751 | | <a href="SkPaint_Reference#kNormal_Hinting">kNormal Hinting</a> | 2 | modifies glyph outlines to improve constrast | |
| 752 | | <a href="SkPaint_Reference#kFull_Hinting">kFull Hinting</a> | 3 | modifies glyph outlines for maxiumum constrast | |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 753 | |
| 754 | ### Parameters |
| 755 | |
| 756 | <table> <tr> <td><code><strong>hintingLevel </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 757 | one of: <a href="SkPaint_Reference#kNo_Hinting">kNo Hinting</a>, <a href="SkPaint_Reference#kSlight_Hinting">kSlight Hinting</a>, <a href="SkPaint_Reference#kNormal_Hinting">kNormal Hinting</a>, <a href="SkPaint_Reference#kFull_Hinting">kFull Hinting</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 758 | </tr> |
| 759 | </table> |
| 760 | |
| 761 | ### Example |
| 762 | |
| 763 | <div><fiddle-embed name="78153fbd3f1000cb33b97bbe831ed34e"> |
| 764 | |
| 765 | #### Example Output |
| 766 | |
| 767 | ~~~~ |
| 768 | paint1 == paint2 |
| 769 | ~~~~ |
| 770 | |
| 771 | </fiddle-embed></div> |
| 772 | |
| 773 | --- |
| 774 | |
| 775 | # <a name="Flags"></a> Flags |
| 776 | |
| 777 | ## <a name="SkPaint::Flags"></a> Enum SkPaint::Flags |
| 778 | |
| 779 | <pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0"> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 780 | enum <a href="SkPaint_Reference#Flags">Flags</a> { |
| 781 | <a href="SkPaint_Reference#kAntiAlias_Flag">kAntiAlias Flag</a> = 0x01, |
| 782 | <a href="SkPaint_Reference#kDither_Flag">kDither Flag</a> = 0x04, |
| 783 | <a href="SkPaint_Reference#kFakeBoldText_Flag">kFakeBoldText Flag</a> = 0x20, |
| 784 | <a href="SkPaint_Reference#kLinearText_Flag">kLinearText Flag</a> = 0x40, |
| 785 | <a href="SkPaint_Reference#kSubpixelText_Flag">kSubpixelText Flag</a> = 0x80, |
| 786 | <a href="SkPaint_Reference#kDevKernText_Flag">kDevKernText Flag</a> = 0x100, |
| 787 | <a href="SkPaint_Reference#kLCDRenderText_Flag">kLCDRenderText Flag</a> = 0x200, |
| 788 | <a href="SkPaint_Reference#kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> = 0x400, |
| 789 | <a href="SkPaint_Reference#kAutoHinting_Flag">kAutoHinting Flag</a> = 0x800, |
| 790 | <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> = 0x1000, |
| 791 | <a href="SkPaint_Reference#kGenA8FromLCD_Flag">kGenA8FromLCD Flag</a> = 0x2000, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 792 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 793 | <a href="SkPaint_Reference#kAllFlags">kAllFlags</a> = 0xFFFF, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 794 | }; |
| 795 | </pre> |
| 796 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 797 | The bit values stored in <a href="SkPaint_Reference#Flags">Flags</a>. |
| 798 | The default value for <a href="SkPaint_Reference#Flags">Flags</a>, normally zero, can be changed at compile time |
| 799 | with a custom definition of <a href="undocumented#SkPaintDefaults_Flags">SkPaintDefaults Flags</a>. |
| 800 | All flags can be read and written explicitly; <a href="SkPaint_Reference#Flags">Flags</a> allows manipulating |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 801 | multiple settings at once. |
| 802 | |
| 803 | ### Constants |
| 804 | |
| 805 | <table> |
| 806 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 807 | <td><a name="SkPaint::kAntiAlias_Flag"></a> <code><strong>SkPaint::kAntiAlias_Flag </strong></code></td><td>0x0001 </td><td>mask for setting <a href="SkPaint_Reference#Anti_alias">Anti-alias</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 808 | </tr> |
| 809 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 810 | <td><a name="SkPaint::kDither_Flag"></a> <code><strong>SkPaint::kDither_Flag </strong></code></td><td>0x0004</td><td>mask for setting <a href="SkPaint_Reference#Dither">Dither</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 811 | </tr> |
| 812 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 813 | <td><a name="SkPaint::kFakeBoldText_Flag"></a> <code><strong>SkPaint::kFakeBoldText_Flag </strong></code></td><td>0x0020</td><td>mask for setting <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 814 | </tr> |
| 815 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 816 | <td><a name="SkPaint::kLinearText_Flag"></a> <code><strong>SkPaint::kLinearText_Flag </strong></code></td><td>0x0040</td><td>mask for setting <a href="SkPaint_Reference#Linear_Text">Linear Text</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 817 | </tr> |
| 818 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 819 | <td><a name="SkPaint::kSubpixelText_Flag"></a> <code><strong>SkPaint::kSubpixelText_Flag </strong></code></td><td>0x0080</td><td>mask for setting <a href="SkPaint_Reference#Subpixel_Text">Subpixel Text</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 820 | </tr> |
| 821 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 822 | <td><a name="SkPaint::kDevKernText_Flag"></a> <code><strong>SkPaint::kDevKernText_Flag </strong></code></td><td>0x0100</td><td>mask for setting <a href="SkPaint_Reference#Full_Hinting_Spacing">Full Hinting Spacing</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 823 | </tr> |
| 824 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 825 | <td><a name="SkPaint::kLCDRenderText_Flag"></a> <code><strong>SkPaint::kLCDRenderText_Flag </strong></code></td><td>0x0200</td><td>mask for setting <a href="SkPaint_Reference#LCD_Text">LCD Text</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 826 | </tr> |
| 827 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 828 | <td><a name="SkPaint::kEmbeddedBitmapText_Flag"></a> <code><strong>SkPaint::kEmbeddedBitmapText_Flag </strong></code></td><td>0x0400</td><td>mask for setting <a href="SkPaint_Reference#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 829 | </tr> |
| 830 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 831 | <td><a name="SkPaint::kAutoHinting_Flag"></a> <code><strong>SkPaint::kAutoHinting_Flag </strong></code></td><td>0x0800</td><td>mask for setting <a href="SkPaint_Reference#Automatic_Hinting">Automatic Hinting</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 832 | </tr> |
| 833 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 834 | <td><a name="SkPaint::kVerticalText_Flag"></a> <code><strong>SkPaint::kVerticalText_Flag </strong></code></td><td>0x1000</td><td>mask for setting <a href="SkPaint_Reference#Vertical_Text">Vertical Text</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 835 | </tr> |
| 836 | <tr> |
| 837 | <td><a name="SkPaint::kGenA8FromLCD_Flag"></a> <code><strong>SkPaint::kGenA8FromLCD_Flag </strong></code></td><td>0x2000</td><td>not intended for public use</td> |
| 838 | </tr> |
| 839 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 840 | <td><a name="SkPaint::kAllFlags"></a> <code><strong>SkPaint::kAllFlags </strong></code></td><td>0xFFFF</td><td>mask of all <a href="SkPaint_Reference#Flags">Flags</a>, including private flags and flags reserved for future use</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 841 | </tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 842 | <a href="SkPaint_Reference#Flags">Flags</a> default to all flags clear, disabling the associated feature. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 843 | |
| 844 | </table> |
| 845 | |
| 846 | ## <a name="SkPaint::ReserveFlags"></a> Enum SkPaint::ReserveFlags |
| 847 | |
| 848 | <pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0"> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 849 | enum <a href="SkPaint_Reference#ReserveFlags">ReserveFlags</a> { |
| 850 | <a href="SkPaint_Reference#kUnderlineText_ReserveFlag">kUnderlineText ReserveFlag</a> = 0x08, |
| 851 | <a href="SkPaint_Reference#kStrikeThruText_ReserveFlag">kStrikeThruText ReserveFlag</a> = 0x10, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 852 | };</pre> |
| 853 | |
| 854 | ### Constants |
| 855 | |
| 856 | <table> |
| 857 | <tr> |
| 858 | <td><a name="SkPaint::kUnderlineText_ReserveFlag"></a> <code><strong>SkPaint::kUnderlineText_ReserveFlag </strong></code></td><td>0x0008</td><td>mask for underline text</td> |
| 859 | </tr> |
| 860 | <tr> |
| 861 | <td><a name="SkPaint::kStrikeThruText_ReserveFlag"></a> <code><strong>SkPaint::kStrikeThruText_ReserveFlag </strong></code></td><td>0x0010</td><td>mask for strike-thru text</td> |
| 862 | </tr> |
| 863 | </table> |
| 864 | |
| 865 | |
| 866 | |
| 867 | <a name="getFlags"></a> |
| 868 | ## getFlags |
| 869 | |
| 870 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 871 | uint32_t getFlags() const |
| 872 | </pre> |
| 873 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 874 | Returns paint settings described by <a href="SkPaint_Reference#Flags">Flags</a>. Each setting uses one |
| 875 | bit, and can be tested with <a href="SkPaint_Reference#Flags">Flags</a> members. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 876 | |
| 877 | ### Return Value |
| 878 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 879 | zero, one, or more bits described by <a href="SkPaint_Reference#Flags">Flags</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 880 | |
| 881 | ### Example |
| 882 | |
| 883 | <div><fiddle-embed name="8a3f8c309533388b01aa66e1267f322d"> |
| 884 | |
| 885 | #### Example Output |
| 886 | |
| 887 | ~~~~ |
| 888 | (SkPaint::kAntiAlias_Flag & paint.getFlags()) != 0 |
| 889 | ~~~~ |
| 890 | |
| 891 | </fiddle-embed></div> |
| 892 | |
| 893 | --- |
| 894 | |
| 895 | <a name="setFlags"></a> |
| 896 | ## setFlags |
| 897 | |
| 898 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 899 | void setFlags(uint32_t flags) |
| 900 | </pre> |
| 901 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 902 | Replaces <a href="SkPaint_Reference#Flags">Flags</a> with <a href="SkPaint_Reference#flags">flags</a>, the union of the <a href="SkPaint_Reference#Flags">Flags</a> members. |
| 903 | All <a href="SkPaint_Reference#Flags">Flags</a> members may be cleared, or one or more may be set. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 904 | |
| 905 | ### Parameters |
| 906 | |
| 907 | <table> <tr> <td><code><strong>flags </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 908 | union of <a href="SkPaint_Reference#Flags">Flags</a> for <a href="SkPaint_Reference#Paint">Paint</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 909 | </tr> |
| 910 | </table> |
| 911 | |
| 912 | ### Example |
| 913 | |
| 914 | <div><fiddle-embed name="54baed3f6bc4b9c31ba664e27767fdc7"> |
| 915 | |
| 916 | #### Example Output |
| 917 | |
| 918 | ~~~~ |
| 919 | paint.isAntiAlias() |
| 920 | paint.isDither() |
| 921 | ~~~~ |
| 922 | |
| 923 | </fiddle-embed></div> |
| 924 | |
| 925 | --- |
| 926 | |
| 927 | # <a name="Anti-alias"></a> Anti-alias |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 928 | <a href="SkPaint_Reference#Anti_alias">Anti-alias</a> drawing approximates partial pixel coverage with transparency. |
| 929 | If <a href="SkPaint_Reference#kAntiAlias_Flag">kAntiAlias Flag</a> is clear, pixel centers contained by the shape edge are drawn opaque. |
| 930 | If <a href="SkPaint_Reference#kAntiAlias_Flag">kAntiAlias Flag</a> is set, pixels are drawn with <a href="undocumented#Alpha">Color Alpha</a> equal to their coverage. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 931 | |
| 932 | The rule for aliased pixels is inconsistent across platforms. A shape edge |
| 933 | passing through the pixel center may, but is not required to, draw the pixel. |
| 934 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 935 | <a href="undocumented#Raster_Engine">Raster Engine</a> draws aliased pixels whose centers are on or to the right of the start of an |
| 936 | active <a href="SkPath_Reference#Path">Path</a> edge, and whose center is to the left of the end of the active <a href="SkPath_Reference#Path">Path</a> edge. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 937 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 938 | A platform may only support anti-aliased drawing. Some <a href="undocumented#GPU_backed">GPU-backed</a> platforms use |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 939 | supersampling to anti-alias all drawing, and have no mechanism to selectively |
| 940 | alias. |
| 941 | |
| 942 | The amount of coverage computed for anti-aliased pixels also varies across platforms. |
| 943 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 944 | <a href="SkPaint_Reference#Anti_alias">Anti-alias</a> is disabled by default. |
| 945 | <a href="SkPaint_Reference#Anti_alias">Anti-alias</a> can be enabled by default by setting <a href="undocumented#SkPaintDefaults_Flags">SkPaintDefaults Flags</a> to <a href="SkPaint_Reference#kAntiAlias_Flag">kAntiAlias Flag</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 946 | at compile time. |
| 947 | |
| 948 | ### Example |
| 949 | |
| 950 | <div><fiddle-embed name="a6575a49467ce8d28bb01cc7638fa04d"><div>A red line is drawn with transparency on the edges to make it look smoother. |
| 951 | A blue line draws only where the pixel centers are contained. |
| 952 | The lines are drawn into an offscreen bitmap, then drawn magified to make the |
| 953 | aliasing easier to see.</div></fiddle-embed></div> |
| 954 | |
| 955 | <a name="isAntiAlias"></a> |
| 956 | ## isAntiAlias |
| 957 | |
| 958 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 959 | bool isAntiAlias() const |
| 960 | </pre> |
| 961 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 962 | If true, pixels on the active edges of <a href="SkPath_Reference#Path">Path</a> may be drawn with partial transparency. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 963 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 964 | Equivalent to <a href="SkPaint_Reference#getFlags">getFlags</a> masked with <a href="SkPaint_Reference#kAntiAlias_Flag">kAntiAlias Flag</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 965 | |
| 966 | ### Return Value |
| 967 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 968 | <a href="SkPaint_Reference#kAntiAlias_Flag">kAntiAlias Flag</a> state |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 969 | |
| 970 | ### Example |
| 971 | |
| 972 | <div><fiddle-embed name="d7d5f4f7da7acd5104a652f490c6f7b8"> |
| 973 | |
| 974 | #### Example Output |
| 975 | |
| 976 | ~~~~ |
| 977 | paint.isAntiAlias() == !!(paint.getFlags() & SkPaint::kAntiAlias_Flag) |
| 978 | paint.isAntiAlias() == !!(paint.getFlags() & SkPaint::kAntiAlias_Flag) |
| 979 | ~~~~ |
| 980 | |
| 981 | </fiddle-embed></div> |
| 982 | |
| 983 | --- |
| 984 | |
| 985 | <a name="setAntiAlias"></a> |
| 986 | ## setAntiAlias |
| 987 | |
| 988 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 989 | void setAntiAlias(bool aa) |
| 990 | </pre> |
| 991 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 992 | Requests, but does not require, that <a href="SkPath_Reference#Path">Path</a> edge pixels draw opaque or with |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 993 | partial transparency. |
| 994 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 995 | Sets <a href="SkPaint_Reference#kAntiAlias_Flag">kAntiAlias Flag</a> if <a href="SkPaint_Reference#aa">aa</a> is true. |
| 996 | Clears <a href="SkPaint_Reference#kAntiAlias_Flag">kAntiAlias Flag</a> if <a href="SkPaint_Reference#aa">aa</a> is false. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 997 | |
| 998 | ### Parameters |
| 999 | |
| 1000 | <table> <tr> <td><code><strong>aa </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1001 | setting for <a href="SkPaint_Reference#kAntiAlias_Flag">kAntiAlias Flag</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1002 | </tr> |
| 1003 | </table> |
| 1004 | |
| 1005 | ### Example |
| 1006 | |
| 1007 | <div><fiddle-embed name="c2ff148374d01cbef845b223e725905c"> |
| 1008 | |
| 1009 | #### Example Output |
| 1010 | |
| 1011 | ~~~~ |
| 1012 | paint1 == paint2 |
| 1013 | ~~~~ |
| 1014 | |
| 1015 | </fiddle-embed></div> |
| 1016 | |
| 1017 | --- |
| 1018 | |
| 1019 | # <a name="Dither"></a> Dither |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1020 | <a href="SkPaint_Reference#Dither">Dither</a> increases fidelity by adjusting the color of adjcent pixels. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1021 | This can help to smooth color transitions and reducing banding in gradients. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1022 | Dithering lessens visible banding from <a href="undocumented#SkColorType">kRGB 565 SkColorType</a> |
| 1023 | and <a href="undocumented#SkColorType">kRGBA 8888 SkColorType</a> gradients, |
| 1024 | and improves rendering into a <a href="undocumented#SkColorType">kRGB 565 SkColorType</a> <a href="undocumented#Surface">Surface</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1025 | |
| 1026 | Dithering is always enabled for linear gradients drawing into |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1027 | <a href="undocumented#SkColorType">kRGB 565 SkColorType</a> <a href="undocumented#Surface">Surface</a> and <a href="undocumented#SkColorType">kRGBA 8888 SkColorType</a> <a href="undocumented#Surface">Surface</a>. |
| 1028 | <a href="SkPaint_Reference#Dither">Dither</a> cannot be enabled for <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a> <a href="undocumented#Surface">Surface</a> and |
| 1029 | <a href="undocumented#SkColorType">kRGBA F16 SkColorType</a> <a href="undocumented#Surface">Surface</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1030 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1031 | <a href="SkPaint_Reference#Dither">Dither</a> is disabled by default. |
| 1032 | <a href="SkPaint_Reference#Dither">Dither</a> can be enabled by default by setting <a href="undocumented#SkPaintDefaults_Flags">SkPaintDefaults Flags</a> to <a href="SkPaint_Reference#kDither_Flag">kDither Flag</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1033 | at compile time. |
| 1034 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1035 | Some platform implementations may ignore dithering. Setto ignore <a href="SkPaint_Reference#Dither">Dither</a> on <a href="undocumented#GPU_Surface">GPU Surface</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1036 | |
| 1037 | ### Example |
| 1038 | |
| 1039 | <div><fiddle-embed name="8b26507690b71462f44642b911890bbf"><div>Dithering in the bottom half more closely approximates the requested color by |
| 1040 | alternating nearby colors from pixel to pixel.</div></fiddle-embed></div> |
| 1041 | |
| 1042 | ### Example |
| 1043 | |
| 1044 | <div><fiddle-embed name="76d4d4a7931a48495e4d5f54e073be53"><div>Dithering introduces subtle adjustments to color to smooth gradients. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1045 | Drawing the gradient repeatedly with <a href="undocumented#kPlus">SkBlendMode::kPlus</a> exaggerates the |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1046 | dither, making it easier to see.</div></fiddle-embed></div> |
| 1047 | |
| 1048 | <a name="isDither"></a> |
| 1049 | ## isDither |
| 1050 | |
| 1051 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1052 | bool isDither() const |
| 1053 | </pre> |
| 1054 | |
| 1055 | If true, color error may be distributed to smooth color transition. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1056 | Equivalent to <a href="SkPaint_Reference#getFlags">getFlags</a> masked with <a href="SkPaint_Reference#kDither_Flag">kDither Flag</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1057 | |
| 1058 | ### Return Value |
| 1059 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1060 | <a href="SkPaint_Reference#kDither_Flag">kDither Flag</a> state |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1061 | |
| 1062 | ### Example |
| 1063 | |
| 1064 | <div><fiddle-embed name="f4ce93f6c5e7335436a985377fd980c0"> |
| 1065 | |
| 1066 | #### Example Output |
| 1067 | |
| 1068 | ~~~~ |
| 1069 | paint.isDither() == !!(paint.getFlags() & SkPaint::kDither_Flag) |
| 1070 | paint.isDither() == !!(paint.getFlags() & SkPaint::kDither_Flag) |
| 1071 | ~~~~ |
| 1072 | |
| 1073 | </fiddle-embed></div> |
| 1074 | |
| 1075 | --- |
| 1076 | |
| 1077 | <a name="setDither"></a> |
| 1078 | ## setDither |
| 1079 | |
| 1080 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1081 | void setDither(bool dither) |
| 1082 | </pre> |
| 1083 | |
| 1084 | Requests, but does not require, to distribute color error. |
| 1085 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1086 | Sets <a href="SkPaint_Reference#kDither_Flag">kDither Flag</a> if <a href="SkPaint_Reference#dither">dither</a> is true. |
| 1087 | Clears <a href="SkPaint_Reference#kDither_Flag">kDither Flag</a> if <a href="SkPaint_Reference#dither">dither</a> is false. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1088 | |
| 1089 | ### Parameters |
| 1090 | |
| 1091 | <table> <tr> <td><code><strong>dither </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1092 | setting for <a href="SkPaint_Reference#kDither_Flag">kDither Flag</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1093 | </tr> |
| 1094 | </table> |
| 1095 | |
| 1096 | ### Example |
| 1097 | |
| 1098 | <div><fiddle-embed name="69b7162e8324d9239dd02dd9ada2bdff"> |
| 1099 | |
| 1100 | #### Example Output |
| 1101 | |
| 1102 | ~~~~ |
| 1103 | paint1 == paint2 |
| 1104 | ~~~~ |
| 1105 | |
| 1106 | </fiddle-embed></div> |
| 1107 | |
| 1108 | ### See Also |
| 1109 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1110 | <a href="undocumented#SkColorType">kRGB 565 SkColorType</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1111 | |
| 1112 | --- |
| 1113 | |
| 1114 | ### See Also |
| 1115 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1116 | Gradient <a href="undocumented#RGB_565">Color RGB-565</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1117 | |
| 1118 | # <a name="Device_Text"></a> Device Text |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1119 | <a href="SkPaint_Reference#LCD_Text">LCD Text</a> and <a href="SkPaint_Reference#Subpixel_Text">Subpixel Text</a> increase the precision of glyph position. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1120 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1121 | When set, <a href="SkPaint_Reference#Flags">Flags</a> <a href="SkPaint_Reference#kLCDRenderText_Flag">kLCDRenderText Flag</a> takes advantage of the organization of <a href="undocumented#RGB">Color RGB</a> stripes that |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1122 | create a color, and relies |
| 1123 | on the small size of the stripe and visual perception to make the color fringing inperceptible. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1124 | <a href="SkPaint_Reference#LCD_Text">LCD Text</a> can be enabled on devices that orient stripes horizontally or vertically, and that order |
| 1125 | the color components as <a href="undocumented#RGB">Color RGB</a> or <a href="undocumented#RBG">Color RBG</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1126 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1127 | <a href="SkPaint_Reference#Flags">Flags</a> <a href="SkPaint_Reference#kSubpixelText_Flag">kSubpixelText Flag</a> uses the pixel transparency to represent a fractional offset. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1128 | As the opaqueness |
| 1129 | of the color increases, the edge of the glyph appears to move towards the outside of the pixel. |
| 1130 | |
| 1131 | Either or both techniques can be enabled. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1132 | <a href="SkPaint_Reference#kLCDRenderText_Flag">kLCDRenderText Flag</a> and <a href="SkPaint_Reference#kSubpixelText_Flag">kSubpixelText Flag</a> are clear by default. |
| 1133 | <a href="SkPaint_Reference#LCD_Text">LCD Text</a> or <a href="SkPaint_Reference#Subpixel_Text">Subpixel Text</a> can be enabled by default by setting <a href="undocumented#SkPaintDefaults_Flags">SkPaintDefaults Flags</a> to |
| 1134 | <a href="SkPaint_Reference#kLCDRenderText_Flag">kLCDRenderText Flag</a> or <a href="SkPaint_Reference#kSubpixelText_Flag">kSubpixelText Flag</a> (or both) at compile time. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1135 | |
| 1136 | ### Example |
| 1137 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1138 | <div><fiddle-embed name="4606ae1be792d6bc46d496432f050ee9"><div>Four commas are drawn normally and with combinations of <a href="SkPaint_Reference#LCD_Text">LCD Text</a> and <a href="SkPaint_Reference#Subpixel_Text">Subpixel Text</a>. |
| 1139 | When <a href="SkPaint_Reference#Subpixel_Text">Subpixel Text</a> is disabled, the comma glyphs are indentical, but not evenly spaced. |
| 1140 | When <a href="SkPaint_Reference#Subpixel_Text">Subpixel Text</a> is enabled, the comma glyphs are unique, but appear evenly spaced.</div></fiddle-embed></div> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1141 | |
| 1142 | ## <a name="Linear_Text"></a> Linear Text |
| 1143 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1144 | <a href="SkPaint_Reference#Linear_Text">Linear Text</a> selects whether text is rendered as a <a href="undocumented#Glyph">Glyph</a> or as a <a href="SkPath_Reference#Path">Path</a>. |
| 1145 | If <a href="SkPaint_Reference#kLinearText_Flag">kLinearText Flag</a> is set, it has the same effect as setting <a href="SkPaint_Reference#Hinting">Hinting</a> to <a href="SkPaint_Reference#kNormal_Hinting">kNormal Hinting</a>. |
| 1146 | If <a href="SkPaint_Reference#kLinearText_Flag">kLinearText Flag</a> is clear, it's the same as setting <a href="SkPaint_Reference#Hinting">Hinting</a> to <a href="SkPaint_Reference#kNo_Hinting">kNo Hinting</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1147 | |
| 1148 | <a name="isLinearText"></a> |
| 1149 | ## isLinearText |
| 1150 | |
| 1151 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1152 | bool isLinearText() const |
| 1153 | </pre> |
| 1154 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1155 | If true, text is converted to <a href="SkPath_Reference#Path">Path</a> before drawing and measuring. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1156 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1157 | Equivalent to <a href="SkPaint_Reference#getFlags">getFlags</a> masked with <a href="SkPaint_Reference#kLinearText_Flag">kLinearText Flag</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1158 | |
| 1159 | ### Return Value |
| 1160 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1161 | <a href="SkPaint_Reference#kLinearText_Flag">kLinearText Flag</a> state |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1162 | |
| 1163 | ### Example |
| 1164 | |
| 1165 | <div><fiddle-embed name="2890ad644f980637837e6fcb386fb462"></fiddle-embed></div> |
| 1166 | |
| 1167 | ### See Also |
| 1168 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1169 | <a href="SkPaint_Reference#setLinearText">setLinearText</a> <a href="SkPaint_Reference#Hinting">Hinting</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1170 | |
| 1171 | --- |
| 1172 | |
| 1173 | <a name="setLinearText"></a> |
| 1174 | ## setLinearText |
| 1175 | |
| 1176 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1177 | void setLinearText(bool linearText) |
| 1178 | </pre> |
| 1179 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1180 | If true, text is converted to <a href="SkPath_Reference#Path">Path</a> before drawing and measuring. |
| 1181 | By default, <a href="SkPaint_Reference#kLinearText_Flag">kLinearText Flag</a> is clear. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1182 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1183 | Sets <a href="SkPaint_Reference#kLinearText_Flag">kLinearText Flag</a> if <a href="SkPaint_Reference#linearText">linearText</a> is true. |
| 1184 | Clears <a href="SkPaint_Reference#kLinearText_Flag">kLinearText Flag</a> if <a href="SkPaint_Reference#linearText">linearText</a> is false. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1185 | |
| 1186 | ### Parameters |
| 1187 | |
| 1188 | <table> <tr> <td><code><strong>linearText </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1189 | setting for <a href="SkPaint_Reference#kLinearText_Flag">kLinearText Flag</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1190 | </tr> |
| 1191 | </table> |
| 1192 | |
| 1193 | ### Example |
| 1194 | |
| 1195 | <div><fiddle-embed name="c93bb912f3bddfb4d96d3ad70ada552b"></fiddle-embed></div> |
| 1196 | |
| 1197 | ### See Also |
| 1198 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1199 | <a href="SkPaint_Reference#isLinearText">isLinearText</a> <a href="SkPaint_Reference#Hinting">Hinting</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1200 | |
| 1201 | --- |
| 1202 | |
| 1203 | ## <a name="Subpixel_Text"></a> Subpixel Text |
| 1204 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1205 | <a href="SkPaint_Reference#Flags">Flags</a> <a href="SkPaint_Reference#kSubpixelText_Flag">kSubpixelText Flag</a> uses the pixel transparency to represent a fractional offset. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1206 | As the opaqueness |
| 1207 | of the color increases, the edge of the glyph appears to move towards the outside of the pixel. |
| 1208 | |
| 1209 | <a name="isSubpixelText"></a> |
| 1210 | ## isSubpixelText |
| 1211 | |
| 1212 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1213 | bool isSubpixelText() const |
| 1214 | </pre> |
| 1215 | |
| 1216 | If true, glyphs at different sub-pixel positions may differ on pixel edge coverage. |
| 1217 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1218 | Equivalent to <a href="SkPaint_Reference#getFlags">getFlags</a> masked with <a href="SkPaint_Reference#kSubpixelText_Flag">kSubpixelText Flag</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1219 | |
| 1220 | ### Return Value |
| 1221 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1222 | <a href="SkPaint_Reference#kSubpixelText_Flag">kSubpixelText Flag</a> state |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1223 | |
| 1224 | ### Example |
| 1225 | |
| 1226 | <div><fiddle-embed name="abe9afc0932e2199324ae6cbb396e67c"> |
| 1227 | |
| 1228 | #### Example Output |
| 1229 | |
| 1230 | ~~~~ |
| 1231 | paint.isSubpixelText() == !!(paint.getFlags() & SkPaint::kSubpixelText_Flag) |
| 1232 | paint.isSubpixelText() == !!(paint.getFlags() & SkPaint::kSubpixelText_Flag) |
| 1233 | ~~~~ |
| 1234 | |
| 1235 | </fiddle-embed></div> |
| 1236 | |
| 1237 | --- |
| 1238 | |
| 1239 | <a name="setSubpixelText"></a> |
| 1240 | ## setSubpixelText |
| 1241 | |
| 1242 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1243 | void setSubpixelText(bool subpixelText) |
| 1244 | </pre> |
| 1245 | |
| 1246 | Requests, but does not require, that glyphs respect sub-pixel positioning. |
| 1247 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1248 | Sets <a href="SkPaint_Reference#kSubpixelText_Flag">kSubpixelText Flag</a> if <a href="SkPaint_Reference#subpixelText">subpixelText</a> is true. |
| 1249 | Clears <a href="SkPaint_Reference#kSubpixelText_Flag">kSubpixelText Flag</a> if <a href="SkPaint_Reference#subpixelText">subpixelText</a> is false. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1250 | |
| 1251 | ### Parameters |
| 1252 | |
| 1253 | <table> <tr> <td><code><strong>subpixelText </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1254 | setting for <a href="SkPaint_Reference#kSubpixelText_Flag">kSubpixelText Flag</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1255 | </tr> |
| 1256 | </table> |
| 1257 | |
| 1258 | ### Example |
| 1259 | |
| 1260 | <div><fiddle-embed name="a77bbc1a4e3be9a8ab0f842f877c5ee4"> |
| 1261 | |
| 1262 | #### Example Output |
| 1263 | |
| 1264 | ~~~~ |
| 1265 | paint1 == paint2 |
| 1266 | ~~~~ |
| 1267 | |
| 1268 | </fiddle-embed></div> |
| 1269 | |
| 1270 | --- |
| 1271 | |
| 1272 | ## <a name="LCD_Text"></a> LCD Text |
| 1273 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1274 | When set, <a href="SkPaint_Reference#Flags">Flags</a> <a href="SkPaint_Reference#kLCDRenderText_Flag">kLCDRenderText Flag</a> takes advantage of the organization of <a href="undocumented#RGB">Color RGB</a> stripes that |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1275 | create a color, and relies |
| 1276 | on the small size of the stripe and visual perception to make the color fringing inperceptible. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1277 | <a href="SkPaint_Reference#LCD_Text">LCD Text</a> can be enabled on devices that orient stripes horizontally or vertically, and that order |
| 1278 | the color components as <a href="undocumented#RGB">Color RGB</a> or <a href="undocumented#RBG">Color RBG</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1279 | |
| 1280 | <a name="isLCDRenderText"></a> |
| 1281 | ## isLCDRenderText |
| 1282 | |
| 1283 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1284 | bool isLCDRenderText() const |
| 1285 | </pre> |
| 1286 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1287 | If true, glyphs may use <a href="undocumented#LCD">LCD</a> striping to improve glyph edges. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1288 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1289 | Returns true if <a href="SkPaint_Reference#Flags">Flags</a> <a href="SkPaint_Reference#kLCDRenderText_Flag">kLCDRenderText Flag</a> is set. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1290 | |
| 1291 | ### Return Value |
| 1292 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1293 | <a href="SkPaint_Reference#kLCDRenderText_Flag">kLCDRenderText Flag</a> state |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1294 | |
| 1295 | ### Example |
| 1296 | |
| 1297 | <div><fiddle-embed name="68e1fd95dd2fd06a333899d2bd2396b9"> |
| 1298 | |
| 1299 | #### Example Output |
| 1300 | |
| 1301 | ~~~~ |
| 1302 | paint.isLCDRenderText() == !!(paint.getFlags() & SkPaint::kLCDRenderText_Flag) |
| 1303 | paint.isLCDRenderText() == !!(paint.getFlags() & SkPaint::kLCDRenderText_Flag) |
| 1304 | ~~~~ |
| 1305 | |
| 1306 | </fiddle-embed></div> |
| 1307 | |
| 1308 | --- |
| 1309 | |
| 1310 | <a name="setLCDRenderText"></a> |
| 1311 | ## setLCDRenderText |
| 1312 | |
| 1313 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1314 | void setLCDRenderText(bool lcdText) |
| 1315 | </pre> |
| 1316 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1317 | Requests, but does not require, that glyphs use <a href="undocumented#LCD">LCD</a> striping for glyph edges. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1318 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1319 | Sets <a href="SkPaint_Reference#kLCDRenderText_Flag">kLCDRenderText Flag</a> if <a href="SkPaint_Reference#lcdText">lcdText</a> is true. |
| 1320 | Clears <a href="SkPaint_Reference#kLCDRenderText_Flag">kLCDRenderText Flag</a> if <a href="SkPaint_Reference#lcdText">lcdText</a> is false. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1321 | |
| 1322 | ### Parameters |
| 1323 | |
| 1324 | <table> <tr> <td><code><strong>lcdText </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1325 | setting for <a href="SkPaint_Reference#kLCDRenderText_Flag">kLCDRenderText Flag</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1326 | </tr> |
| 1327 | </table> |
| 1328 | |
| 1329 | ### Example |
| 1330 | |
| 1331 | <div><fiddle-embed name="50dedf8450159571a3edaf4f0050defe"> |
| 1332 | |
| 1333 | #### Example Output |
| 1334 | |
| 1335 | ~~~~ |
| 1336 | paint1 == paint2 |
| 1337 | ~~~~ |
| 1338 | |
| 1339 | </fiddle-embed></div> |
| 1340 | |
| 1341 | --- |
| 1342 | |
| 1343 | # <a name="Font_Embedded_Bitmaps"></a> Font Embedded Bitmaps |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1344 | <a href="SkPaint_Reference#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a> allows selecting custom-sized bitmap glyphs. |
| 1345 | <a href="SkPaint_Reference#Flags">Flags</a> <a href="SkPaint_Reference#kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> when set chooses an embedded bitmap glyph over an outline contained |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1346 | in a font if the platform supports this option. |
| 1347 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1348 | <a href="undocumented#FreeType">FreeType</a> selects the bitmap glyph if available when <a href="SkPaint_Reference#kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> is set, and selects |
| 1349 | the outline glyph if <a href="SkPaint_Reference#kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> is clear. |
| 1350 | <a href="undocumented#Windows">Windows</a> may select the bitmap glyph but is not required to do so. |
| 1351 | <a href="undocumented#OS_X">OS X</a> and <a href="undocumented#iOS">iOS</a> do not support this option. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1352 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1353 | <a href="SkPaint_Reference#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a> is disabled by default. |
| 1354 | <a href="SkPaint_Reference#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a> can be enabled by default by setting <a href="undocumented#SkPaintDefaults_Flags">SkPaintDefaults Flags</a> to |
| 1355 | <a href="SkPaint_Reference#kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> at compile time. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1356 | |
| 1357 | ### Example |
| 1358 | |
| 1359 | <pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0"> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1360 | !fiddle<div>The hintgasp <a href="undocumented#TrueType">TrueType</a> font in the <a href="undocumented#Skia">Skia</a> resources/fonts directory includes an embedded |
| 1361 | bitmap glyph at odd font sizes. This example works on platforms that use <a href="undocumented#FreeType">FreeType</a> |
| 1362 | as their <a href="undocumented#Engine">Font Engine</a>. |
| 1363 | <a href="undocumented#Windows">Windows</a> may, but is not required to, return a bitmap glyph if <a href="SkPaint_Reference#kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> is set.</div><a href="undocumented#SkBitmap">SkBitmap</a> bitmap; |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1364 | bitmap.allocN32Pixels(30, 15); |
| 1365 | bitmap.eraseColor(0); |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1366 | <a href="SkCanvas_Reference#SkCanvas">SkCanvas</a> offscreen(bitmap); |
| 1367 | <a href="SkPaint_Reference#SkPaint">SkPaint</a> paint; |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1368 | paint.</pre> |
| 1369 | |
| 1370 | <a name="isEmbeddedBitmapText"></a> |
| 1371 | ## isEmbeddedBitmapText |
| 1372 | |
| 1373 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1374 | bool isEmbeddedBitmapText() const |
| 1375 | </pre> |
| 1376 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1377 | If true, <a href="undocumented#Engine">Font Engine</a> may return glyphs from font bitmaps instead of from outlines. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1378 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1379 | Equivalent to <a href="SkPaint_Reference#getFlags">getFlags</a> masked with <a href="SkPaint_Reference#kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1380 | |
| 1381 | ### Return Value |
| 1382 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1383 | <a href="SkPaint_Reference#kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> state |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1384 | |
| 1385 | ### Example |
| 1386 | |
| 1387 | <div><fiddle-embed name="eba10b27b790e87183ae451b3fc5c4b1"> |
| 1388 | |
| 1389 | #### Example Output |
| 1390 | |
| 1391 | ~~~~ |
| 1392 | paint.isEmbeddedBitmapText() == !!(paint.getFlags() & SkPaint::kEmbeddedBitmapText_Flag) |
| 1393 | paint.isEmbeddedBitmapText() == !!(paint.getFlags() & SkPaint::kEmbeddedBitmapText_Flag) |
| 1394 | ~~~~ |
| 1395 | |
| 1396 | </fiddle-embed></div> |
| 1397 | |
| 1398 | --- |
| 1399 | |
| 1400 | <a name="setEmbeddedBitmapText"></a> |
| 1401 | ## setEmbeddedBitmapText |
| 1402 | |
| 1403 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1404 | void setEmbeddedBitmapText(bool useEmbeddedBitmapText) |
| 1405 | </pre> |
| 1406 | |
| 1407 | Requests, but does not require, to use bitmaps in fonts instead of outlines. |
| 1408 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1409 | Sets <a href="SkPaint_Reference#kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> if <a href="SkPaint_Reference#useEmbeddedBitmapText">useEmbeddedBitmapText</a> is true. |
| 1410 | Clears <a href="SkPaint_Reference#kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> if <a href="SkPaint_Reference#useEmbeddedBitmapText">useEmbeddedBitmapText</a> is false. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1411 | |
| 1412 | ### Parameters |
| 1413 | |
| 1414 | <table> <tr> <td><code><strong>useEmbeddedBitmapText </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1415 | setting for <a href="SkPaint_Reference#kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1416 | </tr> |
| 1417 | </table> |
| 1418 | |
| 1419 | ### Example |
| 1420 | |
| 1421 | <div><fiddle-embed name="246dffdd93a484ba4ad7ecf71198a5d4"> |
| 1422 | |
| 1423 | #### Example Output |
| 1424 | |
| 1425 | ~~~~ |
| 1426 | paint1 == paint2 |
| 1427 | ~~~~ |
| 1428 | |
| 1429 | </fiddle-embed></div> |
| 1430 | |
| 1431 | --- |
| 1432 | |
| 1433 | # <a name="Automatic_Hinting"></a> Automatic Hinting |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1434 | If <a href="SkPaint_Reference#Hinting">Hinting</a> is set to <a href="SkPaint_Reference#kNormal_Hinting">kNormal Hinting</a> or <a href="SkPaint_Reference#kFull_Hinting">kFull Hinting</a>, <a href="SkPaint_Reference#Automatic_Hinting">Automatic Hinting</a> |
| 1435 | instructs the <a href="undocumented#Font_Manager">Font Manager</a> to always hint glyphs. |
| 1436 | <a href="SkPaint_Reference#Automatic_Hinting">Automatic Hinting</a> has no effect if <a href="SkPaint_Reference#Hinting">Hinting</a> is set to <a href="SkPaint_Reference#kNo_Hinting">kNo Hinting</a> or |
| 1437 | <a href="SkPaint_Reference#kSlight_Hinting">kSlight Hinting</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1438 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1439 | <a href="SkPaint_Reference#Automatic_Hinting">Automatic Hinting</a> only affects platforms that use <a href="undocumented#FreeType">FreeType</a> as the <a href="undocumented#Font_Manager">Font Manager</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1440 | |
| 1441 | <a name="isAutohinted"></a> |
| 1442 | ## isAutohinted |
| 1443 | |
| 1444 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1445 | bool isAutohinted() const |
| 1446 | </pre> |
| 1447 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1448 | If true, and if <a href="SkPaint_Reference#Hinting">Hinting</a> is set to <a href="SkPaint_Reference#kNormal_Hinting">kNormal Hinting</a> or <a href="SkPaint_Reference#kFull_Hinting">kFull Hinting</a>, and if |
| 1449 | platform uses <a href="undocumented#FreeType">FreeType</a> as the <a href="undocumented#Font_Manager">Font Manager</a>, instruct the <a href="undocumented#Font_Manager">Font Manager</a> to always hint |
Cary Clark | bad5ad7 | 2017-08-03 17:14:08 -0400 | [diff] [blame] | 1450 | glyphs. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1451 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1452 | Equivalent to <a href="SkPaint_Reference#getFlags">getFlags</a> masked with <a href="SkPaint_Reference#kAutoHinting_Flag">kAutoHinting Flag</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1453 | |
| 1454 | ### Return Value |
| 1455 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1456 | <a href="SkPaint_Reference#kAutoHinting_Flag">kAutoHinting Flag</a> state |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1457 | |
| 1458 | ### Example |
| 1459 | |
| 1460 | <div><fiddle-embed name="aa4781afbe3b90e7ef56a287e5b9ce1e"> |
| 1461 | |
| 1462 | #### Example Output |
| 1463 | |
| 1464 | ~~~~ |
| 1465 | paint.isAutohinted() == !!(paint.getFlags() & SkPaint::kAutoHinting_Flag) |
| 1466 | paint.isAutohinted() == !!(paint.getFlags() & SkPaint::kAutoHinting_Flag) |
| 1467 | ~~~~ |
| 1468 | |
| 1469 | </fiddle-embed></div> |
| 1470 | |
| 1471 | ### See Also |
| 1472 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1473 | <a href="SkPaint_Reference#setAutohinted">setAutohinted</a> <a href="SkPaint_Reference#Hinting">Hinting</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1474 | |
| 1475 | --- |
| 1476 | |
| 1477 | <a name="setAutohinted"></a> |
| 1478 | ## setAutohinted |
| 1479 | |
| 1480 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1481 | void setAutohinted(bool useAutohinter) |
| 1482 | </pre> |
| 1483 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1484 | If <a href="SkPaint_Reference#Hinting">Hinting</a> is set to <a href="SkPaint_Reference#kNormal_Hinting">kNormal Hinting</a> or <a href="SkPaint_Reference#kFull_Hinting">kFull Hinting</a> and <a href="SkPaint_Reference#useAutohinter">useAutohinter</a> is set, |
| 1485 | instruct the <a href="undocumented#Font_Manager">Font Manager</a> to always hint glyphs. |
| 1486 | <a href="SkPaint_Reference#Automatic_Hinting">Automatic Hinting</a> has no effect if <a href="SkPaint_Reference#Hinting">Hinting</a> is set to <a href="SkPaint_Reference#kNo_Hinting">kNo Hinting</a> or |
| 1487 | <a href="SkPaint_Reference#kSlight_Hinting">kSlight Hinting</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1488 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1489 | Only affects platforms that use <a href="undocumented#FreeType">FreeType</a> as the <a href="undocumented#Font_Manager">Font Manager</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1490 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1491 | Sets <a href="SkPaint_Reference#kAutoHinting_Flag">kAutoHinting Flag</a> if <a href="SkPaint_Reference#useAutohinter">useAutohinter</a> is true. |
| 1492 | Clears <a href="SkPaint_Reference#kAutoHinting_Flag">kAutoHinting Flag</a> if <a href="SkPaint_Reference#useAutohinter">useAutohinter</a> is false. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1493 | |
| 1494 | ### Parameters |
| 1495 | |
| 1496 | <table> <tr> <td><code><strong>useAutohinter </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1497 | setting for <a href="SkPaint_Reference#kAutoHinting_Flag">kAutoHinting Flag</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1498 | </tr> |
| 1499 | </table> |
| 1500 | |
| 1501 | ### Example |
| 1502 | |
| 1503 | <div><fiddle-embed name="4e185306d7de9390fe8445eed0139309"></fiddle-embed></div> |
| 1504 | |
| 1505 | ### See Also |
| 1506 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1507 | <a href="SkPaint_Reference#isAutohinted">isAutohinted</a> <a href="SkPaint_Reference#Hinting">Hinting</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1508 | |
| 1509 | --- |
| 1510 | |
| 1511 | # <a name="Vertical_Text"></a> Vertical Text |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1512 | <a href="undocumented#Text">Text</a> may be drawn by positioning each glyph, or by positioning the first glyph and |
| 1513 | using <a href="undocumented#Advance">Font Advance</a> to position subsequent glyphs. By default, each successive glyph |
| 1514 | is positioned to the right of the preceeding glyph. <a href="SkPaint_Reference#Vertical_Text">Vertical Text</a> sets successive |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1515 | glyphs to position below the preceeding glyph. |
| 1516 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1517 | <a href="undocumented#Skia">Skia</a> can translate text character codes as a series of glyphs, but does not implement |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1518 | font substitution, |
| 1519 | textual substitution, line layout, or contextual spacing like kerning pairs. Use |
| 1520 | a text shaping engine likeHarfBuzzhttp://harfbuzz.org/to translate text runs |
| 1521 | into glyph series. |
| 1522 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1523 | <a href="SkPaint_Reference#Vertical_Text">Vertical Text</a> is clear if text is drawn left to right or set if drawn from top to bottom. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1524 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1525 | <a href="SkPaint_Reference#Flags">Flags</a> <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> if clear draws text left to right. |
| 1526 | <a href="SkPaint_Reference#Flags">Flags</a> <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> if set draws text top to bottom. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1527 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1528 | <a href="SkPaint_Reference#Vertical_Text">Vertical Text</a> is clear by default. |
| 1529 | <a href="SkPaint_Reference#Vertical_Text">Vertical Text</a> can be set by default by setting <a href="undocumented#SkPaintDefaults_Flags">SkPaintDefaults Flags</a> to |
| 1530 | <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> at compile time. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1531 | |
| 1532 | ### Example |
| 1533 | |
| 1534 | <div><fiddle-embed name="8df5800819311b71373d9abb669b49b8"></fiddle-embed></div> |
| 1535 | |
| 1536 | <a name="isVerticalText"></a> |
| 1537 | ## isVerticalText |
| 1538 | |
| 1539 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1540 | bool isVerticalText() const |
| 1541 | </pre> |
| 1542 | |
| 1543 | If true, glyphs are drawn top to bottom instead of left to right. |
| 1544 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1545 | Equivalent to <a href="SkPaint_Reference#getFlags">getFlags</a> masked with <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1546 | |
| 1547 | ### Return Value |
| 1548 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1549 | <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> state |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1550 | |
| 1551 | ### Example |
| 1552 | |
| 1553 | <div><fiddle-embed name="4a269b16e644d473870ffa873396f139"> |
| 1554 | |
| 1555 | #### Example Output |
| 1556 | |
| 1557 | ~~~~ |
| 1558 | paint.isVerticalText() == !!(paint.getFlags() & SkPaint::kVerticalText_Flag) |
| 1559 | paint.isVerticalText() == !!(paint.getFlags() & SkPaint::kVerticalText_Flag) |
| 1560 | ~~~~ |
| 1561 | |
| 1562 | </fiddle-embed></div> |
| 1563 | |
| 1564 | --- |
| 1565 | |
| 1566 | <a name="setVerticalText"></a> |
| 1567 | ## setVerticalText |
| 1568 | |
| 1569 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1570 | void setVerticalText(bool verticalText) |
| 1571 | </pre> |
| 1572 | |
| 1573 | If true, text advance positions the next glyph below the previous glyph instead of to the |
| 1574 | right of previous glyph. |
| 1575 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1576 | Sets <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> if vertical is true. |
| 1577 | Clears <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> if vertical is false. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1578 | |
| 1579 | ### Parameters |
| 1580 | |
| 1581 | <table> <tr> <td><code><strong>verticalText </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1582 | setting for <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1583 | </tr> |
| 1584 | </table> |
| 1585 | |
| 1586 | ### Example |
| 1587 | |
| 1588 | <div><fiddle-embed name="6fbd7e9e1a346cb8d7f537786009c736"> |
| 1589 | |
| 1590 | #### Example Output |
| 1591 | |
| 1592 | ~~~~ |
| 1593 | paint1 == paint2 |
| 1594 | ~~~~ |
| 1595 | |
| 1596 | </fiddle-embed></div> |
| 1597 | |
| 1598 | --- |
| 1599 | |
| 1600 | # <a name="Fake_Bold"></a> Fake Bold |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1601 | <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a> approximates the bold font style accompanying a normal font when a bold font face |
| 1602 | is not available. <a href="undocumented#Skia">Skia</a> does not provide font substitution; it is up to the client to find the |
| 1603 | bold font face using the platform's <a href="undocumented#Font_Manager">Font Manager</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1604 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1605 | Use <a href="SkPaint_Reference#Text_Skew_X">Text Skew X</a> to approximate an italic font style when the italic font face |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1606 | is not available. |
| 1607 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1608 | A <a href="undocumented#FreeType_based">FreeType-based</a> port may define <a href="undocumented#SK_USE_FREETYPE_EMBOLDEN">SK USE FREETYPE EMBOLDEN</a> at compile time to direct |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1609 | the font engine to create the bold glyphs. Otherwise, the extra bold is computed |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1610 | by increasing the stroke width and setting the <a href="SkPaint_Reference#Style">Style</a> to <a href="SkPaint_Reference#kStrokeAndFill_Style">kStrokeAndFill Style</a> as needed. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1611 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1612 | <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a> is disabled by default. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1613 | |
| 1614 | ### Example |
| 1615 | |
| 1616 | <div><fiddle-embed name="e811f4829a2daaaeaad3795504a7e02a"></fiddle-embed></div> |
| 1617 | |
| 1618 | <a name="isFakeBoldText"></a> |
| 1619 | ## isFakeBoldText |
| 1620 | |
| 1621 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1622 | bool isFakeBoldText() const |
| 1623 | </pre> |
| 1624 | |
| 1625 | If true, approximate bold by increasing the stroke width when creating glyph bitmaps |
| 1626 | from outlines. |
| 1627 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1628 | Equivalent to <a href="SkPaint_Reference#getFlags">getFlags</a> masked with <a href="SkPaint_Reference#kFakeBoldText_Flag">kFakeBoldText Flag</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1629 | |
| 1630 | ### Return Value |
| 1631 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1632 | <a href="SkPaint_Reference#kFakeBoldText_Flag">kFakeBoldText Flag</a> state |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1633 | |
| 1634 | ### Example |
| 1635 | |
| 1636 | <div><fiddle-embed name="f54d1f85b16073b80b9eef2e1a1d151d"> |
| 1637 | |
| 1638 | #### Example Output |
| 1639 | |
| 1640 | ~~~~ |
| 1641 | paint.isFakeBoldText() == !!(paint.getFlags() & SkPaint::kFakeBoldText_Flag) |
| 1642 | paint.isFakeBoldText() == !!(paint.getFlags() & SkPaint::kFakeBoldText_Flag) |
| 1643 | ~~~~ |
| 1644 | |
| 1645 | </fiddle-embed></div> |
| 1646 | |
| 1647 | --- |
| 1648 | |
| 1649 | <a name="setFakeBoldText"></a> |
| 1650 | ## setFakeBoldText |
| 1651 | |
| 1652 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1653 | void setFakeBoldText(bool fakeBoldText) |
| 1654 | </pre> |
| 1655 | |
| 1656 | Use increased stroke width when creating glyph bitmaps to approximate bolding. |
| 1657 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1658 | Sets <a href="SkPaint_Reference#kFakeBoldText_Flag">kFakeBoldText Flag</a> if <a href="SkPaint_Reference#fakeBoldText">fakeBoldText</a> is true. |
| 1659 | Clears <a href="SkPaint_Reference#kFakeBoldText_Flag">kFakeBoldText Flag</a> if <a href="SkPaint_Reference#fakeBoldText">fakeBoldText</a> is false. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1660 | |
| 1661 | ### Parameters |
| 1662 | |
| 1663 | <table> <tr> <td><code><strong>fakeBoldText </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1664 | setting for <a href="SkPaint_Reference#kFakeBoldText_Flag">kFakeBoldText Flag</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1665 | </tr> |
| 1666 | </table> |
| 1667 | |
| 1668 | ### Example |
| 1669 | |
| 1670 | <div><fiddle-embed name="594d47858eb11028cb626515a520910a"> |
| 1671 | |
| 1672 | #### Example Output |
| 1673 | |
| 1674 | ~~~~ |
| 1675 | paint1 == paint2 |
| 1676 | ~~~~ |
| 1677 | |
| 1678 | </fiddle-embed></div> |
| 1679 | |
| 1680 | --- |
| 1681 | |
| 1682 | # <a name="Full_Hinting_Spacing"></a> Full Hinting Spacing |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1683 | <a href="SkPaint_Reference#Full_Hinting_Spacing">Full Hinting Spacing</a> adjusts the character spacing by the difference of the |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1684 | hinted and unhinted left and right side bearings, |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1685 | if <a href="SkPaint_Reference#Hinting">Hinting</a> is set to <a href="SkPaint_Reference#kFull_Hinting">kFull Hinting</a>. <a href="SkPaint_Reference#Full_Hinting_Spacing">Full Hinting Spacing</a> only |
| 1686 | applies to platforms that use <a href="undocumented#FreeType">FreeType</a> as their <a href="undocumented#Engine">Font Engine</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1687 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1688 | <a href="SkPaint_Reference#Full_Hinting_Spacing">Full Hinting Spacing</a> is not related to text kerning, where the space between |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1689 | a specific pair of characters is adjusted using data in the font's kerning tables. |
| 1690 | |
| 1691 | <a name="isDevKernText"></a> |
| 1692 | ## isDevKernText |
| 1693 | |
| 1694 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1695 | bool isDevKernText() const |
| 1696 | </pre> |
| 1697 | |
| 1698 | Returns if character spacing may be adjusted by the hinting difference. |
| 1699 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1700 | Equivalent to <a href="SkPaint_Reference#getFlags">getFlags</a> masked with <a href="SkPaint_Reference#kDevKernText_Flag">kDevKernText Flag</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1701 | |
| 1702 | ### Return Value |
| 1703 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1704 | <a href="SkPaint_Reference#kDevKernText_Flag">kDevKernText Flag</a> state |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1705 | |
| 1706 | ### Example |
| 1707 | |
| 1708 | <div><fiddle-embed name="4f69a84b2505b12809c30b0cc09c5157"></fiddle-embed></div> |
| 1709 | |
| 1710 | --- |
| 1711 | |
| 1712 | <a name="setDevKernText"></a> |
| 1713 | ## setDevKernText |
| 1714 | |
| 1715 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1716 | void setDevKernText(bool devKernText) |
| 1717 | </pre> |
| 1718 | |
| 1719 | Requests, but does not require, to use hinting to adjust glyph spacing. |
| 1720 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1721 | Sets <a href="SkPaint_Reference#kDevKernText_Flag">kDevKernText Flag</a> if <a href="SkPaint_Reference#devKernText">devKernText</a> is true. |
| 1722 | Clears <a href="SkPaint_Reference#kDevKernText_Flag">kDevKernText Flag</a> if <a href="SkPaint_Reference#devKernText">devKernText</a> is false. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1723 | |
| 1724 | ### Parameters |
| 1725 | |
| 1726 | <table> <tr> <td><code><strong>devKernText </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1727 | setting for <a href="SkPaint_Reference#devKernText">devKernText</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1728 | </tr> |
| 1729 | </table> |
| 1730 | |
| 1731 | ### Example |
| 1732 | |
| 1733 | <div><fiddle-embed name="2b718a059072908bf68942503f264797"> |
| 1734 | |
| 1735 | #### Example Output |
| 1736 | |
| 1737 | ~~~~ |
| 1738 | paint1 == paint2 |
| 1739 | ~~~~ |
| 1740 | |
| 1741 | </fiddle-embed></div> |
| 1742 | |
| 1743 | --- |
| 1744 | |
| 1745 | # <a name="Filter_Quality_Methods"></a> Filter Quality Methods |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1746 | <a href="undocumented#Filter_Quality">Filter Quality</a> trades speed for image filtering when the image is scaled. |
| 1747 | A lower <a href="undocumented#Filter_Quality">Filter Quality</a> draws faster, but has less fidelity. |
| 1748 | A higher <a href="undocumented#Filter_Quality">Filter Quality</a> draws slower, but looks better. |
| 1749 | If the image is unscaled, the <a href="undocumented#Filter_Quality">Filter Quality</a> choice will not result in a noticable |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1750 | difference. |
| 1751 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1752 | <a href="undocumented#Filter_Quality">Filter Quality</a> is used in <a href="SkPaint_Reference#Paint">Paint</a> passed as a parameter to |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1753 | |
| 1754 | <table> <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1755 | <td><a href="SkCanvas_Reference#drawBitmap">SkCanvas::drawBitmap</a></td> </tr> <tr> |
| 1756 | <td><a href="SkCanvas_Reference#drawBitmapRect">SkCanvas::drawBitmapRect</a></td> </tr> <tr> |
| 1757 | <td><a href="SkCanvas_Reference#drawImage">SkCanvas::drawImage</a></td> </tr> <tr> |
| 1758 | <td><a href="SkCanvas_Reference#drawImageRect">SkCanvas::drawImageRect</a></td> </tr> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1759 | </table> |
| 1760 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1761 | and when <a href="SkPaint_Reference#Paint">Paint</a> has a <a href="undocumented#Shader">Shader</a> specialization that uses <a href="undocumented#Image">Image</a> or <a href="undocumented#Bitmap">Bitmap</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1762 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1763 | <a href="undocumented#Filter_Quality">Filter Quality</a> is <a href="undocumented#SkFilterQuality">kNone SkFilterQuality</a> by default. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1764 | |
| 1765 | ### Example |
| 1766 | |
| 1767 | <div><fiddle-embed name="ee77f83f7291e07ae0d89f1380c7d67c"></fiddle-embed></div> |
| 1768 | |
| 1769 | <a name="getFilterQuality"></a> |
| 1770 | ## getFilterQuality |
| 1771 | |
| 1772 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1773 | SkFilterQuality getFilterQuality() const |
| 1774 | </pre> |
| 1775 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1776 | Returns <a href="undocumented#Filter_Quality">Filter Quality</a>, the image filtering level. A lower setting |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1777 | draws faster; a higher setting looks better when the image is scaled. |
| 1778 | |
| 1779 | ### Return Value |
| 1780 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1781 | one of: <a href="undocumented#SkFilterQuality">kNone SkFilterQuality</a>, <a href="undocumented#SkFilterQuality">kLow SkFilterQuality</a>, |
| 1782 | <a href="undocumented#SkFilterQuality">kMedium SkFilterQuality</a>, <a href="undocumented#SkFilterQuality">kHigh SkFilterQuality</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1783 | |
| 1784 | ### Example |
| 1785 | |
| 1786 | <div><fiddle-embed name="d4ca1f23809b6835c4ba46ea98a86900"> |
| 1787 | |
| 1788 | #### Example Output |
| 1789 | |
| 1790 | ~~~~ |
| 1791 | kNone_SkFilterQuality == paint.getFilterQuality() |
| 1792 | ~~~~ |
| 1793 | |
| 1794 | </fiddle-embed></div> |
| 1795 | |
| 1796 | --- |
| 1797 | |
| 1798 | <a name="setFilterQuality"></a> |
| 1799 | ## setFilterQuality |
| 1800 | |
| 1801 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1802 | void setFilterQuality(SkFilterQuality quality) |
| 1803 | </pre> |
| 1804 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1805 | Sets <a href="undocumented#Filter_Quality">Filter Quality</a>, the image filtering level. A lower setting |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1806 | draws faster; a higher setting looks better when the image is scaled. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1807 | Does not check to see if <a href="SkPaint_Reference#setFilterQuality">quality</a> is valid. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1808 | |
| 1809 | ### Parameters |
| 1810 | |
| 1811 | <table> <tr> <td><code><strong>quality </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1812 | one of: <a href="undocumented#SkFilterQuality">kNone SkFilterQuality</a>, <a href="undocumented#SkFilterQuality">kLow SkFilterQuality</a>, |
| 1813 | <a href="undocumented#SkFilterQuality">kMedium SkFilterQuality</a>, <a href="undocumented#SkFilterQuality">kHigh SkFilterQuality</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1814 | </tr> |
| 1815 | </table> |
| 1816 | |
| 1817 | ### Example |
| 1818 | |
| 1819 | <div><fiddle-embed name="e4288fabf24ee60b645e8bb6ea0afadf"> |
| 1820 | |
| 1821 | #### Example Output |
| 1822 | |
| 1823 | ~~~~ |
| 1824 | kHigh_SkFilterQuality == paint.getFilterQuality() |
| 1825 | ~~~~ |
| 1826 | |
| 1827 | </fiddle-embed></div> |
| 1828 | |
| 1829 | ### See Also |
| 1830 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1831 | <a href="undocumented#SkFilterQuality">SkFilterQuality</a> <a href="undocumented#Image_Scaling">Image Scaling</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1832 | |
| 1833 | --- |
| 1834 | |
| 1835 | # <a name="Color_Methods"></a> Color Methods |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1836 | <a href="undocumented#Color">Color</a> specifies the <a href="undocumented#RGB_Red">Color RGB Red</a>, <a href="undocumented#RGB_Blue">Color RGB Blue</a>, <a href="undocumented#RGB_Green">Color RGB Green</a>, and <a href="undocumented#Alpha">Color Alpha</a> values used to draw a filled |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1837 | or stroked shape in a |
| 1838 | 32-bit value. Each component occupies 8-bits, ranging from zero: no contribution; |
| 1839 | to 255: full intensity. All values in any combination are valid. |
| 1840 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1841 | <a href="undocumented#Color">Color</a> is not premultiplied; |
| 1842 | <a href="undocumented#Alpha">Color Alpha</a> sets the transparency independent of <a href="undocumented#RGB">Color RGB</a>: <a href="undocumented#RGB_Red">Color RGB Red</a>, <a href="undocumented#RGB_Blue">Color RGB Blue</a>, and <a href="undocumented#RGB_Green">Color RGB Green</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1843 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1844 | The bit positions of <a href="undocumented#Alpha">Color Alpha</a> and <a href="undocumented#RGB">Color RGB</a> are independent of the bit positions |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1845 | on the output device, which may have more or fewer bits, and may have a different arrangement. |
| 1846 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1847 | | bit positions | <a href="undocumented#Alpha">Color Alpha</a> | <a href="undocumented#RGB_Red">Color RGB Red</a> | <a href="undocumented#RGB_Blue">Color RGB Blue</a> | <a href="undocumented#RGB_Green">Color RGB Green</a> | |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1848 | | --- | --- | --- | --- | --- | |
| 1849 | | | 31 - 24 | 23 - 16 | 15 - 8 | 7 - 0 | |
| 1850 | |
| 1851 | ### Example |
| 1852 | |
| 1853 | <div><fiddle-embed name="214b559d75c65a7bef6ef4be1f860053"></fiddle-embed></div> |
| 1854 | |
| 1855 | <a name="getColor"></a> |
| 1856 | ## getColor |
| 1857 | |
| 1858 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1859 | SkColor getColor() const |
| 1860 | </pre> |
| 1861 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1862 | Retrieves <a href="undocumented#Alpha">Color Alpha</a> and <a href="undocumented#RGB">Color RGB</a>, unpremultiplied, packed into 32 bits. |
| 1863 | Use helpers <a href="undocumented#SkColorGetA">SkColorGetA</a>, <a href="undocumented#SkColorGetR">SkColorGetR</a>, <a href="undocumented#SkColorGetG">SkColorGetG</a>, and <a href="undocumented#SkColorGetB">SkColorGetB</a> to extract |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1864 | a color component. |
| 1865 | |
| 1866 | ### Return Value |
| 1867 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1868 | <a href="undocumented#Unpremultiplied">Unpremultiplied</a> <a href="undocumented#ARGB">Color ARGB</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1869 | |
| 1870 | ### Example |
| 1871 | |
| 1872 | <div><fiddle-embed name="72d41f890203109a41f589a7403acae9"> |
| 1873 | |
| 1874 | #### Example Output |
| 1875 | |
| 1876 | ~~~~ |
| 1877 | Yellow is 100% red, 100% green, and 0% blue. |
| 1878 | ~~~~ |
| 1879 | |
| 1880 | </fiddle-embed></div> |
| 1881 | |
| 1882 | ### See Also |
| 1883 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1884 | <a href="undocumented#SkColor">SkColor</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1885 | |
| 1886 | --- |
| 1887 | |
| 1888 | <a name="setColor"></a> |
| 1889 | ## setColor |
| 1890 | |
| 1891 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1892 | void setColor(SkColor color) |
| 1893 | </pre> |
| 1894 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1895 | Sets <a href="undocumented#Alpha">Color Alpha</a> and <a href="undocumented#RGB">Color RGB</a> used when stroking and filling. The <a href="SkPaint_Reference#color">color</a> is a 32-bit value, |
| 1896 | unpremutiplied, packing 8-bit components for <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#RGB_Red">Color RGB Red</a>, <a href="undocumented#RGB_Blue">Color RGB Blue</a>, and <a href="undocumented#RGB_Green">Color RGB Green</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1897 | |
| 1898 | ### Parameters |
| 1899 | |
| 1900 | <table> <tr> <td><code><strong>color </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1901 | <a href="undocumented#Unpremultiplied">Unpremultiplied</a> <a href="undocumented#ARGB">Color ARGB</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1902 | </tr> |
| 1903 | </table> |
| 1904 | |
| 1905 | ### Example |
| 1906 | |
| 1907 | <div><fiddle-embed name="6e70f18300bd676a3c056ceb6b62f8df"> |
| 1908 | |
| 1909 | #### Example Output |
| 1910 | |
| 1911 | ~~~~ |
| 1912 | green1 == green2 |
| 1913 | ~~~~ |
| 1914 | |
| 1915 | </fiddle-embed></div> |
| 1916 | |
| 1917 | ### See Also |
| 1918 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1919 | <a href="undocumented#SkColor">SkColor</a> <a href="SkPaint_Reference#setARGB">setARGB</a> <a href="undocumented#SkColorSetARGB">SkColorSetARGB</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1920 | |
| 1921 | --- |
| 1922 | |
| 1923 | ## <a name="Alpha_Methods"></a> Alpha Methods |
| 1924 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1925 | <a href="undocumented#Alpha">Color Alpha</a> sets the transparency independent of <a href="undocumented#RGB">Color RGB</a>: <a href="undocumented#RGB_Red">Color RGB Red</a>, <a href="undocumented#RGB_Blue">Color RGB Blue</a>, and <a href="undocumented#RGB_Green">Color RGB Green</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1926 | |
| 1927 | <a name="getAlpha"></a> |
| 1928 | ## getAlpha |
| 1929 | |
| 1930 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1931 | uint8_t getAlpha() const |
| 1932 | </pre> |
| 1933 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1934 | Retrieves <a href="undocumented#Alpha">Color Alpha</a> from the <a href="undocumented#Color">Color</a> used when stroking and filling. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1935 | |
| 1936 | ### Return Value |
| 1937 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1938 | <a href="undocumented#Alpha">Color Alpha</a> ranging from zero, fully transparent, to 255, fully opaque |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1939 | |
| 1940 | ### Example |
| 1941 | |
| 1942 | <div><fiddle-embed name="9a85bb62fe3d877b18fb7f952c4fa7f7"> |
| 1943 | |
| 1944 | #### Example Output |
| 1945 | |
| 1946 | ~~~~ |
| 1947 | 255 == paint.getAlpha() |
| 1948 | ~~~~ |
| 1949 | |
| 1950 | </fiddle-embed></div> |
| 1951 | |
| 1952 | --- |
| 1953 | |
| 1954 | <a name="setAlpha"></a> |
| 1955 | ## setAlpha |
| 1956 | |
| 1957 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1958 | void setAlpha(U8CPU a) |
| 1959 | </pre> |
| 1960 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1961 | Replaces <a href="undocumented#Alpha">Color Alpha</a>, leaving <a href="undocumented#RGB">Color RGB</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1962 | unchanged. An out of range value triggers an assert in the debug |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1963 | build. <a href="SkPaint_Reference#a">a</a> is <a href="SkPaint_Reference#a">a</a> value from zero to 255. |
| 1964 | <a href="SkPaint_Reference#a">a</a> set to zero makes <a href="undocumented#Color">Color</a> fully transparent; <a href="SkPaint_Reference#a">a</a> set to 255 makes <a href="undocumented#Color">Color</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1965 | fully opaque. |
| 1966 | |
| 1967 | ### Parameters |
| 1968 | |
| 1969 | <table> <tr> <td><code><strong>a </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1970 | <a href="undocumented#Alpha">Color Alpha</a> component of <a href="undocumented#Color">Color</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1971 | </tr> |
| 1972 | </table> |
| 1973 | |
| 1974 | ### Example |
| 1975 | |
| 1976 | <div><fiddle-embed name="6ddc0360512dfb9947e75c17e6a8103d"> |
| 1977 | |
| 1978 | #### Example Output |
| 1979 | |
| 1980 | ~~~~ |
| 1981 | 0x44112233 == paint.getColor() |
| 1982 | ~~~~ |
| 1983 | |
| 1984 | </fiddle-embed></div> |
| 1985 | |
| 1986 | --- |
| 1987 | |
| 1988 | <a name="setARGB"></a> |
| 1989 | ## setARGB |
| 1990 | |
| 1991 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 1992 | void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) |
| 1993 | </pre> |
| 1994 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1995 | Sets <a href="undocumented#Color">Color</a> used when drawing solid fills. The color components range from 0 to 255. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1996 | The color is unpremultiplied; |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 1997 | <a href="undocumented#Alpha">Color Alpha</a> sets the transparency independent of <a href="undocumented#RGB">Color RGB</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 1998 | |
| 1999 | ### Parameters |
| 2000 | |
| 2001 | <table> <tr> <td><code><strong>a </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2002 | amount of <a href="undocumented#Alpha">Color Alpha</a>, from fully transparent (0) to fully opaque (255)</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2003 | </tr> <tr> <td><code><strong>r </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2004 | amount of <a href="undocumented#RGB_Red">Color RGB Red</a>, from no red (0) to full red (255)</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2005 | </tr> <tr> <td><code><strong>g </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2006 | amount of <a href="undocumented#RGB_Green">Color RGB Green</a>, from no green (0) to full green (255)</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2007 | </tr> <tr> <td><code><strong>b </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2008 | amount of <a href="undocumented#RGB_Blue">Color RGB Blue</a>, from no blue (0) to full blue (255)</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2009 | </tr> |
| 2010 | </table> |
| 2011 | |
| 2012 | ### Example |
| 2013 | |
| 2014 | <div><fiddle-embed name="cb62e4755789ed32f7120dc55984959d"> |
| 2015 | |
| 2016 | #### Example Output |
| 2017 | |
| 2018 | ~~~~ |
| 2019 | transRed1 == transRed2 |
| 2020 | ~~~~ |
| 2021 | |
| 2022 | </fiddle-embed></div> |
| 2023 | |
| 2024 | ### See Also |
| 2025 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2026 | <a href="SkPaint_Reference#setColor">setColor</a> <a href="undocumented#SkColorSetARGB">SkColorSetARGB</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2027 | |
| 2028 | --- |
| 2029 | |
| 2030 | # <a name="Style"></a> Style |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2031 | <a href="SkPaint_Reference#Style">Style</a> specifies if the geometry is filled, stroked, or both filled and stroked. |
| 2032 | Some shapes ignore <a href="SkPaint_Reference#Style">Style</a> and are always drawn filled or stroked. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2033 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2034 | Set <a href="SkPaint_Reference#Style">Style</a> to <a href="SkPaint_Reference#kFill_Style">kFill Style</a> to fill the shape. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2035 | The fill covers the area inside the geometry for most shapes. |
| 2036 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2037 | Set <a href="SkPaint_Reference#Style">Style</a> to <a href="SkPaint_Reference#kStroke_Style">kStroke Style</a> to stroke the shape. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2038 | |
| 2039 | ## <a name="Fill"></a> Fill |
| 2040 | |
| 2041 | ### See Also |
| 2042 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2043 | <a href="SkPath_Reference#Fill_Type">Path Fill Type</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2044 | |
| 2045 | ## <a name="Stroke"></a> Stroke |
| 2046 | |
| 2047 | The stroke covers the area described by following the shape's edge with a pen or brush of |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2048 | <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a>. The area covered where the shape starts and stops is described by <a href="SkPaint_Reference#Stroke_Cap">Stroke Cap</a>. |
| 2049 | The area covered where the shape turns a corner is described by <a href="SkPaint_Reference#Stroke_Join">Stroke Join</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2050 | The stroke is centered on the shape; it extends equally on either side of the shape's edge. |
| 2051 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2052 | As <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> gets smaller, the drawn path frame is thinner. <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> less than one |
| 2053 | may have gaps, and if <a href="SkPaint_Reference#kAntiAlias_Flag">kAntiAlias Flag</a> is set, <a href="undocumented#Alpha">Color Alpha</a> will increase to visually decrease coverage. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2054 | |
| 2055 | ## <a name="Hairline"></a> Hairline |
| 2056 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2057 | <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> of zero has a special meaning and switches drawing to use <a href="SkPaint_Reference#Hairline">Hairline</a>. |
| 2058 | <a href="SkPaint_Reference#Hairline">Hairline</a> draws the thinnest continuous frame. If <a href="SkPaint_Reference#kAntiAlias_Flag">kAntiAlias Flag</a> is clear, adjacent pixels |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2059 | flow horizontally, vertically,or diagonally. |
| 2060 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2061 | <a href="SkPath_Reference#Path">Path</a> drawing with <a href="SkPaint_Reference#Hairline">Hairline</a> may hit the same pixel more than once. For instance, <a href="SkPath_Reference#Path">Path</a> containing |
| 2062 | two lines in one <a href="SkPath_Reference#Contour">Path Contour</a> will draw the corner point once, but may both lines may draw the adjacent |
| 2063 | pixel. If <a href="SkPaint_Reference#kAntiAlias_Flag">kAntiAlias Flag</a> is set, transparency is applied twice, resulting in a darker pixel. Some |
| 2064 | <a href="undocumented#GPU_backed">GPU-backed</a> implementations apply transparency at a later drawing stage, avoiding double hit pixels |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2065 | while stroking. |
| 2066 | |
| 2067 | ## <a name="SkPaint::Style"></a> Enum SkPaint::Style |
| 2068 | |
| 2069 | <pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0"> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2070 | enum <a href="SkPaint_Reference#Style">Style</a> { |
| 2071 | <a href="SkPaint_Reference#kFill_Style">kFill Style</a>, |
| 2072 | <a href="SkPaint_Reference#kStroke_Style">kStroke Style</a>, |
| 2073 | <a href="SkPaint_Reference#kStrokeAndFill_Style">kStrokeAndFill Style</a>, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2074 | };</pre> |
| 2075 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2076 | Set <a href="SkPaint_Reference#Style">Style</a> to fill, stroke, or both fill and stroke geometry. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2077 | The stroke and fill |
| 2078 | share all paint attributes; for instance, they are drawn with the same color. |
| 2079 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2080 | Use <a href="SkPaint_Reference#kStrokeAndFill_Style">kStrokeAndFill Style</a> to avoid hitting the same pixels twice with a stroke draw and |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2081 | a fill draw. |
| 2082 | |
| 2083 | ### Constants |
| 2084 | |
| 2085 | <table> |
| 2086 | <tr> |
| 2087 | <td><a name="SkPaint::kFill_Style"></a> <code><strong>SkPaint::kFill_Style </strong></code></td><td>0</td><td>Set to fill geometry. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2088 | Applies to <a href="undocumented#Rect">Rect</a>, <a href="undocumented#Region">Region</a>, <a href="undocumented#Round_Rect">Round Rect</a>, <a href="undocumented#Circle">Circle</a>, <a href="undocumented#Oval">Oval</a>, <a href="SkPath_Reference#Path">Path</a>, and <a href="undocumented#Text">Text</a>. |
| 2089 | <a href="undocumented#Bitmap">Bitmap</a>, <a href="undocumented#Image">Image</a>, <a href="undocumented#Patch">Patch</a>, <a href="undocumented#Region">Region</a>, <a href="undocumented#Sprite">Sprite</a>, and <a href="undocumented#Vertices">Vertices</a> are painted as if |
| 2090 | <a href="SkPaint_Reference#kFill_Style">kFill Style</a> is set, and ignore the set <a href="SkPaint_Reference#Style">Style</a>. |
| 2091 | The <a href="SkPath_Reference#Fill_Type">Path Fill Type</a> specifies additional rules to fill the area outside the path edge, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2092 | and to create an unfilled hole inside the shape. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2093 | <a href="SkPaint_Reference#Style">Style</a> is set to <a href="SkPaint_Reference#kFill_Style">kFill Style</a> by default.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2094 | </tr> |
| 2095 | <tr> |
| 2096 | <td><a name="SkPaint::kStroke_Style"></a> <code><strong>SkPaint::kStroke_Style </strong></code></td><td>1</td><td>Set to stroke geometry. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2097 | Applies to <a href="undocumented#Rect">Rect</a>, <a href="undocumented#Region">Region</a>, <a href="undocumented#Round_Rect">Round Rect</a>, <a href="undocumented#Arc">Arc</a>, <a href="undocumented#Circle">Circle</a>, <a href="undocumented#Oval">Oval</a>, |
| 2098 | <a href="SkPath_Reference#Path">Path</a>, and <a href="undocumented#Text">Text</a>. |
| 2099 | <a href="undocumented#Arc">Arc</a>, <a href="undocumented#Line">Line</a>, <a href="undocumented#Point">Point</a>, and <a href="undocumented#Array">Point Array</a> are always drawn as if <a href="SkPaint_Reference#kStroke_Style">kStroke Style</a> is set, |
| 2100 | and ignore the set <a href="SkPaint_Reference#Style">Style</a>. |
| 2101 | The stroke construction is unaffected by the <a href="SkPath_Reference#Fill_Type">Path Fill Type</a>.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2102 | </tr> |
| 2103 | <tr> |
| 2104 | <td><a name="SkPaint::kStrokeAndFill_Style"></a> <code><strong>SkPaint::kStrokeAndFill_Style </strong></code></td><td>2</td><td>Set to stroke and fill geometry. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2105 | Applies to <a href="undocumented#Rect">Rect</a>, <a href="undocumented#Region">Region</a>, <a href="undocumented#Round_Rect">Round Rect</a>, <a href="undocumented#Circle">Circle</a>, <a href="undocumented#Oval">Oval</a>, <a href="SkPath_Reference#Path">Path</a>, and <a href="undocumented#Text">Text</a>. |
| 2106 | <a href="SkPath_Reference#Path">Path</a> is treated as if it is set to <a href="SkPath_Reference#kWinding_FillType">SkPath::kWinding FillType</a>, |
| 2107 | and the set <a href="SkPath_Reference#Fill_Type">Path Fill Type</a> is ignored.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2108 | </tr> |
| 2109 | |
| 2110 | </table> |
| 2111 | |
| 2112 | ## <a name="SkPaint::_anonymous"></a> Enum SkPaint::_anonymous |
| 2113 | |
| 2114 | <pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0"> |
| 2115 | enum { |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2116 | <a href="SkPaint_Reference#kStyleCount">kStyleCount</a> = <a href="SkPaint_Reference#kStrokeAndFill_Style">kStrokeAndFill Style</a> + 1, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2117 | };</pre> |
| 2118 | |
| 2119 | ### Constants |
| 2120 | |
| 2121 | <table> |
| 2122 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2123 | <td><a name="SkPaint::kStyleCount"></a> <code><strong>SkPaint::kStyleCount </strong></code></td><td>3</td><td>The number of different <a href="SkPaint_Reference#Style">Style</a> values defined. |
| 2124 | May be used to verify that <a href="SkPaint_Reference#Style">Style</a> is a legal value.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2125 | </tr> |
| 2126 | |
| 2127 | </table> |
| 2128 | |
| 2129 | <a name="getStyle"></a> |
| 2130 | ## getStyle |
| 2131 | |
| 2132 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2133 | Style getStyle() const |
| 2134 | </pre> |
| 2135 | |
| 2136 | Whether the geometry is filled, stroked, or filled and stroked. |
| 2137 | |
| 2138 | ### Return Value |
| 2139 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2140 | one of:<a href="SkPaint_Reference#kFill_Style">kFill Style</a>, <a href="SkPaint_Reference#kStroke_Style">kStroke Style</a>, <a href="SkPaint_Reference#kStrokeAndFill_Style">kStrokeAndFill Style</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2141 | |
| 2142 | ### Example |
| 2143 | |
| 2144 | <div><fiddle-embed name="1c5e18c3c0102d2dac86a78ba8c8ce01"> |
| 2145 | |
| 2146 | #### Example Output |
| 2147 | |
| 2148 | ~~~~ |
| 2149 | SkPaint::kFill_Style == paint.getStyle() |
| 2150 | ~~~~ |
| 2151 | |
| 2152 | </fiddle-embed></div> |
| 2153 | |
| 2154 | ### See Also |
| 2155 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2156 | <a href="SkPaint_Reference#Style">Style</a> <a href="SkPaint_Reference#setStyle">setStyle</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2157 | |
| 2158 | --- |
| 2159 | |
| 2160 | <a name="setStyle"></a> |
| 2161 | ## setStyle |
| 2162 | |
| 2163 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2164 | void setStyle(Style style) |
| 2165 | </pre> |
| 2166 | |
| 2167 | Sets whether the geometry is filled, stroked, or filled and stroked. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2168 | Has no effect if <a href="SkPaint_Reference#setStyle">style</a> is not a legal <a href="SkPaint_Reference#Style">Style</a> value. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2169 | |
| 2170 | ### Parameters |
| 2171 | |
| 2172 | <table> <tr> <td><code><strong>style </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2173 | one of: <a href="SkPaint_Reference#kFill_Style">kFill Style</a>, <a href="SkPaint_Reference#kStroke_Style">kStroke Style</a>, <a href="SkPaint_Reference#kStrokeAndFill_Style">kStrokeAndFill Style</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2174 | </tr> |
| 2175 | </table> |
| 2176 | |
| 2177 | ### Example |
| 2178 | |
| 2179 | <div><fiddle-embed name="c7bb6248e4735b8d1a32d02fba40d344"></fiddle-embed></div> |
| 2180 | |
| 2181 | ### See Also |
| 2182 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2183 | <a href="SkPaint_Reference#Style">Style</a> <a href="SkPaint_Reference#getStyle">getStyle</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2184 | |
| 2185 | --- |
| 2186 | |
| 2187 | ### See Also |
| 2188 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2189 | <a href="SkPath_Reference#Fill_Type">Path Fill Type</a> <a href="undocumented#Path_Effect">Path Effect</a> <a href="SkPaint_Reference#Style_Fill">Style Fill</a> <a href="SkPaint_Reference#Style_Stroke">Style Stroke</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2190 | |
| 2191 | # <a name="Stroke_Width"></a> Stroke Width |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2192 | <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> sets the width for stroking. The width is the thickness |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2193 | of the stroke perpendicular to the path's direction when the paint's style is |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2194 | set to <a href="SkPaint_Reference#kStroke_Style">kStroke Style</a> or <a href="SkPaint_Reference#kStrokeAndFill_Style">kStrokeAndFill Style</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2195 | |
| 2196 | When width is greater than zero, the stroke encompasses as many pixels partially |
| 2197 | or fully as needed. When the width equals zero, the paint enables hairlines; |
| 2198 | the stroke is always one pixel wide. |
| 2199 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2200 | The stroke's dimensions are scaled by the canvas matrix, but <a href="SkPaint_Reference#Hairline">Hairline</a> stroke |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2201 | remains one pixel wide regardless of scaling. |
| 2202 | |
| 2203 | The default width for the paint is zero. |
| 2204 | |
| 2205 | ### Example |
| 2206 | |
| 2207 | <div><fiddle-embed name="01e3e08a3022a351628ff54e84887756">raster gpu<div>The pixels hit to represent thin lines vary with the angle of the |
| 2208 | line and the platform's implementation.</div></fiddle-embed></div> |
| 2209 | |
| 2210 | <a name="getStrokeWidth"></a> |
| 2211 | ## getStrokeWidth |
| 2212 | |
| 2213 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2214 | SkScalar getStrokeWidth() const |
| 2215 | </pre> |
| 2216 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2217 | Returns the thickness of the pen used by <a href="SkPaint_Reference#Paint">Paint</a> to |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2218 | outline the shape. |
| 2219 | |
| 2220 | ### Return Value |
| 2221 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2222 | zero for <a href="SkPaint_Reference#Hairline">Hairline</a>, greater than zero for pen thickness |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2223 | |
| 2224 | ### Example |
| 2225 | |
| 2226 | <div><fiddle-embed name="99aa73f64df8bbf06e656cd891a81b9e"> |
| 2227 | |
| 2228 | #### Example Output |
| 2229 | |
| 2230 | ~~~~ |
| 2231 | 0 == paint.getStrokeWidth() |
| 2232 | ~~~~ |
| 2233 | |
| 2234 | </fiddle-embed></div> |
| 2235 | |
| 2236 | --- |
| 2237 | |
| 2238 | <a name="setStrokeWidth"></a> |
| 2239 | ## setStrokeWidth |
| 2240 | |
| 2241 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2242 | void setStrokeWidth(SkScalar width) |
| 2243 | </pre> |
| 2244 | |
| 2245 | Sets the thickness of the pen used by the paint to |
| 2246 | outline the shape. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2247 | Has no effect if <a href="SkPaint_Reference#setStrokeWidth">width</a> is less than zero. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2248 | |
| 2249 | ### Parameters |
| 2250 | |
| 2251 | <table> <tr> <td><code><strong>width </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2252 | zero thickness for <a href="SkPaint_Reference#Hairline">Hairline</a>; greater than zero for pen thickness</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2253 | </tr> |
| 2254 | </table> |
| 2255 | |
| 2256 | ### Example |
| 2257 | |
| 2258 | <div><fiddle-embed name="0c4446c0870b5c7b5a2efe77ff92afb8"> |
| 2259 | |
| 2260 | #### Example Output |
| 2261 | |
| 2262 | ~~~~ |
| 2263 | 5 == paint.getStrokeWidth() |
| 2264 | ~~~~ |
| 2265 | |
| 2266 | </fiddle-embed></div> |
| 2267 | |
| 2268 | --- |
| 2269 | |
| 2270 | # <a name="Miter_Limit"></a> Miter Limit |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2271 | <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a> specifies the maximum miter length, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2272 | relative to the stroke width. |
| 2273 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2274 | <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a> is used when the <a href="SkPaint_Reference#Stroke_Join">Stroke Join</a> |
| 2275 | is set to <a href="SkPaint_Reference#kMiter_Join">kMiter Join</a>, and the <a href="SkPaint_Reference#Style">Style</a> is either <a href="SkPaint_Reference#kStroke_Style">kStroke Style</a> |
| 2276 | or <a href="SkPaint_Reference#kStrokeAndFill_Style">kStrokeAndFill Style</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2277 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2278 | If the miter at a corner exceeds this limit, <a href="SkPaint_Reference#kMiter_Join">kMiter Join</a> |
| 2279 | is replaced with <a href="SkPaint_Reference#kBevel_Join">kBevel Join</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2280 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2281 | <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a> can be computed from the corner angle: |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2282 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2283 | miter limit = 1 / sin ( angle / 2 )<a href="SkPaint_Reference#Miter_Limit">Miter Limit</a> default value is 4. |
| 2284 | The default may be changed at compile time by setting <a href="undocumented#SkPaintDefaults_MiterLimit">SkPaintDefaults MiterLimit</a> |
| 2285 | in <a href="undocumented#SkUserConfig.h">SkUserConfig.h</a> or as a define supplied by the build environment. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2286 | |
| 2287 | Here are some miter limits and the angles that triggers them. |
| 2288 | |
| 2289 | | miter limit | angle in degrees | |
| 2290 | | --- | --- | |
| 2291 | | 10 | 11.48 | |
| 2292 | | 9 | 12.76 | |
| 2293 | | 8 | 14.36 | |
| 2294 | | 7 | 16.43 | |
| 2295 | | 6 | 19.19 | |
| 2296 | | 5 | 23.07 | |
| 2297 | | 4 | 28.96 | |
| 2298 | | 3 | 38.94 | |
| 2299 | | 2 | 60 | |
| 2300 | | 1 | 180 | |
| 2301 | |
| 2302 | ### Example |
| 2303 | |
| 2304 | <div><fiddle-embed name="5de2de0f00354e59074a9bb1a42d5a63"><div>This example draws a stroked corner and the miter length beneath. |
| 2305 | When the miter limit is decreased slightly, the miter join is replaced |
| 2306 | by a bevel join.</div></fiddle-embed></div> |
| 2307 | |
| 2308 | <a name="getStrokeMiter"></a> |
| 2309 | ## getStrokeMiter |
| 2310 | |
| 2311 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2312 | SkScalar getStrokeMiter() const |
| 2313 | </pre> |
| 2314 | |
| 2315 | The limit at which a sharp corner is drawn beveled. |
| 2316 | |
| 2317 | ### Return Value |
| 2318 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2319 | zero and greater <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2320 | |
| 2321 | ### Example |
| 2322 | |
| 2323 | <div><fiddle-embed name="50da74a43b725f07a914df588c867d36"> |
| 2324 | |
| 2325 | #### Example Output |
| 2326 | |
| 2327 | ~~~~ |
| 2328 | default miter limit == 4 |
| 2329 | ~~~~ |
| 2330 | |
| 2331 | </fiddle-embed></div> |
| 2332 | |
| 2333 | ### See Also |
| 2334 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2335 | <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a> <a href="SkPaint_Reference#setStrokeMiter">setStrokeMiter</a> <a href="SkPaint_Reference#Join">Join</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2336 | |
| 2337 | --- |
| 2338 | |
| 2339 | <a name="setStrokeMiter"></a> |
| 2340 | ## setStrokeMiter |
| 2341 | |
| 2342 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2343 | void setStrokeMiter(SkScalar miter) |
| 2344 | </pre> |
| 2345 | |
| 2346 | The limit at which a sharp corner is drawn beveled. |
| 2347 | Valid values are zero and greater. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2348 | Has no effect if <a href="SkPaint_Reference#setStrokeMiter">miter</a> is less than zero. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2349 | |
| 2350 | ### Parameters |
| 2351 | |
| 2352 | <table> <tr> <td><code><strong>miter </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2353 | zero and greater <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2354 | </tr> |
| 2355 | </table> |
| 2356 | |
| 2357 | ### Example |
| 2358 | |
| 2359 | <div><fiddle-embed name="700b284dbc97785c6a9c9636088713ad"> |
| 2360 | |
| 2361 | #### Example Output |
| 2362 | |
| 2363 | ~~~~ |
| 2364 | default miter limit == 8 |
| 2365 | ~~~~ |
| 2366 | |
| 2367 | </fiddle-embed></div> |
| 2368 | |
| 2369 | ### See Also |
| 2370 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2371 | <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a> <a href="SkPaint_Reference#getStrokeMiter">getStrokeMiter</a> <a href="SkPaint_Reference#Join">Join</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2372 | |
| 2373 | --- |
| 2374 | |
| 2375 | # <a name="Stroke_Cap"></a> Stroke Cap |
| 2376 | |
| 2377 | ## <a name="SkPaint::Cap"></a> Enum SkPaint::Cap |
| 2378 | |
| 2379 | <pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0"> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2380 | enum <a href="SkPaint_Reference#Cap">Cap</a> { |
| 2381 | <a href="SkPaint_Reference#kButt_Cap">kButt Cap</a>, |
| 2382 | <a href="SkPaint_Reference#kRound_Cap">kRound Cap</a>, |
| 2383 | <a href="SkPaint_Reference#kSquare_Cap">kSquare Cap</a>, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2384 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2385 | <a href="SkPaint_Reference#kLast_Cap">kLast Cap</a> = <a href="SkPaint_Reference#kSquare_Cap">kSquare Cap</a>, |
| 2386 | <a href="SkPaint_Reference#kDefault_Cap">kDefault Cap</a> = <a href="SkPaint_Reference#kButt_Cap">kButt Cap</a>, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2387 | }; |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2388 | static constexpr int <a href="SkPaint_Reference#kCapCount">kCapCount</a> = <a href="SkPaint_Reference#kLast_Cap">kLast Cap</a> + 1;</pre> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2389 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2390 | <a href="SkPaint_Reference#Stroke_Cap">Stroke Cap</a> draws at the beginning and end of an open <a href="SkPath_Reference#Contour">Path Contour</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2391 | |
| 2392 | ### Constants |
| 2393 | |
| 2394 | <table> |
| 2395 | <tr> |
| 2396 | <td><a name="SkPaint::kButt_Cap"></a> <code><strong>SkPaint::kButt_Cap </strong></code></td><td>0</td><td>Does not extend the stroke past the beginning or the end.</td> |
| 2397 | </tr> |
| 2398 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2399 | <td><a name="SkPaint::kRound_Cap"></a> <code><strong>SkPaint::kRound_Cap </strong></code></td><td>1</td><td>Adds a circle with a diameter equal to <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> at the beginning |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2400 | and end.</td> |
| 2401 | </tr> |
| 2402 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2403 | <td><a name="SkPaint::kSquare_Cap"></a> <code><strong>SkPaint::kSquare_Cap </strong></code></td><td>2</td><td>Adds a square with sides equal to <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> at the beginning |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2404 | and end. The square sides are parallel to the initial and final direction |
| 2405 | of the stroke.</td> |
| 2406 | </tr> |
| 2407 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2408 | <td><a name="SkPaint::kLast_Cap"></a> <code><strong>SkPaint::kLast_Cap </strong></code></td><td>2</td><td>Equivalent to the largest value for <a href="SkPaint_Reference#Stroke_Cap">Stroke Cap</a>.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2409 | </tr> |
| 2410 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2411 | <td><a name="SkPaint::kDefault_Cap"></a> <code><strong>SkPaint::kDefault_Cap </strong></code></td><td>0</td><td>Equivalent to <a href="SkPaint_Reference#kButt_Cap">kButt Cap</a>. |
| 2412 | <a href="SkPaint_Reference#Stroke_Cap">Stroke Cap</a> is set to <a href="SkPaint_Reference#kButt_Cap">kButt Cap</a> by default.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2413 | </tr> |
| 2414 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2415 | <td><a name="SkPaint::kCapCount"></a> <code><strong>SkPaint::kCapCount </strong></code></td><td>3</td><td>The number of different <a href="SkPaint_Reference#Stroke_Cap">Stroke Cap</a> values defined. |
| 2416 | May be used to verify that <a href="SkPaint_Reference#Stroke_Cap">Stroke Cap</a> is a legal value.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2417 | </tr> |
| 2418 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2419 | Stroke describes the area covered by a pen of <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> as it |
| 2420 | follows the <a href="SkPath_Reference#Contour">Path Contour</a>, moving parallel to the contours's direction. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2421 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2422 | If the <a href="SkPath_Reference#Contour">Path Contour</a> is not terminated by <a href="SkPath_Reference#kClose_Verb">SkPath::kClose Verb</a>, the contour has a |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2423 | visible beginning and end. |
| 2424 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2425 | <a href="SkPath_Reference#Contour">Path Contour</a> may start and end at the same point; defining <a href="SkPath_Reference#Zero_Length">Zero Length Contour</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2426 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2427 | <a href="SkPaint_Reference#kButt_Cap">kButt Cap</a> and <a href="SkPath_Reference#Zero_Length">Zero Length Contour</a> is not drawn. |
| 2428 | <a href="SkPaint_Reference#kRound_Cap">kRound Cap</a> and <a href="SkPath_Reference#Zero_Length">Zero Length Contour</a> draws a circle of diameter <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2429 | at the contour point. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2430 | <a href="SkPaint_Reference#kSquare_Cap">kSquare Cap</a> and <a href="SkPath_Reference#Zero_Length">Zero Length Contour</a> draws an upright square with a side of |
| 2431 | <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> at the contour point. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2432 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2433 | <a href="SkPaint_Reference#Stroke_Cap">Stroke Cap</a> is <a href="SkPaint_Reference#kButt_Cap">kButt Cap</a> by default. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2434 | |
| 2435 | </table> |
| 2436 | |
| 2437 | ### Example |
| 2438 | |
| 2439 | <div><fiddle-embed name="3d92b449b298b4ce4004cfca6b91cee7"></fiddle-embed></div> |
| 2440 | |
| 2441 | <a name="getStrokeCap"></a> |
| 2442 | ## getStrokeCap |
| 2443 | |
| 2444 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2445 | Cap getStrokeCap() const |
| 2446 | </pre> |
| 2447 | |
| 2448 | The geometry drawn at the beginning and end of strokes. |
| 2449 | |
| 2450 | ### Return Value |
| 2451 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2452 | one of: <a href="SkPaint_Reference#kButt_Cap">kButt Cap</a>, <a href="SkPaint_Reference#kRound_Cap">kRound Cap</a>, <a href="SkPaint_Reference#kSquare_Cap">kSquare Cap</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2453 | |
| 2454 | ### Example |
| 2455 | |
| 2456 | <div><fiddle-embed name="aabf9baee8e026fae36fca30e955512b"> |
| 2457 | |
| 2458 | #### Example Output |
| 2459 | |
| 2460 | ~~~~ |
| 2461 | kButt_Cap == default stroke cap |
| 2462 | ~~~~ |
| 2463 | |
| 2464 | </fiddle-embed></div> |
| 2465 | |
| 2466 | ### See Also |
| 2467 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2468 | <a href="SkPaint_Reference#Stroke_Cap">Stroke Cap</a> <a href="SkPaint_Reference#setStrokeCap">setStrokeCap</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2469 | |
| 2470 | --- |
| 2471 | |
| 2472 | <a name="setStrokeCap"></a> |
| 2473 | ## setStrokeCap |
| 2474 | |
| 2475 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2476 | void setStrokeCap(Cap cap) |
| 2477 | </pre> |
| 2478 | |
| 2479 | The geometry drawn at the beginning and end of strokes. |
| 2480 | |
| 2481 | ### Parameters |
| 2482 | |
| 2483 | <table> <tr> <td><code><strong>cap </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2484 | one of: <a href="SkPaint_Reference#kButt_Cap">kButt Cap</a>, <a href="SkPaint_Reference#kRound_Cap">kRound Cap</a>, <a href="SkPaint_Reference#kSquare_Cap">kSquare Cap</a>; |
| 2485 | has no effect if <a href="SkPaint_Reference#setStrokeCap">cap</a> is not valid</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2486 | </tr> |
| 2487 | </table> |
| 2488 | |
| 2489 | ### Example |
| 2490 | |
| 2491 | <div><fiddle-embed name="de83fbd848a4625345b4b87a6e55d98a"> |
| 2492 | |
| 2493 | #### Example Output |
| 2494 | |
| 2495 | ~~~~ |
| 2496 | kRound_Cap == paint.getStrokeCap() |
| 2497 | ~~~~ |
| 2498 | |
| 2499 | </fiddle-embed></div> |
| 2500 | |
| 2501 | ### See Also |
| 2502 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2503 | <a href="SkPaint_Reference#Stroke_Cap">Stroke Cap</a> <a href="SkPaint_Reference#getStrokeCap">getStrokeCap</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2504 | |
| 2505 | --- |
| 2506 | |
| 2507 | # <a name="Stroke_Join"></a> Stroke Join |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2508 | <a href="SkPaint_Reference#Stroke_Join">Stroke Join</a> draws at the sharp corners of an open or closed <a href="SkPath_Reference#Contour">Path Contour</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2509 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2510 | Stroke describes the area covered by a pen of <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> as it |
| 2511 | follows the <a href="SkPath_Reference#Contour">Path Contour</a>, moving parallel to the contours's direction. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2512 | |
| 2513 | If the contour direction changes abruptly, because the tangent direction leading |
| 2514 | to the end of a curve within the contour does not match the tangent direction of |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2515 | the following curve, the pair of curves meet at <a href="SkPaint_Reference#Stroke_Join">Stroke Join</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2516 | |
| 2517 | ### Example |
| 2518 | |
| 2519 | <div><fiddle-embed name="4a4e41ed89a57d47eab5d1600c33b0e8"></fiddle-embed></div> |
| 2520 | |
| 2521 | ## <a name="SkPaint::Join"></a> Enum SkPaint::Join |
| 2522 | |
| 2523 | <pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0"> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2524 | enum <a href="SkPaint_Reference#Join">Join</a> { |
| 2525 | <a href="SkPaint_Reference#kMiter_Join">kMiter Join</a>, |
| 2526 | <a href="SkPaint_Reference#kRound_Join">kRound Join</a>, |
| 2527 | <a href="SkPaint_Reference#kBevel_Join">kBevel Join</a>, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2528 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2529 | <a href="SkPaint_Reference#kLast_Join">kLast Join</a> = <a href="SkPaint_Reference#kBevel_Join">kBevel Join</a>, |
| 2530 | <a href="SkPaint_Reference#kDefault_Join">kDefault Join</a> = <a href="SkPaint_Reference#kMiter_Join">kMiter Join</a>, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2531 | }; |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2532 | static constexpr int <a href="SkPaint_Reference#kJoinCount">kJoinCount</a> = <a href="SkPaint_Reference#kLast_Join">kLast Join</a> + 1;</pre> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2533 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2534 | <a href="SkPaint_Reference#Join">Join</a> specifies how corners are drawn when a shape is stroked. <a href="SkPaint_Reference#Join">Join</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2535 | affects the four corners of a stroked rectangle, and the connected segments in a |
| 2536 | stroked path. |
| 2537 | |
| 2538 | Choose miter join to draw sharp corners. Choose round join to draw a circle with a |
| 2539 | radius equal to the stroke width on top of the corner. Choose bevel join to minimally |
| 2540 | connect the thick strokes. |
| 2541 | |
| 2542 | The fill path constructed to describe the stroked path respects the join setting but may |
| 2543 | not contain the actual join. For instance, a fill path constructed with round joins does |
| 2544 | not necessarily include circles at each connected segment. |
| 2545 | |
| 2546 | ### Constants |
| 2547 | |
| 2548 | <table> |
| 2549 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2550 | <td><a name="SkPaint::kMiter_Join"></a> <code><strong>SkPaint::kMiter_Join </strong></code></td><td>0</td><td>Extends the outside corner to the extent allowed by <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a>. |
| 2551 | If the extension exceeds <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a>, <a href="SkPaint_Reference#kBevel_Join">kBevel Join</a> is used instead.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2552 | </tr> |
| 2553 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2554 | <td><a name="SkPaint::kRound_Join"></a> <code><strong>SkPaint::kRound_Join </strong></code></td><td>1</td><td>Adds a circle with a diameter of <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> at the sharp corner.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2555 | </tr> |
| 2556 | <tr> |
| 2557 | <td><a name="SkPaint::kBevel_Join"></a> <code><strong>SkPaint::kBevel_Join </strong></code></td><td>2</td><td>Connects the outside edges of the sharp corner.</td> |
| 2558 | </tr> |
| 2559 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2560 | <td><a name="SkPaint::kLast_Join"></a> <code><strong>SkPaint::kLast_Join </strong></code></td><td>2</td><td>Equivalent to the largest value for <a href="SkPaint_Reference#Stroke_Join">Stroke Join</a>.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2561 | </tr> |
| 2562 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2563 | <td><a name="SkPaint::kDefault_Join"></a> <code><strong>SkPaint::kDefault_Join </strong></code></td><td>1</td><td>Equivalent to <a href="SkPaint_Reference#kMiter_Join">kMiter Join</a>. |
| 2564 | <a href="SkPaint_Reference#Stroke_Join">Stroke Join</a> is set to <a href="SkPaint_Reference#kMiter_Join">kMiter Join</a> by default.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2565 | </tr> |
| 2566 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2567 | <td><a name="SkPaint::kJoinCount"></a> <code><strong>SkPaint::kJoinCount </strong></code></td><td>3</td><td>The number of different <a href="SkPaint_Reference#Stroke_Join">Stroke Join</a> values defined. |
| 2568 | May be used to verify that <a href="SkPaint_Reference#Stroke_Join">Stroke Join</a> is a legal value.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2569 | </tr> |
| 2570 | </table> |
| 2571 | |
| 2572 | ### Example |
| 2573 | |
| 2574 | <div><fiddle-embed name="3b1aebacc21c1836a52876b9b0b3905e"></fiddle-embed></div> |
| 2575 | |
| 2576 | ### See Also |
| 2577 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2578 | <a href="SkPaint_Reference#setStrokeJoin">setStrokeJoin</a> <a href="SkPaint_Reference#getStrokeJoin">getStrokeJoin</a> <a href="SkPaint_Reference#setStrokeMiter">setStrokeMiter</a> <a href="SkPaint_Reference#getStrokeMiter">getStrokeMiter</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2579 | |
| 2580 | |
| 2581 | |
| 2582 | <a name="getStrokeJoin"></a> |
| 2583 | ## getStrokeJoin |
| 2584 | |
| 2585 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2586 | Join getStrokeJoin() const |
| 2587 | </pre> |
| 2588 | |
| 2589 | The geometry drawn at the corners of strokes. |
| 2590 | |
| 2591 | ### Return Value |
| 2592 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2593 | one of: <a href="SkPaint_Reference#kMiter_Join">kMiter Join</a>, <a href="SkPaint_Reference#kRound_Join">kRound Join</a>, <a href="SkPaint_Reference#kBevel_Join">kBevel Join</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2594 | |
| 2595 | ### Example |
| 2596 | |
| 2597 | <div><fiddle-embed name="31bf751d0a8ddf176b871810820d8199"> |
| 2598 | |
| 2599 | #### Example Output |
| 2600 | |
| 2601 | ~~~~ |
| 2602 | kMiter_Join == default stroke join |
| 2603 | ~~~~ |
| 2604 | |
| 2605 | </fiddle-embed></div> |
| 2606 | |
| 2607 | ### See Also |
| 2608 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2609 | <a href="SkPaint_Reference#Stroke_Join">Stroke Join</a> <a href="SkPaint_Reference#setStrokeJoin">setStrokeJoin</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2610 | |
| 2611 | --- |
| 2612 | |
| 2613 | <a name="setStrokeJoin"></a> |
| 2614 | ## setStrokeJoin |
| 2615 | |
| 2616 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2617 | void setStrokeJoin(Join join) |
| 2618 | </pre> |
| 2619 | |
| 2620 | The geometry drawn at the corners of strokes. |
| 2621 | |
| 2622 | ### Parameters |
| 2623 | |
| 2624 | <table> <tr> <td><code><strong>join </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2625 | one of: <a href="SkPaint_Reference#kMiter_Join">kMiter Join</a>, <a href="SkPaint_Reference#kRound_Join">kRound Join</a>, <a href="SkPaint_Reference#kBevel_Join">kBevel Join</a>; |
Cary Clark | bad5ad7 | 2017-08-03 17:14:08 -0400 | [diff] [blame] | 2626 | otherwise, has no effect</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2627 | </tr> |
| 2628 | </table> |
| 2629 | |
| 2630 | ### Example |
| 2631 | |
| 2632 | <div><fiddle-embed name="48d963ad4286eddf680f9c511eb6da91"> |
| 2633 | |
| 2634 | #### Example Output |
| 2635 | |
| 2636 | ~~~~ |
| 2637 | kMiter_Join == paint.getStrokeJoin() |
| 2638 | ~~~~ |
| 2639 | |
| 2640 | </fiddle-embed></div> |
| 2641 | |
| 2642 | ### See Also |
| 2643 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2644 | <a href="SkPaint_Reference#Stroke_Join">Stroke Join</a> <a href="SkPaint_Reference#getStrokeJoin">getStrokeJoin</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2645 | |
| 2646 | --- |
| 2647 | |
| 2648 | ### See Also |
| 2649 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2650 | <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2651 | |
| 2652 | # <a name="Fill_Path"></a> Fill Path |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2653 | <a href="SkPaint_Reference#Fill_Path">Fill Path</a> creates a <a href="SkPath_Reference#Path">Path</a> by applying the <a href="undocumented#Path_Effect">Path Effect</a>, followed by the <a href="SkPaint_Reference#Style_Stroke">Style Stroke</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2654 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2655 | If <a href="SkPaint_Reference#Paint">Paint</a> contains <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Path_Effect">Path Effect</a> operates on the source <a href="SkPath_Reference#Path">Path</a>; the result |
| 2656 | replaces the destination <a href="SkPath_Reference#Path">Path</a>. Otherwise, the source <a href="SkPath_Reference#Path">Path</a> is replaces the |
| 2657 | destination <a href="SkPath_Reference#Path">Path</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2658 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2659 | Fill <a href="SkPath_Reference#Path">Path</a> can request the <a href="undocumented#Path_Effect">Path Effect</a> to restrict to a culling rectangle, but |
| 2660 | the <a href="undocumented#Path_Effect">Path Effect</a> is not required to do so. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2661 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2662 | If <a href="SkPaint_Reference#Style">Style</a> is <a href="SkPaint_Reference#kStroke_Style">kStroke Style</a> or <a href="SkPaint_Reference#kStrokeAndFill_Style">kStrokeAndFill Style</a>, |
| 2663 | and <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> is greater than zero, the <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a>, <a href="SkPaint_Reference#Stroke_Cap">Stroke Cap</a>, <a href="SkPaint_Reference#Stroke_Join">Stroke Join</a>, |
| 2664 | and <a href="SkPaint_Reference#Miter_Limit">Miter Limit</a> operate on the destination <a href="SkPath_Reference#Path">Path</a>, replacing it. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2665 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2666 | Fill <a href="SkPath_Reference#Path">Path</a> can specify the precision used by <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> to approximate the stroke geometry. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2667 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2668 | If the <a href="SkPaint_Reference#Style">Style</a> is <a href="SkPaint_Reference#kStroke_Style">kStroke Style</a> and the <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> is zero, <a href="SkPaint_Reference#getFillPath">getFillPath</a> |
| 2669 | returns false since <a href="SkPaint_Reference#Hairline">Hairline</a> has no filled equivalent. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2670 | |
| 2671 | <a name="getFillPath"></a> |
| 2672 | ## getFillPath |
| 2673 | |
| 2674 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2675 | bool getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect, |
| 2676 | SkScalar resScale = 1) const |
| 2677 | </pre> |
| 2678 | |
| 2679 | The filled equivalent of the stroked path. |
| 2680 | |
| 2681 | ### Parameters |
| 2682 | |
| 2683 | <table> <tr> <td><code><strong>src </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2684 | <a href="SkPath_Reference#Path">Path</a> read to create a filled version</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2685 | </tr> <tr> <td><code><strong>dst </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2686 | resulting <a href="SkPath_Reference#Path">Path</a>; may be the same as <a href="SkPaint_Reference#src">src</a>, but may not be nullptr</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2687 | </tr> <tr> <td><code><strong>cullRect </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2688 | optional limit passed to <a href="undocumented#Path_Effect">Path Effect</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2689 | </tr> <tr> <td><code><strong>resScale </strong></code></td> <td> |
| 2690 | if > 1, increase precision, else if (0 < res < 1) reduce precision |
| 2691 | to favor speed and size</td> |
| 2692 | </tr> |
| 2693 | </table> |
| 2694 | |
| 2695 | ### Return Value |
| 2696 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2697 | true if the path represents <a href="SkPaint_Reference#Style_Fill">Style Fill</a>, or false if it represents <a href="SkPaint_Reference#Hairline">Hairline</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2698 | |
| 2699 | ### Example |
| 2700 | |
| 2701 | <div><fiddle-embed name="cedd6233848198e1fca4d1e14816baaf"><div>A very small quad stroke is turned into a filled path with increasing levels of precision. |
| 2702 | At the lowest precision, the quad stroke is approximated by a rectangle. |
| 2703 | At the highest precision, the filled path has high fidelity compared to the original stroke.</div></fiddle-embed></div> |
| 2704 | |
| 2705 | --- |
| 2706 | |
| 2707 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2708 | bool getFillPath(const SkPath& src, SkPath* dst) const |
| 2709 | </pre> |
| 2710 | |
| 2711 | The filled equivalent of the stroked path. |
| 2712 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2713 | Replaces <a href="SkPaint_Reference#dst">dst</a> with the <a href="SkPaint_Reference#src">src</a> path modified by <a href="undocumented#Path_Effect">Path Effect</a> and <a href="SkPaint_Reference#Style_Stroke">Style Stroke</a>. |
| 2714 | <a href="undocumented#Path_Effect">Path Effect</a>, if any, is not culled. <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> is created with default precision. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2715 | |
| 2716 | ### Parameters |
| 2717 | |
| 2718 | <table> <tr> <td><code><strong>src </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2719 | <a href="SkPath_Reference#Path">Path</a> read to create a filled version</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2720 | </tr> <tr> <td><code><strong>dst </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2721 | resulting <a href="SkPath_Reference#Path">Path</a> <a href="SkPaint_Reference#dst">dst</a> may be the same as <a href="SkPaint_Reference#src">src</a>, but may not be nullptr</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2722 | </tr> |
| 2723 | </table> |
| 2724 | |
| 2725 | ### Return Value |
| 2726 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2727 | true if the path represents <a href="SkPaint_Reference#Style_Fill">Style Fill</a>, or false if it represents <a href="SkPaint_Reference#Hairline">Hairline</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2728 | |
| 2729 | ### Example |
| 2730 | |
| 2731 | <div><fiddle-embed name="e6d8ca0cc17e0b475bd54dd995825468"></fiddle-embed></div> |
| 2732 | |
| 2733 | --- |
| 2734 | |
| 2735 | ### See Also |
| 2736 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2737 | <a href="SkPaint_Reference#Style_Stroke">Style Stroke</a> <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a> <a href="undocumented#Path_Effect">Path Effect</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2738 | |
| 2739 | # <a name="Shader_Methods"></a> Shader Methods |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2740 | <a href="undocumented#Shader">Shader</a> defines the colors used when drawing a shape. |
| 2741 | <a href="undocumented#Shader">Shader</a> may be an image, a gradient, or a computed fill. |
| 2742 | If <a href="SkPaint_Reference#Paint">Paint</a> has no <a href="undocumented#Shader">Shader</a>, then <a href="undocumented#Color">Color</a> fills the shape. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2743 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2744 | <a href="undocumented#Shader">Shader</a> is modulated by <a href="undocumented#Alpha">Color Alpha</a> component of <a href="undocumented#Color">Color</a>. |
| 2745 | If <a href="undocumented#Shader">Shader</a> object defines only <a href="undocumented#Alpha">Color Alpha</a>, then <a href="undocumented#Color">Color</a> modulated by <a href="undocumented#Alpha">Color Alpha</a> describes |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2746 | the fill. |
| 2747 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2748 | The drawn transparency can be modified without altering <a href="undocumented#Shader">Shader</a>, by changing <a href="undocumented#Alpha">Color Alpha</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2749 | |
| 2750 | ### Example |
| 2751 | |
| 2752 | <div><fiddle-embed name="c015dc2010c15e1c00b4f7330232b0f7"></fiddle-embed></div> |
| 2753 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2754 | If <a href="undocumented#Shader">Shader</a> generates only <a href="undocumented#Alpha">Color Alpha</a> then all components of <a href="undocumented#Color">Color</a> modulate the output. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2755 | |
| 2756 | ### Example |
| 2757 | |
| 2758 | <div><fiddle-embed name="9673be7720ba3adcdae42ddc1565b588"></fiddle-embed></div> |
| 2759 | |
| 2760 | <a name="getShader"></a> |
| 2761 | ## getShader |
| 2762 | |
| 2763 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2764 | SkShader* getShader() const |
| 2765 | </pre> |
| 2766 | |
| 2767 | Optional colors used when filling a path, such as a gradient. |
| 2768 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2769 | Does not alter <a href="undocumented#Shader">Shader</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2770 | |
| 2771 | ### Return Value |
| 2772 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2773 | <a href="undocumented#Shader">Shader</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2774 | |
| 2775 | ### Example |
| 2776 | |
| 2777 | <div><fiddle-embed name="09f15b9fd88882850da2d235eb86292f"> |
| 2778 | |
| 2779 | #### Example Output |
| 2780 | |
| 2781 | ~~~~ |
| 2782 | nullptr == shader |
| 2783 | nullptr != shader |
| 2784 | ~~~~ |
| 2785 | |
| 2786 | </fiddle-embed></div> |
| 2787 | |
| 2788 | --- |
| 2789 | |
| 2790 | <a name="refShader"></a> |
| 2791 | ## refShader |
| 2792 | |
| 2793 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2794 | sk_sp<SkShader> refShader() const |
| 2795 | </pre> |
| 2796 | |
| 2797 | Optional colors used when filling a path, such as a gradient. |
| 2798 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2799 | Increases <a href="undocumented#Shader">Shader</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2800 | |
| 2801 | ### Return Value |
| 2802 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2803 | <a href="undocumented#Shader">Shader</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2804 | |
| 2805 | ### Example |
| 2806 | |
| 2807 | <div><fiddle-embed name="53da0295972a418cbc9607bbb17feaa8"> |
| 2808 | |
| 2809 | #### Example Output |
| 2810 | |
| 2811 | ~~~~ |
| 2812 | shader unique: true |
| 2813 | shader unique: false |
| 2814 | ~~~~ |
| 2815 | |
| 2816 | </fiddle-embed></div> |
| 2817 | |
| 2818 | --- |
| 2819 | |
| 2820 | <a name="setShader"></a> |
| 2821 | ## setShader |
| 2822 | |
| 2823 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2824 | void setShader(sk_sp<SkShader> shader) |
| 2825 | </pre> |
| 2826 | |
| 2827 | Optional colors used when filling a path, such as a gradient. |
| 2828 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2829 | Sets <a href="undocumented#Shader">Shader</a> to <a href="SkPaint_Reference#shader">shader</a>, decrementing <a href="undocumented#Reference_Count">Reference Count</a> of the previous <a href="undocumented#Shader">Shader</a>. |
| 2830 | Does not alter <a href="SkPaint_Reference#shader">shader</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2831 | |
| 2832 | ### Parameters |
| 2833 | |
| 2834 | <table> <tr> <td><code><strong>shader </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2835 | how geometry is filled with color; if nullptr, <a href="undocumented#Color">Color</a> is used instead</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2836 | </tr> |
| 2837 | </table> |
| 2838 | |
| 2839 | ### Example |
| 2840 | |
| 2841 | <div><fiddle-embed name="77e64d5bae9b1ba037fd99252bb4aa58"></fiddle-embed></div> |
| 2842 | |
| 2843 | --- |
| 2844 | |
| 2845 | # <a name="Color_Filter_Methods"></a> Color Filter Methods |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2846 | <a href="undocumented#Color_Filter">Color Filter</a> alters the color used when drawing a shape. |
| 2847 | <a href="undocumented#Color_Filter">Color Filter</a> may apply <a href="undocumented#Blend_Mode">Blend Mode</a>, transform the color through a matrix, or composite multiple filters. |
| 2848 | If <a href="SkPaint_Reference#Paint">Paint</a> has no <a href="undocumented#Color_Filter">Color Filter</a>, the color is unaltered. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2849 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2850 | The drawn transparency can be modified without altering <a href="undocumented#Color_Filter">Color Filter</a>, by changing <a href="undocumented#Alpha">Color Alpha</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2851 | |
| 2852 | ### Example |
| 2853 | |
| 2854 | <div><fiddle-embed name="5abde56ca2f89a18b8e231abd1b57c56"></fiddle-embed></div> |
| 2855 | |
| 2856 | <a name="getColorFilter"></a> |
| 2857 | ## getColorFilter |
| 2858 | |
| 2859 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2860 | SkColorFilter* getColorFilter() const |
| 2861 | </pre> |
| 2862 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2863 | Returns <a href="undocumented#Color_Filter">Color Filter</a> if set, or nullptr. |
| 2864 | Does not alter <a href="undocumented#Color_Filter">Color Filter</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2865 | |
| 2866 | ### Return Value |
| 2867 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2868 | <a href="undocumented#Color_Filter">Color Filter</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2869 | |
| 2870 | ### Example |
| 2871 | |
| 2872 | <div><fiddle-embed name="093bdc627d6b59002670fd290931f6c9"> |
| 2873 | |
| 2874 | #### Example Output |
| 2875 | |
| 2876 | ~~~~ |
| 2877 | nullptr == color filter |
| 2878 | nullptr != color filter |
| 2879 | ~~~~ |
| 2880 | |
| 2881 | </fiddle-embed></div> |
| 2882 | |
| 2883 | --- |
| 2884 | |
| 2885 | <a name="refColorFilter"></a> |
| 2886 | ## refColorFilter |
| 2887 | |
| 2888 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2889 | sk_sp<SkColorFilter> refColorFilter() const |
| 2890 | </pre> |
| 2891 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2892 | Returns <a href="undocumented#Color_Filter">Color Filter</a> if set, or nullptr. |
| 2893 | Increases <a href="undocumented#Color_Filter">Color Filter</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2894 | |
| 2895 | ### Return Value |
| 2896 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2897 | <a href="undocumented#Color_Filter">Color Filter</a> if set, or nullptr |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2898 | |
| 2899 | ### Example |
| 2900 | |
| 2901 | <div><fiddle-embed name="b588c95fa4c86ddbc4b0546762f08297"> |
| 2902 | |
| 2903 | #### Example Output |
| 2904 | |
| 2905 | ~~~~ |
| 2906 | color filter unique: true |
| 2907 | color filter unique: false |
| 2908 | ~~~~ |
| 2909 | |
| 2910 | </fiddle-embed></div> |
| 2911 | |
| 2912 | --- |
| 2913 | |
| 2914 | <a name="setColorFilter"></a> |
| 2915 | ## setColorFilter |
| 2916 | |
| 2917 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2918 | void setColorFilter(sk_sp<SkColorFilter> colorFilter) |
| 2919 | </pre> |
| 2920 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2921 | Sets <a href="undocumented#Color_Filter">Color Filter</a> to filter, decrementing <a href="undocumented#Reference_Count">Reference Count</a> of the previous <a href="undocumented#Color_Filter">Color Filter</a>. |
| 2922 | Pass nullptr to clear <a href="undocumented#Color_Filter">Color Filter</a>. |
| 2923 | Does not alter filter <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2924 | |
| 2925 | ### Parameters |
| 2926 | |
| 2927 | <table> <tr> <td><code><strong>colorFilter </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2928 | <a href="undocumented#Color_Filter">Color Filter</a> to apply to subsequent draw</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2929 | </tr> |
| 2930 | </table> |
| 2931 | |
| 2932 | ### Example |
| 2933 | |
| 2934 | <div><fiddle-embed name="c7b786dc9b3501cd0eaba47494b6fa31"></fiddle-embed></div> |
| 2935 | |
| 2936 | --- |
| 2937 | |
| 2938 | # <a name="Blend_Mode_Methods"></a> Blend Mode Methods |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2939 | <a href="undocumented#Blend_Mode">Blend Mode</a> describes how <a href="undocumented#Color">Color</a> combines with the destination color. |
| 2940 | The default setting, <a href="undocumented#kSrcOver">SkBlendMode::kSrcOver</a>, draws the source color |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2941 | over the destination color. |
| 2942 | |
| 2943 | ### Example |
| 2944 | |
| 2945 | <div><fiddle-embed name="73092d4d06faecea3c204d852a4dd8a8"></fiddle-embed></div> |
| 2946 | |
| 2947 | ### See Also |
| 2948 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2949 | <a href="undocumented#Blend_Mode">Blend Mode</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2950 | |
| 2951 | <a name="getBlendMode"></a> |
| 2952 | ## getBlendMode |
| 2953 | |
| 2954 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2955 | SkBlendMode getBlendMode() const |
| 2956 | </pre> |
| 2957 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2958 | Returns <a href="undocumented#Blend_Mode">Blend Mode</a>. |
| 2959 | By default, returns <a href="undocumented#kSrcOver">SkBlendMode::kSrcOver</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2960 | |
| 2961 | ### Return Value |
| 2962 | |
| 2963 | mode used to combine source color with destination color |
| 2964 | |
| 2965 | ### Example |
| 2966 | |
| 2967 | <div><fiddle-embed name="4ec1864b8203d52c0810e8605092f45c"> |
| 2968 | |
| 2969 | #### Example Output |
| 2970 | |
| 2971 | ~~~~ |
| 2972 | kSrcOver == getBlendMode |
| 2973 | kSrcOver != getBlendMode |
| 2974 | ~~~~ |
| 2975 | |
| 2976 | </fiddle-embed></div> |
| 2977 | |
| 2978 | --- |
| 2979 | |
| 2980 | <a name="isSrcOver"></a> |
| 2981 | ## isSrcOver |
| 2982 | |
| 2983 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 2984 | bool isSrcOver() const |
| 2985 | </pre> |
| 2986 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2987 | Returns true if <a href="undocumented#Blend_Mode">Blend Mode</a> is <a href="undocumented#kSrcOver">SkBlendMode::kSrcOver</a>, the default. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2988 | |
| 2989 | ### Return Value |
| 2990 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 2991 | true if <a href="undocumented#Blend_Mode">Blend Mode</a> is <a href="undocumented#kSrcOver">SkBlendMode::kSrcOver</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 2992 | |
| 2993 | ### Example |
| 2994 | |
| 2995 | <div><fiddle-embed name="257c9473db7a2b3a0fb2b9e2431e59a6"> |
| 2996 | |
| 2997 | #### Example Output |
| 2998 | |
| 2999 | ~~~~ |
| 3000 | isSrcOver == true |
| 3001 | isSrcOver != true |
| 3002 | ~~~~ |
| 3003 | |
| 3004 | </fiddle-embed></div> |
| 3005 | |
| 3006 | --- |
| 3007 | |
| 3008 | <a name="setBlendMode"></a> |
| 3009 | ## setBlendMode |
| 3010 | |
| 3011 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3012 | void setBlendMode(SkBlendMode mode) |
| 3013 | </pre> |
| 3014 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3015 | Sets <a href="undocumented#Blend_Mode">Blend Mode</a> to <a href="SkPaint_Reference#mode">mode</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3016 | Does not check for valid input. |
| 3017 | |
| 3018 | ### Parameters |
| 3019 | |
| 3020 | <table> <tr> <td><code><strong>mode </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3021 | <a href="undocumented#SkBlendMode">SkBlendMode</a> used to combine source color and destination</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3022 | </tr> |
| 3023 | </table> |
| 3024 | |
| 3025 | ### Example |
| 3026 | |
| 3027 | <div><fiddle-embed name="257c9473db7a2b3a0fb2b9e2431e59a6"> |
| 3028 | |
| 3029 | #### Example Output |
| 3030 | |
| 3031 | ~~~~ |
| 3032 | isSrcOver == true |
| 3033 | isSrcOver != true |
| 3034 | ~~~~ |
| 3035 | |
| 3036 | </fiddle-embed></div> |
| 3037 | |
| 3038 | --- |
| 3039 | |
| 3040 | # <a name="Path_Effect_Methods"></a> Path Effect Methods |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3041 | <a href="undocumented#Path_Effect">Path Effect</a> modifies the path geometry before drawing it. |
| 3042 | <a href="undocumented#Path_Effect">Path Effect</a> may implement dashing, custom fill effects and custom stroke effects. |
| 3043 | If <a href="SkPaint_Reference#Paint">Paint</a> has no <a href="undocumented#Path_Effect">Path Effect</a>, the path geometry is unaltered when filled or stroked. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3044 | |
| 3045 | ### Example |
| 3046 | |
| 3047 | <div><fiddle-embed name="8cf5684b187d60f09e11c4a48993ea39"></fiddle-embed></div> |
| 3048 | |
| 3049 | ### See Also |
| 3050 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3051 | <a href="undocumented#Path_Effect">Path Effect</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3052 | |
| 3053 | <a name="getPathEffect"></a> |
| 3054 | ## getPathEffect |
| 3055 | |
| 3056 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3057 | SkPathEffect* getPathEffect() const |
| 3058 | </pre> |
| 3059 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3060 | Returns <a href="undocumented#Path_Effect">Path Effect</a> if set, or nullptr. |
| 3061 | Does not alter <a href="undocumented#Path_Effect">Path Effect</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3062 | |
| 3063 | ### Return Value |
| 3064 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3065 | <a href="undocumented#Path_Effect">Path Effect</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3066 | |
| 3067 | ### Example |
| 3068 | |
| 3069 | <div><fiddle-embed name="211a1b14bfa6c4332082c8eab4fbc5fd"> |
| 3070 | |
| 3071 | #### Example Output |
| 3072 | |
| 3073 | ~~~~ |
| 3074 | nullptr == path effect |
| 3075 | nullptr != path effect |
| 3076 | ~~~~ |
| 3077 | |
| 3078 | </fiddle-embed></div> |
| 3079 | |
| 3080 | --- |
| 3081 | |
| 3082 | <a name="refPathEffect"></a> |
| 3083 | ## refPathEffect |
| 3084 | |
| 3085 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3086 | sk_sp<SkPathEffect> refPathEffect() const |
| 3087 | </pre> |
| 3088 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3089 | Returns <a href="undocumented#Path_Effect">Path Effect</a> if set, or nullptr. |
| 3090 | Increases <a href="undocumented#Path_Effect">Path Effect</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3091 | |
| 3092 | ### Return Value |
| 3093 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3094 | <a href="undocumented#Path_Effect">Path Effect</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3095 | |
| 3096 | ### Example |
| 3097 | |
| 3098 | <div><fiddle-embed name="c55c74f8f581870bd2c18f2f99765579"> |
| 3099 | |
| 3100 | #### Example Output |
| 3101 | |
| 3102 | ~~~~ |
| 3103 | path effect unique: true |
| 3104 | path effect unique: false |
| 3105 | ~~~~ |
| 3106 | |
| 3107 | </fiddle-embed></div> |
| 3108 | |
| 3109 | --- |
| 3110 | |
| 3111 | <a name="setPathEffect"></a> |
| 3112 | ## setPathEffect |
| 3113 | |
| 3114 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3115 | void setPathEffect(sk_sp<SkPathEffect> pathEffect) |
| 3116 | </pre> |
| 3117 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3118 | Sets <a href="undocumented#Path_Effect">Path Effect</a> to <a href="SkPaint_Reference#pathEffect">pathEffect</a>, |
| 3119 | decrementing <a href="undocumented#Reference_Count">Reference Count</a> of the previous <a href="undocumented#Path_Effect">Path Effect</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3120 | Pass nullptr to leave the path geometry unaltered. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3121 | Does not alter <a href="SkPaint_Reference#pathEffect">pathEffect</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3122 | |
| 3123 | ### Parameters |
| 3124 | |
| 3125 | <table> <tr> <td><code><strong>pathEffect </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3126 | replace <a href="SkPath_Reference#Path">Path</a> with a modification when drawn</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3127 | </tr> |
| 3128 | </table> |
| 3129 | |
| 3130 | ### Example |
| 3131 | |
| 3132 | <div><fiddle-embed name="52dd55074ca0b7d520d04e750ca2a0d7"></fiddle-embed></div> |
| 3133 | |
| 3134 | --- |
| 3135 | |
| 3136 | # <a name="Mask_Filter_Methods"></a> Mask Filter Methods |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3137 | <a href="undocumented#Mask_Filter">Mask Filter</a> uses <a href="undocumented#Alpha">Color Alpha</a> of the shape drawn to create <a href="undocumented#Mask_Alpha">Mask Alpha</a>. |
| 3138 | <a href="undocumented#Mask_Filter">Mask Filter</a> operates at a lower level than <a href="undocumented#Rasterizer">Rasterizer</a>; <a href="undocumented#Mask_Filter">Mask Filter</a> takes a <a href="undocumented#Mask">Mask</a>, |
| 3139 | and returns a <a href="undocumented#Mask">Mask</a>. |
| 3140 | <a href="undocumented#Mask_Filter">Mask Filter</a> may change the geometry and transparency of the shape, such as creating a blur effect. |
| 3141 | Set <a href="undocumented#Mask_Filter">Mask Filter</a> to nullptr to prevent <a href="undocumented#Mask_Filter">Mask Filter</a> from modifying the draw. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3142 | |
| 3143 | ### Example |
| 3144 | |
| 3145 | <div><fiddle-embed name="320b04ea1e1291d49f1e61994a0410fe"></fiddle-embed></div> |
| 3146 | |
| 3147 | <a name="getMaskFilter"></a> |
| 3148 | ## getMaskFilter |
| 3149 | |
| 3150 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3151 | SkMaskFilter* getMaskFilter() const |
| 3152 | </pre> |
| 3153 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3154 | Returns <a href="undocumented#Mask_Filter">Mask Filter</a> if set, or nullptr. |
| 3155 | Does not alter <a href="undocumented#Mask_Filter">Mask Filter</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3156 | |
| 3157 | ### Return Value |
| 3158 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3159 | <a href="undocumented#Mask_Filter">Mask Filter</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3160 | |
| 3161 | ### Example |
| 3162 | |
| 3163 | <div><fiddle-embed name="8cd53ece8fc83e4560599ace094b0f16"> |
| 3164 | |
| 3165 | #### Example Output |
| 3166 | |
| 3167 | ~~~~ |
| 3168 | nullptr == mask filter |
| 3169 | nullptr != mask filter |
| 3170 | ~~~~ |
| 3171 | |
| 3172 | </fiddle-embed></div> |
| 3173 | |
| 3174 | --- |
| 3175 | |
| 3176 | <a name="refMaskFilter"></a> |
| 3177 | ## refMaskFilter |
| 3178 | |
| 3179 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3180 | sk_sp<SkMaskFilter> refMaskFilter() const |
| 3181 | </pre> |
| 3182 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3183 | Returns <a href="undocumented#Mask_Filter">Mask Filter</a> if set, or nullptr. |
| 3184 | Increases <a href="undocumented#Mask_Filter">Mask Filter</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3185 | |
| 3186 | ### Return Value |
| 3187 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3188 | <a href="undocumented#Mask_Filter">Mask Filter</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3189 | |
| 3190 | ### Example |
| 3191 | |
| 3192 | <div><fiddle-embed name="35a397dce5d44658ee4e9e9dfb9fee22"> |
| 3193 | |
| 3194 | #### Example Output |
| 3195 | |
| 3196 | ~~~~ |
| 3197 | mask filter unique: true |
| 3198 | mask filter unique: false |
| 3199 | ~~~~ |
| 3200 | |
| 3201 | </fiddle-embed></div> |
| 3202 | |
| 3203 | --- |
| 3204 | |
| 3205 | <a name="setMaskFilter"></a> |
| 3206 | ## setMaskFilter |
| 3207 | |
| 3208 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3209 | void setMaskFilter(sk_sp<SkMaskFilter> maskFilter) |
| 3210 | </pre> |
| 3211 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3212 | Sets <a href="undocumented#Mask_Filter">Mask Filter</a> to <a href="SkPaint_Reference#maskFilter">maskFilter</a>, |
| 3213 | decrementing <a href="undocumented#Reference_Count">Reference Count</a> of the previous <a href="undocumented#Mask_Filter">Mask Filter</a>. |
| 3214 | Pass nullptr to clear <a href="undocumented#Mask_Filter">Mask Filter</a> and leave <a href="undocumented#Mask_Filter">Mask Filter</a> effect on <a href="undocumented#Mask_Alpha">Mask Alpha</a> unaltered. |
| 3215 | Does not affect <a href="undocumented#Rasterizer">Rasterizer</a>. |
| 3216 | Does not alter <a href="SkPaint_Reference#maskFilter">maskFilter</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3217 | |
| 3218 | ### Parameters |
| 3219 | |
| 3220 | <table> <tr> <td><code><strong>maskFilter </strong></code></td> <td> |
| 3221 | modifies clipping mask generated from drawn geometry</td> |
| 3222 | </tr> |
| 3223 | </table> |
| 3224 | |
| 3225 | ### Example |
| 3226 | |
| 3227 | <div><fiddle-embed name="62c5a826692f85c3de3bab65e9e97aa9"></fiddle-embed></div> |
| 3228 | |
| 3229 | --- |
| 3230 | |
| 3231 | # <a name="Typeface_Methods"></a> Typeface Methods |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3232 | <a href="undocumented#Typeface">Typeface</a> identifies the font used when drawing and measuring text. |
| 3233 | <a href="undocumented#Typeface">Typeface</a> may be specified by name, from a file, or from a data stream. |
| 3234 | The default <a href="undocumented#Typeface">Typeface</a> defers to the platform-specific default font |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3235 | implementation. |
| 3236 | |
| 3237 | ### Example |
| 3238 | |
| 3239 | <div><fiddle-embed name="c18b1696b8c1649bebf7eb1f8b89e0b0"></fiddle-embed></div> |
| 3240 | |
| 3241 | <a name="getTypeface"></a> |
| 3242 | ## getTypeface |
| 3243 | |
| 3244 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3245 | SkTypeface* getTypeface() const |
| 3246 | </pre> |
| 3247 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3248 | Returns <a href="undocumented#Typeface">Typeface</a> if set, or nullptr. |
| 3249 | Does not alter <a href="undocumented#Typeface">Typeface</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3250 | |
| 3251 | ### Return Value |
| 3252 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3253 | <a href="undocumented#Typeface">Typeface</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3254 | |
| 3255 | ### Example |
| 3256 | |
| 3257 | <div><fiddle-embed name="4d9ffb5761b62a9e3bc9b0bca8787bce"> |
| 3258 | |
| 3259 | #### Example Output |
| 3260 | |
| 3261 | ~~~~ |
| 3262 | nullptr == typeface |
| 3263 | nullptr != typeface |
| 3264 | ~~~~ |
| 3265 | |
| 3266 | </fiddle-embed></div> |
| 3267 | |
| 3268 | --- |
| 3269 | |
| 3270 | <a name="refTypeface"></a> |
| 3271 | ## refTypeface |
| 3272 | |
| 3273 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3274 | sk_sp<SkTypeface> refTypeface() const |
| 3275 | </pre> |
| 3276 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3277 | Increases <a href="undocumented#Typeface">Typeface</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3278 | |
| 3279 | ### Return Value |
| 3280 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3281 | <a href="undocumented#Typeface">Typeface</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3282 | |
| 3283 | ### Example |
| 3284 | |
| 3285 | <div><fiddle-embed name="c8edce7b36a3ffda8af4fe89d7187dbc"> |
| 3286 | |
| 3287 | #### Example Output |
| 3288 | |
| 3289 | ~~~~ |
| 3290 | typeface1 != typeface2 |
| 3291 | typeface1 == typeface2 |
| 3292 | ~~~~ |
| 3293 | |
| 3294 | </fiddle-embed></div> |
| 3295 | |
| 3296 | --- |
| 3297 | |
| 3298 | <a name="setTypeface"></a> |
| 3299 | ## setTypeface |
| 3300 | |
| 3301 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3302 | void setTypeface(sk_sp<SkTypeface> typeface) |
| 3303 | </pre> |
| 3304 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3305 | Sets <a href="undocumented#Typeface">Typeface</a> to <a href="SkPaint_Reference#typeface">typeface</a>, |
| 3306 | decrementing <a href="undocumented#Reference_Count">Reference Count</a> of the previous <a href="undocumented#Typeface">Typeface</a>. |
| 3307 | Pass nullptr to clear <a href="undocumented#Typeface">Typeface</a> and use the default <a href="SkPaint_Reference#typeface">typeface</a>. |
| 3308 | Does not alter <a href="SkPaint_Reference#typeface">typeface</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3309 | |
| 3310 | ### Parameters |
| 3311 | |
| 3312 | <table> <tr> <td><code><strong>typeface </strong></code></td> <td> |
| 3313 | font and style used to draw text</td> |
| 3314 | </tr> |
| 3315 | </table> |
| 3316 | |
| 3317 | ### Example |
| 3318 | |
| 3319 | <div><fiddle-embed name="3d2656ec4c555ed2c7ec086720124a2a"></fiddle-embed></div> |
| 3320 | |
| 3321 | --- |
| 3322 | |
| 3323 | # <a name="Rasterizer_Methods"></a> Rasterizer Methods |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3324 | <a href="undocumented#Rasterizer">Rasterizer</a> controls how shapes are converted to <a href="undocumented#Mask_Alpha">Mask Alpha</a>. |
| 3325 | <a href="undocumented#Rasterizer">Rasterizer</a> operates at a higher level than <a href="undocumented#Mask_Filter">Mask Filter</a>; <a href="undocumented#Rasterizer">Rasterizer</a> takes a <a href="SkPath_Reference#Path">Path</a>, |
| 3326 | and returns a <a href="undocumented#Mask">Mask</a>. |
| 3327 | <a href="undocumented#Rasterizer">Rasterizer</a> may change the geometry and transparency of the shape, such as |
| 3328 | creating a shadow effect. <a href="undocumented#Rasterizer">Rasterizer</a> forms the base of <a href="undocumented#Layer">Rasterizer Layer</a>, which |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3329 | creates effects like embossing and outlining. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3330 | <a href="undocumented#Rasterizer">Rasterizer</a> applies to <a href="undocumented#Rect">Rect</a>, <a href="undocumented#Region">Region</a>, <a href="undocumented#Round_Rect">Round Rect</a>, <a href="undocumented#Arc">Arc</a>, <a href="undocumented#Circle">Circle</a>, <a href="undocumented#Oval">Oval</a>, |
| 3331 | <a href="SkPath_Reference#Path">Path</a>, and <a href="undocumented#Text">Text</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3332 | |
| 3333 | ### Example |
| 3334 | |
| 3335 | <div><fiddle-embed name="e63f8a50996699342a14c6e54d684108"></fiddle-embed></div> |
| 3336 | |
| 3337 | <a name="getRasterizer"></a> |
| 3338 | ## getRasterizer |
| 3339 | |
| 3340 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3341 | SkRasterizer* getRasterizer() const |
| 3342 | </pre> |
| 3343 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3344 | Returns <a href="undocumented#Rasterizer">Rasterizer</a> if set, or nullptr. |
| 3345 | Does not alter <a href="undocumented#Rasterizer">Rasterizer</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3346 | |
| 3347 | ### Return Value |
| 3348 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3349 | <a href="undocumented#Rasterizer">Rasterizer</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3350 | |
| 3351 | ### Example |
| 3352 | |
| 3353 | <div><fiddle-embed name="0707d407c3a14388b107af8ae5873e55"> |
| 3354 | |
| 3355 | #### Example Output |
| 3356 | |
| 3357 | ~~~~ |
| 3358 | nullptr == rasterizer |
| 3359 | nullptr != rasterizer |
| 3360 | ~~~~ |
| 3361 | |
| 3362 | </fiddle-embed></div> |
| 3363 | |
| 3364 | --- |
| 3365 | |
| 3366 | <a name="refRasterizer"></a> |
| 3367 | ## refRasterizer |
| 3368 | |
| 3369 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3370 | sk_sp<SkRasterizer> refRasterizer() const |
| 3371 | </pre> |
| 3372 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3373 | Returns <a href="undocumented#Rasterizer">Rasterizer</a> if set, or nullptr. |
| 3374 | Increases <a href="undocumented#Rasterizer">Rasterizer</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3375 | |
| 3376 | ### Return Value |
| 3377 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3378 | <a href="undocumented#Rasterizer">Rasterizer</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3379 | |
| 3380 | ### Example |
| 3381 | |
| 3382 | <div><fiddle-embed name="c0855ce19a33cb7e5747750ef341b7b3"> |
| 3383 | |
| 3384 | #### Example Output |
| 3385 | |
| 3386 | ~~~~ |
| 3387 | rasterizer unique: true |
| 3388 | rasterizer unique: false |
| 3389 | ~~~~ |
| 3390 | |
| 3391 | </fiddle-embed></div> |
| 3392 | |
| 3393 | --- |
| 3394 | |
| 3395 | <a name="setRasterizer"></a> |
| 3396 | ## setRasterizer |
| 3397 | |
| 3398 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3399 | void setRasterizer(sk_sp<SkRasterizer> rasterizer) |
| 3400 | </pre> |
| 3401 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3402 | Sets <a href="undocumented#Rasterizer">Rasterizer</a> to <a href="SkPaint_Reference#rasterizer">rasterizer</a>, |
| 3403 | decrementing <a href="undocumented#Reference_Count">Reference Count</a> of the previous <a href="undocumented#Rasterizer">Rasterizer</a>. |
| 3404 | Pass nullptr to clear <a href="undocumented#Rasterizer">Rasterizer</a> and leave <a href="undocumented#Rasterizer">Rasterizer</a> effect on <a href="undocumented#Mask_Alpha">Mask Alpha</a> unaltered. |
| 3405 | Does not affect <a href="undocumented#Mask_Filter">Mask Filter</a>. |
| 3406 | Does not alter <a href="SkPaint_Reference#rasterizer">rasterizer</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3407 | |
| 3408 | ### Parameters |
| 3409 | |
| 3410 | <table> <tr> <td><code><strong>rasterizer </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3411 | how geometry is converted to <a href="undocumented#Mask_Alpha">Mask Alpha</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3412 | </tr> |
| 3413 | </table> |
| 3414 | |
| 3415 | ### Example |
| 3416 | |
| 3417 | <div><fiddle-embed name="aec8ed9296c1628073086a33039f62b7"></fiddle-embed></div> |
| 3418 | |
| 3419 | --- |
| 3420 | |
| 3421 | # <a name="Image_Filter_Methods"></a> Image Filter Methods |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3422 | <a href="undocumented#Image_Filter">Image Filter</a> operates on the pixel representation of the shape, as modified by <a href="SkPaint_Reference#Paint">Paint</a> |
| 3423 | with <a href="undocumented#Blend_Mode">Blend Mode</a> set to <a href="undocumented#kSrcOver">SkBlendMode::kSrcOver</a>. <a href="undocumented#Image_Filter">Image Filter</a> creates a new bitmap, |
| 3424 | which is drawn to the device using the set <a href="undocumented#Blend_Mode">Blend Mode</a>. |
| 3425 | <a href="undocumented#Image_Filter">Image Filter</a> is higher level than <a href="undocumented#Mask_Filter">Mask Filter</a>; for instance, an <a href="undocumented#Image_Filter">Image Filter</a> |
| 3426 | can operate on all channels of <a href="undocumented#Color">Color</a>, while <a href="undocumented#Mask_Filter">Mask Filter</a> generates <a href="undocumented#Alpha">Color Alpha</a> only. |
| 3427 | <a href="undocumented#Image_Filter">Image Filter</a> operates independently of and can be used in combination with |
| 3428 | <a href="undocumented#Mask_Filter">Mask Filter</a> and <a href="undocumented#Rasterizer">Rasterizer</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3429 | |
| 3430 | ### Example |
| 3431 | |
| 3432 | <div><fiddle-embed name="88804938b49eb4f7c7f01ad52f4db0d8"></fiddle-embed></div> |
| 3433 | |
| 3434 | <a name="getImageFilter"></a> |
| 3435 | ## getImageFilter |
| 3436 | |
| 3437 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3438 | SkImageFilter* getImageFilter() const |
| 3439 | </pre> |
| 3440 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3441 | Returns <a href="undocumented#Image_Filter">Image Filter</a> if set, or nullptr. |
| 3442 | Does not alter <a href="undocumented#Image_Filter">Image Filter</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3443 | |
| 3444 | ### Return Value |
| 3445 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3446 | <a href="undocumented#Image_Filter">Image Filter</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3447 | |
| 3448 | ### Example |
| 3449 | |
| 3450 | <div><fiddle-embed name="38788d42772641606e08c60d9dd418a2"> |
| 3451 | |
| 3452 | #### Example Output |
| 3453 | |
| 3454 | ~~~~ |
| 3455 | nullptr == image filter |
| 3456 | nullptr != image filter |
| 3457 | ~~~~ |
| 3458 | |
| 3459 | </fiddle-embed></div> |
| 3460 | |
| 3461 | --- |
| 3462 | |
| 3463 | <a name="refImageFilter"></a> |
| 3464 | ## refImageFilter |
| 3465 | |
| 3466 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3467 | sk_sp<SkImageFilter> refImageFilter() const |
| 3468 | </pre> |
| 3469 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3470 | Returns <a href="undocumented#Image_Filter">Image Filter</a> if set, or nullptr. |
| 3471 | Increases <a href="undocumented#Image_Filter">Image Filter</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3472 | |
| 3473 | ### Return Value |
| 3474 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3475 | <a href="undocumented#Image_Filter">Image Filter</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3476 | |
| 3477 | ### Example |
| 3478 | |
| 3479 | <div><fiddle-embed name="13f09088b569251547107d14ae989dc1"> |
| 3480 | |
| 3481 | #### Example Output |
| 3482 | |
| 3483 | ~~~~ |
| 3484 | image filter unique: true |
| 3485 | image filter unique: false |
| 3486 | ~~~~ |
| 3487 | |
| 3488 | </fiddle-embed></div> |
| 3489 | |
| 3490 | --- |
| 3491 | |
| 3492 | <a name="setImageFilter"></a> |
| 3493 | ## setImageFilter |
| 3494 | |
| 3495 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3496 | void setImageFilter(sk_sp<SkImageFilter> imageFilter) |
| 3497 | </pre> |
| 3498 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3499 | Sets <a href="undocumented#Image_Filter">Image Filter</a> to <a href="SkPaint_Reference#imageFilter">imageFilter</a>, |
| 3500 | decrementing <a href="undocumented#Reference_Count">Reference Count</a> of the previous <a href="undocumented#Image_Filter">Image Filter</a>. |
| 3501 | Pass nullptr to clear <a href="undocumented#Image_Filter">Image Filter</a>, and remove <a href="undocumented#Image_Filter">Image Filter</a> effect |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3502 | on drawing. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3503 | Does not affect <a href="undocumented#Rasterizer">Rasterizer</a> or <a href="undocumented#Mask_Filter">Mask Filter</a>. |
| 3504 | Does not alter <a href="SkPaint_Reference#imageFilter">imageFilter</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3505 | |
| 3506 | ### Parameters |
| 3507 | |
| 3508 | <table> <tr> <td><code><strong>imageFilter </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3509 | how <a href="undocumented#Image">Image</a> is sampled when transformed</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3510 | </tr> |
| 3511 | </table> |
| 3512 | |
| 3513 | ### Example |
| 3514 | |
| 3515 | <div><fiddle-embed name="6679d6e4ec632715ee03e68391bd7f9a"></fiddle-embed></div> |
| 3516 | |
| 3517 | --- |
| 3518 | |
| 3519 | # <a name="Draw_Looper_Methods"></a> Draw Looper Methods |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3520 | <a href="undocumented#Draw_Looper">Draw Looper</a> sets a modifier that communicates state from one <a href="undocumented#Draw_Layer">Draw Layer</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3521 | to another to construct the draw. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3522 | <a href="undocumented#Draw_Looper">Draw Looper</a> draws one or more times, modifying the canvas and paint each time. |
| 3523 | <a href="undocumented#Draw_Looper">Draw Looper</a> may be used to draw multiple colors or create a colored shadow. |
| 3524 | Set <a href="undocumented#Draw_Looper">Draw Looper</a> to nullptr to prevent <a href="undocumented#Draw_Looper">Draw Looper</a> from modifying the draw. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3525 | |
| 3526 | ### Example |
| 3527 | |
| 3528 | <div><fiddle-embed name="84ec12a36e50df5ac565cc7a75ffbe9f"></fiddle-embed></div> |
| 3529 | |
| 3530 | <a name="getDrawLooper"></a> |
| 3531 | ## getDrawLooper |
| 3532 | |
| 3533 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3534 | SkDrawLooper* getDrawLooper() const |
| 3535 | </pre> |
| 3536 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3537 | Returns <a href="undocumented#Draw_Looper">Draw Looper</a> if set, or nullptr. |
| 3538 | Does not alter <a href="undocumented#Draw_Looper">Draw Looper</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3539 | |
| 3540 | ### Return Value |
| 3541 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3542 | <a href="undocumented#Draw_Looper">Draw Looper</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3543 | |
| 3544 | ### Example |
| 3545 | |
| 3546 | <div><fiddle-embed name="af4c5acc7a91e7f23c2af48018903ad4"> |
| 3547 | |
| 3548 | #### Example Output |
| 3549 | |
| 3550 | ~~~~ |
| 3551 | nullptr == draw looper |
| 3552 | nullptr != draw looper |
| 3553 | ~~~~ |
| 3554 | |
| 3555 | </fiddle-embed></div> |
| 3556 | |
| 3557 | --- |
| 3558 | |
| 3559 | <a name="refDrawLooper"></a> |
| 3560 | ## refDrawLooper |
| 3561 | |
| 3562 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3563 | sk_sp<SkDrawLooper> refDrawLooper() const |
| 3564 | </pre> |
| 3565 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3566 | Returns <a href="undocumented#Draw_Looper">Draw Looper</a> if set, or nullptr. |
| 3567 | Increases <a href="undocumented#Draw_Looper">Draw Looper</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3568 | |
| 3569 | ### Return Value |
| 3570 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3571 | <a href="undocumented#Draw_Looper">Draw Looper</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3572 | |
| 3573 | ### Example |
| 3574 | |
| 3575 | <div><fiddle-embed name="2a3782c33f04ed17a725d0e449c6f7c3"> |
| 3576 | |
| 3577 | #### Example Output |
| 3578 | |
| 3579 | ~~~~ |
| 3580 | draw looper unique: true |
| 3581 | draw looper unique: false |
| 3582 | ~~~~ |
| 3583 | |
| 3584 | </fiddle-embed></div> |
| 3585 | |
| 3586 | --- |
| 3587 | |
| 3588 | <a name="getLooper"></a> |
| 3589 | ## getLooper |
| 3590 | |
| 3591 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3592 | SkDrawLooper* getLooper() const |
| 3593 | </pre> |
| 3594 | |
| 3595 | Deprecated. |
| 3596 | |
| 3597 | (see bug.skia.org/6259) |
| 3598 | |
| 3599 | ### Return Value |
| 3600 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3601 | <a href="undocumented#Draw_Looper">Draw Looper</a> if previously set, nullptr otherwise |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3602 | |
| 3603 | --- |
| 3604 | |
| 3605 | <a name="setDrawLooper"></a> |
| 3606 | ## setDrawLooper |
| 3607 | |
| 3608 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3609 | void setDrawLooper(sk_sp<SkDrawLooper> drawLooper) |
| 3610 | </pre> |
| 3611 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3612 | Sets <a href="undocumented#Draw_Looper">Draw Looper</a> to <a href="SkPaint_Reference#drawLooper">drawLooper</a>, |
| 3613 | decrementing <a href="undocumented#Reference_Count">Reference Count</a> of the previous <a href="SkPaint_Reference#drawLooper">drawLooper</a>. |
| 3614 | Pass nullptr to clear <a href="undocumented#Draw_Looper">Draw Looper</a> and leave <a href="undocumented#Draw_Looper">Draw Looper</a> effect on drawing unaltered. |
| 3615 | Does not alter <a href="SkPaint_Reference#drawLooper">drawLooper</a> <a href="undocumented#Reference_Count">Reference Count</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3616 | |
| 3617 | ### Parameters |
| 3618 | |
| 3619 | <table> <tr> <td><code><strong>drawLooper </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3620 | Iterates through drawing one or more time, altering <a href="SkPaint_Reference#Paint">Paint</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3621 | </tr> |
| 3622 | </table> |
| 3623 | |
| 3624 | ### Example |
| 3625 | |
| 3626 | <div><fiddle-embed name="bf10f838b330f0a3a3266d42ea68a638"></fiddle-embed></div> |
| 3627 | |
| 3628 | --- |
| 3629 | |
| 3630 | <a name="setLooper"></a> |
| 3631 | ## setLooper |
| 3632 | |
| 3633 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3634 | void setLooper(sk_sp<SkDrawLooper> drawLooper) |
| 3635 | </pre> |
| 3636 | |
| 3637 | Deprecated. |
| 3638 | |
| 3639 | (see bug.skia.org/6259) |
| 3640 | |
| 3641 | ### Parameters |
| 3642 | |
| 3643 | <table> <tr> <td><code><strong>drawLooper </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3644 | sets <a href="undocumented#Draw_Looper">Draw Looper</a> to <a href="SkPaint_Reference#drawLooper">drawLooper</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3645 | </tr> |
| 3646 | |
| 3647 | --- |
| 3648 | |
| 3649 | </table> |
| 3650 | |
| 3651 | # <a name="Text_Align"></a> Text Align |
| 3652 | |
| 3653 | ## <a name="SkPaint::Align"></a> Enum SkPaint::Align |
| 3654 | |
| 3655 | <pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0"> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3656 | enum <a href="SkPaint_Reference#Align">Align</a> { |
| 3657 | <a href="SkPaint_Reference#kLeft_Align">kLeft Align</a>, |
| 3658 | <a href="SkPaint_Reference#kCenter_Align">kCenter Align</a>, |
| 3659 | <a href="SkPaint_Reference#kRight_Align">kRight Align</a>, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3660 | };</pre> |
| 3661 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3662 | <a href="SkPaint_Reference#Align">Align</a> adjusts the text relative to the text position. |
| 3663 | <a href="SkPaint_Reference#Align">Align</a> affects glyphs drawn with: <a href="SkCanvas_Reference#drawText">SkCanvas::drawText</a>, <a href="SkCanvas_Reference#drawPosText">SkCanvas::drawPosText</a>, |
| 3664 | <a href="SkCanvas_Reference#drawPosTextH">SkCanvas::drawPosTextH</a>, <a href="SkCanvas_Reference#drawTextOnPath">SkCanvas::drawTextOnPath</a>, |
| 3665 | <a href="SkCanvas_Reference#drawTextOnPathHV">SkCanvas::drawTextOnPathHV</a>, <a href="SkCanvas_Reference#drawTextRSXform">SkCanvas::drawTextRSXform</a>, <a href="SkCanvas_Reference#drawTextBlob">SkCanvas::drawTextBlob</a>, |
| 3666 | and <a href="SkCanvas_Reference#drawString">SkCanvas::drawString</a>; |
| 3667 | as well as calls that place text glyphs like <a href="SkPaint_Reference#getTextWidths">getTextWidths</a> and <a href="SkPaint_Reference#getTextPath">getTextPath</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3668 | |
| 3669 | The text position is set by the font for both horizontal and vertical text. |
| 3670 | Typically, for horizontal text, the position is to the left side of the glyph on the |
| 3671 | base line; and for vertical text, the position is the horizontal center of the glyph |
| 3672 | at the caps height. |
| 3673 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3674 | <a href="SkPaint_Reference#Align">Align</a> adjusts the glyph position to center it or move it to abut the position |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3675 | using the metrics returned by the font. |
| 3676 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3677 | <a href="SkPaint_Reference#Align">Align</a> defaults to <a href="SkPaint_Reference#kLeft_Align">kLeft Align</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3678 | |
| 3679 | ### Constants |
| 3680 | |
| 3681 | <table> |
| 3682 | <tr> |
| 3683 | <td><a name="SkPaint::kLeft_Align"></a> <code><strong>SkPaint::kLeft_Align </strong></code></td><td>0</td><td>Leaves the glyph at the position computed by the font offset by the text position.</td> |
| 3684 | </tr> |
| 3685 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3686 | <td><a name="SkPaint::kCenter_Align"></a> <code><strong>SkPaint::kCenter_Align </strong></code></td><td>1</td><td>Moves the glyph half its width if <a href="SkPaint_Reference#Flags">Flags</a> has <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> clear, and |
| 3687 | half its height if <a href="SkPaint_Reference#Flags">Flags</a> has <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> set.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3688 | </tr> |
| 3689 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3690 | <td><a name="SkPaint::kRight_Align"></a> <code><strong>SkPaint::kRight_Align </strong></code></td><td>2</td><td>Moves the glyph by its width if <a href="SkPaint_Reference#Flags">Flags</a> has <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> clear, |
| 3691 | and by its height if <a href="SkPaint_Reference#Flags">Flags</a> has <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> set.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3692 | </tr> |
| 3693 | |
| 3694 | </table> |
| 3695 | |
| 3696 | ## <a name="SkPaint::_anonymous_2"></a> Enum SkPaint::_anonymous_2 |
| 3697 | |
| 3698 | <pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0"> |
| 3699 | enum { |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3700 | <a href="SkPaint_Reference#kAlignCount">kAlignCount</a> = 3, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3701 | };</pre> |
| 3702 | |
| 3703 | ### Constants |
| 3704 | |
| 3705 | <table> |
| 3706 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3707 | <td><a name="SkPaint::kAlignCount"></a> <code><strong>SkPaint::kAlignCount </strong></code></td><td>3</td><td>The number of different <a href="SkPaint_Reference#Text_Align">Text Align</a> values defined.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3708 | </tr> |
| 3709 | |
| 3710 | </table> |
| 3711 | |
| 3712 | ### Example |
| 3713 | |
| 3714 | <div><fiddle-embed name="702617fd9ebc3f12e30081b5db93e8a8"><div>Each position separately moves the glyph in drawPosText.</div></fiddle-embed></div> |
| 3715 | |
| 3716 | ### Example |
| 3717 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3718 | <div><fiddle-embed name="f1cbbbafe6b3c52b81309cccbf96a308"><div><a href="SkPaint_Reference#Vertical_Text">Vertical Text</a> treats <a href="SkPaint_Reference#kLeft_Align">kLeft Align</a> as top align, and <a href="SkPaint_Reference#kRight_Align">kRight Align</a> as bottom align.</div></fiddle-embed></div> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3719 | |
| 3720 | <a name="getTextAlign"></a> |
| 3721 | ## getTextAlign |
| 3722 | |
| 3723 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3724 | Align getTextAlign() const |
| 3725 | </pre> |
| 3726 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3727 | Returns <a href="SkPaint_Reference#Text_Align">Text Align</a>. |
| 3728 | Returns <a href="SkPaint_Reference#kLeft_Align">kLeft Align</a> if <a href="SkPaint_Reference#Text_Align">Text Align</a> has not been set. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3729 | |
| 3730 | ### Return Value |
| 3731 | |
| 3732 | text placement relative to position |
| 3733 | |
| 3734 | ### Example |
| 3735 | |
| 3736 | <div><fiddle-embed name="2df932f526e810f74c89d30ec3f4c947"> |
| 3737 | |
| 3738 | #### Example Output |
| 3739 | |
| 3740 | ~~~~ |
| 3741 | kLeft_Align == default |
| 3742 | ~~~~ |
| 3743 | |
| 3744 | </fiddle-embed></div> |
| 3745 | |
| 3746 | --- |
| 3747 | |
| 3748 | <a name="setTextAlign"></a> |
| 3749 | ## setTextAlign |
| 3750 | |
| 3751 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3752 | void setTextAlign(Align align) |
| 3753 | </pre> |
| 3754 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3755 | Sets <a href="SkPaint_Reference#Text_Align">Text Align</a> to <a href="SkPaint_Reference#align">align</a>. |
| 3756 | Has no effect if <a href="SkPaint_Reference#align">align</a> is an invalid value. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3757 | |
| 3758 | ### Parameters |
| 3759 | |
| 3760 | <table> <tr> <td><code><strong>align </strong></code></td> <td> |
| 3761 | text placement relative to position</td> |
| 3762 | </tr> |
| 3763 | </table> |
| 3764 | |
| 3765 | ### Example |
| 3766 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3767 | <div><fiddle-embed name="d37540afd918506ac2594665ca63979b"><div><a href="undocumented#Text">Text</a> is left-aligned by default, and then set to center. Setting the |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3768 | alignment out of range has no effect.</div></fiddle-embed></div> |
| 3769 | |
| 3770 | --- |
| 3771 | |
| 3772 | # <a name="Text_Size"></a> Text Size |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3773 | <a href="SkPaint_Reference#Text_Size">Text Size</a> adjusts the overall text size in points. |
| 3774 | <a href="SkPaint_Reference#Text_Size">Text Size</a> can be set to any positive value or zero. |
| 3775 | <a href="SkPaint_Reference#Text_Size">Text Size</a> defaults to 12. |
| 3776 | Set <a href="undocumented#SkPaintDefaults_TextSize">SkPaintDefaults TextSize</a> at compile time to change the default setting. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3777 | |
| 3778 | ### Example |
| 3779 | |
| 3780 | <div><fiddle-embed name="91c9a3e498bb9412e4522a95d076ed5f"></fiddle-embed></div> |
| 3781 | |
| 3782 | <a name="getTextSize"></a> |
| 3783 | ## getTextSize |
| 3784 | |
| 3785 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3786 | SkScalar getTextSize() const |
| 3787 | </pre> |
| 3788 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3789 | Returns <a href="SkPaint_Reference#Text_Size">Text Size</a> in points. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3790 | |
| 3791 | ### Return Value |
| 3792 | |
| 3793 | typographic height of text |
| 3794 | |
| 3795 | ### Example |
| 3796 | |
| 3797 | <div><fiddle-embed name="983e2a71ba72d4ba8c945420040b8f1c"></fiddle-embed></div> |
| 3798 | |
| 3799 | --- |
| 3800 | |
| 3801 | <a name="setTextSize"></a> |
| 3802 | ## setTextSize |
| 3803 | |
| 3804 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3805 | void setTextSize(SkScalar textSize) |
| 3806 | </pre> |
| 3807 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3808 | Sets <a href="SkPaint_Reference#Text_Size">Text Size</a> in points. |
| 3809 | Has no effect if <a href="SkPaint_Reference#textSize">textSize</a> is not greater than or equal to zero. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3810 | |
| 3811 | ### Parameters |
| 3812 | |
| 3813 | <table> <tr> <td><code><strong>textSize </strong></code></td> <td> |
| 3814 | typographic height of text</td> |
| 3815 | </tr> |
| 3816 | </table> |
| 3817 | |
| 3818 | ### Example |
| 3819 | |
| 3820 | <div><fiddle-embed name="6510c9e2f57b83c47e67829e7a68d493"></fiddle-embed></div> |
| 3821 | |
| 3822 | --- |
| 3823 | |
| 3824 | # <a name="Text_Scale_X"></a> Text Scale X |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3825 | <a href="SkPaint_Reference#Text_Scale_X">Text Scale X</a> adjusts the text horizontal scale. |
| 3826 | <a href="undocumented#Text">Text</a> scaling approximates condensed and expanded type faces when the actual face |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3827 | is not available. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3828 | <a href="SkPaint_Reference#Text_Scale_X">Text Scale X</a> can be set to any value. |
| 3829 | <a href="SkPaint_Reference#Text_Scale_X">Text Scale X</a> defaults to 1. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3830 | |
| 3831 | ### Example |
| 3832 | |
| 3833 | <div><fiddle-embed name="d13d787c1e36f515319fc998411c1d91"></fiddle-embed></div> |
| 3834 | |
| 3835 | <a name="getTextScaleX"></a> |
| 3836 | ## getTextScaleX |
| 3837 | |
| 3838 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3839 | SkScalar getTextScaleX() const |
| 3840 | </pre> |
| 3841 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3842 | Returns <a href="SkPaint_Reference#Text_Scale_X">Text Scale X</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3843 | Default value is 1. |
| 3844 | |
| 3845 | ### Return Value |
| 3846 | |
| 3847 | text horizontal scale |
| 3848 | |
| 3849 | ### Example |
| 3850 | |
| 3851 | <div><fiddle-embed name="5dc8e58f6910cb8e4de9ed60f888188b"></fiddle-embed></div> |
| 3852 | |
| 3853 | --- |
| 3854 | |
| 3855 | <a name="setTextScaleX"></a> |
| 3856 | ## setTextScaleX |
| 3857 | |
| 3858 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3859 | void setTextScaleX(SkScalar scaleX) |
| 3860 | </pre> |
| 3861 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3862 | Sets <a href="SkPaint_Reference#Text_Scale_X">Text Scale X</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3863 | Default value is 1. |
| 3864 | |
| 3865 | ### Parameters |
| 3866 | |
| 3867 | <table> <tr> <td><code><strong>scaleX </strong></code></td> <td> |
| 3868 | text horizontal scale</td> |
| 3869 | </tr> |
| 3870 | </table> |
| 3871 | |
| 3872 | ### Example |
| 3873 | |
| 3874 | <div><fiddle-embed name="a75bbdb8bb866b125c4c1dd5e967d470"></fiddle-embed></div> |
| 3875 | |
| 3876 | --- |
| 3877 | |
| 3878 | # <a name="Text_Skew_X"></a> Text Skew X |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3879 | <a href="SkPaint_Reference#Text_Skew_X">Text Skew X</a> adjusts the text horizontal slant. |
| 3880 | <a href="undocumented#Text">Text</a> skewing approximates italic and oblique type faces when the actual face |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3881 | is not available. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3882 | <a href="SkPaint_Reference#Text_Skew_X">Text Skew X</a> can be set to any value. |
| 3883 | <a href="SkPaint_Reference#Text_Skew_X">Text Skew X</a> defaults to 0. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3884 | |
| 3885 | ### Example |
| 3886 | |
| 3887 | <div><fiddle-embed name="aff208b0aab265f273045b27e683c17c"></fiddle-embed></div> |
| 3888 | |
| 3889 | <a name="getTextSkewX"></a> |
| 3890 | ## getTextSkewX |
| 3891 | |
| 3892 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3893 | SkScalar getTextSkewX() const |
| 3894 | </pre> |
| 3895 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3896 | Returns <a href="SkPaint_Reference#Text_Skew_X">Text Skew X</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3897 | Default value is zero. |
| 3898 | |
| 3899 | ### Return Value |
| 3900 | |
| 3901 | additional shear in x-axis relative to y-axis |
| 3902 | |
| 3903 | ### Example |
| 3904 | |
| 3905 | <div><fiddle-embed name="11c10f466dae0d1639dbb9f6a0040218"></fiddle-embed></div> |
| 3906 | |
| 3907 | --- |
| 3908 | |
| 3909 | <a name="setTextSkewX"></a> |
| 3910 | ## setTextSkewX |
| 3911 | |
| 3912 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3913 | void setTextSkewX(SkScalar skewX) |
| 3914 | </pre> |
| 3915 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3916 | Sets <a href="SkPaint_Reference#Text_Skew_X">Text Skew X</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3917 | Default value is zero. |
| 3918 | |
| 3919 | ### Parameters |
| 3920 | |
| 3921 | <table> <tr> <td><code><strong>skewX </strong></code></td> <td> |
| 3922 | additional shear in x-axis relative to y-axis</td> |
| 3923 | </tr> |
| 3924 | </table> |
| 3925 | |
| 3926 | ### Example |
| 3927 | |
| 3928 | <div><fiddle-embed name="6bd705a6e0c5f8ee24f302fe531bfabc"></fiddle-embed></div> |
| 3929 | |
| 3930 | --- |
| 3931 | |
| 3932 | # <a name="Text_Encoding"></a> Text Encoding |
| 3933 | |
| 3934 | ## <a name="SkPaint::TextEncoding"></a> Enum SkPaint::TextEncoding |
| 3935 | |
| 3936 | <pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0"> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3937 | enum <a href="SkPaint_Reference#TextEncoding">TextEncoding</a> { |
| 3938 | <a href="SkPaint_Reference#kUTF8_TextEncoding">kUTF8 TextEncoding</a>, |
| 3939 | <a href="SkPaint_Reference#kUTF16_TextEncoding">kUTF16 TextEncoding</a>, |
| 3940 | <a href="SkPaint_Reference#kUTF32_TextEncoding">kUTF32 TextEncoding</a>, |
| 3941 | <a href="SkPaint_Reference#kGlyphID_TextEncoding">kGlyphID TextEncoding</a>, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3942 | };</pre> |
| 3943 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3944 | <a href="SkPaint_Reference#TextEncoding">TextEncoding</a> determines whether text specifies character codes and their encoded size, |
| 3945 | or glyph indices. Character codes use the encoding specified by the<a href="undocumented#Unicode">Unicode</a> standardhttp://unicode.org/standard/standard.html. |
| 3946 | Character codes encoded size are specified by <a href="undocumented#UTF_8">UTF-8</a>, <a href="undocumented#UTF_16">UTF-16</a>, or <a href="undocumented#UTF_32">UTF-32</a>. |
| 3947 | All character encoding are able to represent all of <a href="undocumented#Unicode">Unicode</a>, differing only |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3948 | in the total storage required. |
| 3949 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3950 | <a href="undocumented#UTF_8">UTF-8</a> (<a href="undocumented#RFC">RFC</a> 3629)https://tools.ietf.org/html/rfc3629is made up of 8-bit bytes, |
| 3951 | and is a superset of <a href="undocumented#ASCII">ASCII</a>. |
| 3952 | <a href="undocumented#UTF_16">UTF-16</a> (<a href="undocumented#RFC">RFC</a> 2781)https://tools.ietf.org/html/rfc2781is made up of 16-bit words, |
| 3953 | and is a superset of <a href="undocumented#Unicode">Unicode</a> ranges 0x0000 to 0xD7FF and 0xE000 to 0xFFFF. |
| 3954 | <a href="undocumented#UTF_32">UTF-32</a>http://www.unicode.org/versions/<a href="undocumented#Unicode5">Unicode5</a>.0.0/ch03.pdfis |
| 3955 | made up of 32-bit words, and is a superset of <a href="undocumented#Unicode">Unicode</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3956 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3957 | <a href="undocumented#Font_Manager">Font Manager</a> uses font data to convert character code points into glyph indices. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3958 | A glyph index is a 16-bit word. |
| 3959 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3960 | <a href="SkPaint_Reference#TextEncoding">TextEncoding</a> is set to <a href="SkPaint_Reference#kUTF8_TextEncoding">kUTF8 TextEncoding</a> by default. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3961 | |
| 3962 | ### Constants |
| 3963 | |
| 3964 | <table> |
| 3965 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3966 | <td><a name="SkPaint::kUTF8_TextEncoding"></a> <code><strong>SkPaint::kUTF8_TextEncoding </strong></code></td><td>0</td><td>Uses bytes to represent <a href="undocumented#UTF_8">UTF-8</a> or <a href="undocumented#ASCII">ASCII</a>.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3967 | </tr> |
| 3968 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3969 | <td><a name="SkPaint::kUTF16_TextEncoding"></a> <code><strong>SkPaint::kUTF16_TextEncoding </strong></code></td><td>1</td><td>Uses two byte words to represent most of <a href="undocumented#Unicode">Unicode</a>.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3970 | </tr> |
| 3971 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3972 | <td><a name="SkPaint::kUTF32_TextEncoding"></a> <code><strong>SkPaint::kUTF32_TextEncoding </strong></code></td><td>2</td><td>Uses four byte words to represent all of <a href="undocumented#Unicode">Unicode</a>.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3973 | </tr> |
| 3974 | <tr> |
| 3975 | <td><a name="SkPaint::kGlyphID_TextEncoding"></a> <code><strong>SkPaint::kGlyphID_TextEncoding </strong></code></td><td>3</td><td>Uses two byte words to represent glyph indices.</td> |
| 3976 | </tr> |
| 3977 | |
| 3978 | </table> |
| 3979 | |
| 3980 | ### Example |
| 3981 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3982 | <div><fiddle-embed name="b29294e7f29d160a1b46abf2dcec9d2a"><div>First line has <a href="undocumented#UTF_8">UTF-8</a> encoding. |
| 3983 | Second line has <a href="undocumented#UTF_16">UTF-16</a> encoding. |
| 3984 | Third line has <a href="undocumented#UTF_32">UTF-32</a> encoding. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3985 | Fourth line has 16 bit glyph indices.</div></fiddle-embed></div> |
| 3986 | |
| 3987 | <a name="getTextEncoding"></a> |
| 3988 | ## getTextEncoding |
| 3989 | |
| 3990 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 3991 | TextEncoding getTextEncoding() const |
| 3992 | </pre> |
| 3993 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3994 | Returns <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a>. |
| 3995 | <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> determines how character code points are mapped to font glyph indices. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 3996 | |
| 3997 | ### Return Value |
| 3998 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 3999 | one of: <a href="SkPaint_Reference#kUTF8_TextEncoding">kUTF8 TextEncoding</a>, <a href="SkPaint_Reference#kUTF16_TextEncoding">kUTF16 TextEncoding</a>, <a href="SkPaint_Reference#kUTF32_TextEncoding">kUTF32 TextEncoding</a>, or |
| 4000 | <a href="SkPaint_Reference#kGlyphID_TextEncoding">kGlyphID TextEncoding</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4001 | |
| 4002 | ### Example |
| 4003 | |
| 4004 | <div><fiddle-embed name="70ad28bbf7668b38474d7f225e3540bc"> |
| 4005 | |
| 4006 | #### Example Output |
| 4007 | |
| 4008 | ~~~~ |
| 4009 | kUTF8_TextEncoding == text encoding |
| 4010 | kGlyphID_TextEncoding == text encoding |
| 4011 | ~~~~ |
| 4012 | |
| 4013 | </fiddle-embed></div> |
| 4014 | |
| 4015 | --- |
| 4016 | |
| 4017 | <a name="setTextEncoding"></a> |
| 4018 | ## setTextEncoding |
| 4019 | |
| 4020 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4021 | void setTextEncoding(TextEncoding encoding) |
| 4022 | </pre> |
| 4023 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4024 | Sets <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> to <a href="SkPaint_Reference#setTextEncoding">encoding</a>. |
| 4025 | <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> determines how character code points are mapped to font glyph indices. |
| 4026 | Invalid values for <a href="SkPaint_Reference#setTextEncoding">encoding</a> are ignored. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4027 | |
| 4028 | ### Parameters |
| 4029 | |
| 4030 | <table> <tr> <td><code><strong>encoding </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4031 | one of: <a href="SkPaint_Reference#kUTF8_TextEncoding">kUTF8 TextEncoding</a>, <a href="SkPaint_Reference#kUTF16_TextEncoding">kUTF16 TextEncoding</a>, <a href="SkPaint_Reference#kUTF32_TextEncoding">kUTF32 TextEncoding</a>, or |
| 4032 | <a href="SkPaint_Reference#kGlyphID_TextEncoding">kGlyphID TextEncoding</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4033 | </tr> |
Cary Clark | bad5ad7 | 2017-08-03 17:14:08 -0400 | [diff] [blame] | 4034 | # |
| 4035 | |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4036 | </table> |
| 4037 | |
| 4038 | ### Example |
| 4039 | |
| 4040 | <div><fiddle-embed name="329b92fbc35151dee9aa0c0e70107665"> |
| 4041 | |
| 4042 | #### Example Output |
| 4043 | |
| 4044 | ~~~~ |
| 4045 | 4 != text encoding |
| 4046 | ~~~~ |
| 4047 | |
| 4048 | </fiddle-embed></div> |
| 4049 | |
| 4050 | --- |
| 4051 | |
| 4052 | # <a name="Font_Metrics"></a> Font Metrics |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4053 | <a href="SkPaint_Reference#Font_Metrics">Font Metrics</a> describe dimensions common to the glyphs in <a href="undocumented#Typeface">Typeface</a>. |
| 4054 | The dimensions are computed by <a href="undocumented#Font_Manager">Font Manager</a> from font data and do not take |
| 4055 | <a href="SkPaint_Reference#Paint">Paint</a> settings other than <a href="SkPaint_Reference#Text_Size">Text Size</a> into account. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4056 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4057 | <a href="undocumented#Font">Font</a> dimensions specify the anchor to the left of the glyph at baseline as the origin. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4058 | X-axis values to the left of the glyph are negative, and to the right of the left glyph edge |
| 4059 | are positive. |
| 4060 | Y-axis values above the baseline are negative, and below the baseline are positive. |
| 4061 | |
| 4062 | ### Example |
| 4063 | |
| 4064 | <div><fiddle-embed name="b5b76e0a15da0c3530071186a9006498"></fiddle-embed></div> |
| 4065 | |
| 4066 | # <a name="SkPaint::FontMetrics"></a> Struct SkPaint::FontMetrics |
| 4067 | |
| 4068 | <pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0"> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4069 | struct <a href="SkPaint_Reference#FontMetrics">FontMetrics</a> { |
| 4070 | enum <a href="SkPaint_Reference#FontMetrics_FontMetricsFlags">FontMetricsFlags</a> { |
| 4071 | <a href="SkPaint_Reference#FontMetrics_kUnderlineThicknessIsValid_Flag">kUnderlineThicknessIsValid Flag</a> = 1 << 0, |
| 4072 | <a href="SkPaint_Reference#FontMetrics_kUnderlinePositionIsValid_Flag">kUnderlinePositionIsValid Flag</a> = 1 << 1, |
| 4073 | <a href="SkPaint_Reference#FontMetrics_kStrikeoutThicknessIsValid_Flag">kStrikeoutThicknessIsValid Flag</a> = 1 << 2, |
| 4074 | <a href="SkPaint_Reference#FontMetrics_kStrikeoutPositionIsValid_Flag">kStrikeoutPositionIsValid Flag</a> = 1 << 3, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4075 | }; |
| 4076 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4077 | uint32_t <a href="SkPaint_Reference#FontMetrics_fFlags">fFlags</a>; |
| 4078 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fTop">fTop</a>; |
| 4079 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fAscent">fAscent</a>; |
| 4080 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fDescent">fDescent</a>; |
| 4081 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fBottom">fBottom</a>; |
| 4082 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fLeading">fLeading</a>; |
| 4083 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fAvgCharWidth">fAvgCharWidth</a>; |
| 4084 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fMaxCharWidth">fMaxCharWidth</a>; |
| 4085 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fXMin">fXMin</a>; |
| 4086 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fXMax">fXMax</a>; |
| 4087 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fXHeight">fXHeight</a>; |
| 4088 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fCapHeight">fCapHeight</a>; |
| 4089 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fUnderlineThickness">fUnderlineThickness</a>; |
| 4090 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fUnderlinePosition">fUnderlinePosition</a>; |
| 4091 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fStrikeoutThickness">fStrikeoutThickness</a>; |
| 4092 | <a href="undocumented#SkScalar">SkScalar</a> <a href="SkPaint_Reference#FontMetrics_fStrikeoutPosition">fStrikeoutPosition</a>; |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4093 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4094 | bool <a href="SkPaint_Reference#FontMetrics_hasUnderlineThickness">hasUnderlineThickness(SkScalar* thickness)</a> const; |
| 4095 | bool <a href="SkPaint_Reference#FontMetrics_hasUnderlinePosition">hasUnderlinePosition(SkScalar* position)</a> const; |
| 4096 | bool <a href="SkPaint_Reference#FontMetrics_hasStrikeoutThickness">hasStrikeoutThickness(SkScalar* thickness)</a> const; |
| 4097 | bool <a href="SkPaint_Reference#FontMetrics_hasStrikeoutPosition">hasStrikeoutPosition(SkScalar* position)</a> const; |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4098 | };</pre> |
| 4099 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4100 | <a href="SkPaint_Reference#FontMetrics">FontMetrics</a> is filled out by <a href="SkPaint_Reference#getFontMetrics">getFontMetrics</a>. <a href="SkPaint_Reference#FontMetrics">FontMetrics</a> contents reflect the values |
| 4101 | computed by <a href="undocumented#Font_Manager">Font Manager</a> using <a href="undocumented#Typeface">Typeface</a>. Values are set to zero if they are |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4102 | not availble. |
| 4103 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4104 | <a href="SkPaint_Reference#FontMetrics_fUnderlineThickness">fUnderlineThickness</a> and <a href="SkPaint_Reference#FontMetrics_fUnderlinePosition">fUnderlinePosition</a> have a bit set in <a href="SkPaint_Reference#FontMetrics_fFlags">fFlags</a> if their values |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4105 | are valid, since their value may be zero. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4106 | <a href="SkPaint_Reference#FontMetrics_fStrikeoutThickness">fStrikeoutThickness</a> and <a href="SkPaint_Reference#FontMetrics_fStrikeoutPosition">fStrikeoutPosition</a> have a bit set in <a href="SkPaint_Reference#FontMetrics_fFlags">fFlags</a> if their values |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4107 | are valid, since their value may be zero. |
| 4108 | |
| 4109 | ## <a name="SkPaint::FontMetrics::FontMetricsFlags"></a> Enum SkPaint::FontMetrics::FontMetricsFlags |
| 4110 | |
| 4111 | <pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0"> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4112 | enum <a href="SkPaint_Reference#FontMetrics_FontMetricsFlags">FontMetricsFlags</a> { |
| 4113 | <a href="SkPaint_Reference#FontMetrics_kUnderlineThicknessIsValid_Flag">kUnderlineThicknessIsValid Flag</a> = 1 << 0, |
| 4114 | <a href="SkPaint_Reference#FontMetrics_kUnderlinePositionIsValid_Flag">kUnderlinePositionIsValid Flag</a> = 1 << 1, |
| 4115 | <a href="SkPaint_Reference#FontMetrics_kStrikeoutThicknessIsValid_Flag">kStrikeoutThicknessIsValid Flag</a> = 1 << 2, |
| 4116 | <a href="SkPaint_Reference#FontMetrics_kStrikeoutPositionIsValid_Flag">kStrikeoutPositionIsValid Flag</a> = 1 << 3, |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4117 | };</pre> |
| 4118 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4119 | <a href="SkPaint_Reference#FontMetrics_FontMetricsFlags">FontMetricsFlags</a> are set in <a href="SkPaint_Reference#FontMetrics_fFlags">fFlags</a> when underline and strikeout metrics are valid; |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4120 | the underline or strikeout metric may be valid and zero. |
| 4121 | Fonts with embedded bitmaps may not have valid underline or strikeout metrics. |
| 4122 | |
| 4123 | ### Constants |
| 4124 | |
| 4125 | <table> |
| 4126 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4127 | <td><a name="SkPaint::FontMetrics::kUnderlineThicknessIsValid_Flag"></a> <code><strong>SkPaint::FontMetrics::kUnderlineThicknessIsValid_Flag </strong></code></td><td>0x0001</td><td>Set if <a href="SkPaint_Reference#FontMetrics_fUnderlineThickness">fUnderlineThickness</a> is valid.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4128 | </tr> |
| 4129 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4130 | <td><a name="SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag"></a> <code><strong>SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag </strong></code></td><td>0x0002</td><td>Set if <a href="SkPaint_Reference#FontMetrics_fUnderlinePosition">fUnderlinePosition</a> is valid.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4131 | </tr> |
| 4132 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4133 | <td><a name="SkPaint::FontMetrics::kStrikeoutThicknessIsValid_Flag"></a> <code><strong>SkPaint::FontMetrics::kStrikeoutThicknessIsValid_Flag </strong></code></td><td>0x0004</td><td>Set if <a href="SkPaint_Reference#FontMetrics_fStrikeoutThickness">fStrikeoutThickness</a> is valid.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4134 | </tr> |
| 4135 | <tr> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4136 | <td><a name="SkPaint::FontMetrics::kStrikeoutPositionIsValid_Flag"></a> <code><strong>SkPaint::FontMetrics::kStrikeoutPositionIsValid_Flag </strong></code></td><td>0x0008</td><td>Set if <a href="SkPaint_Reference#FontMetrics_fStrikeoutPosition">fStrikeoutPosition</a> is valid.</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4137 | </tr> |
| 4138 | |
| 4139 | </table> |
| 4140 | |
| 4141 | <code><strong>uint32_t fFlags</strong></code> |
| 4142 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4143 | <a href="SkPaint_Reference#FontMetrics_fFlags">fFlags</a> is set when underline metrics are valid. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4144 | |
| 4145 | <code><strong>SkScalar fTop</strong></code> |
| 4146 | |
| 4147 | Largest height for any glyph. |
| 4148 | A measure from the baseline, and is less than or equal to zero. |
| 4149 | |
| 4150 | <code><strong>SkScalar fAscent</strong></code> |
| 4151 | |
| 4152 | Recommended distance above the baseline to reserve for a line of text. |
| 4153 | A measure from the baseline, and is less than or equal to zero. |
| 4154 | |
| 4155 | <code><strong>SkScalar fDescent</strong></code> |
| 4156 | |
| 4157 | Recommended distance below the baseline to reserve for a line of text. |
| 4158 | A measure from the baseline, and is greater than or equal to zero. |
| 4159 | |
| 4160 | <code><strong>SkScalar fBottom</strong></code> |
| 4161 | |
| 4162 | Greatest extent below the baseline for any glyph. |
| 4163 | A measure from the baseline, and is greater than or equal to zero. |
| 4164 | |
| 4165 | <code><strong>SkScalar fLeading</strong></code> |
| 4166 | |
| 4167 | Recommended distance to add between lines of text. |
| 4168 | Greater than or equal to zero. |
| 4169 | |
| 4170 | <code><strong>SkScalar fAvgCharWidth</strong></code> |
| 4171 | |
| 4172 | Average character width, if it is available. |
| 4173 | Zero if no average width is stored in the font. |
| 4174 | |
| 4175 | <code><strong>SkScalar fMaxCharWidth</strong></code> |
| 4176 | |
| 4177 | Maximum character width. |
| 4178 | |
| 4179 | <code><strong>SkScalar fXMin</strong></code> |
| 4180 | |
| 4181 | Minimum bounding box x value for all glyphs. |
| 4182 | Typically less than zero. |
| 4183 | |
| 4184 | <code><strong>SkScalar fXMax</strong></code> |
| 4185 | |
| 4186 | Maximum bounding box x value for all glyphs. |
| 4187 | Typically greater than zero. |
| 4188 | |
| 4189 | <code><strong>SkScalar fXHeight</strong></code> |
| 4190 | |
| 4191 | Height of a lower-case 'x'. |
| 4192 | May be zero if no lower-case height is stored in the font. |
| 4193 | |
| 4194 | <code><strong>SkScalar fCapHeight</strong></code> |
| 4195 | |
| 4196 | Height of an upper-case letter. |
| 4197 | May be zero if no upper-case height is stored in the font. |
| 4198 | |
| 4199 | <code><strong>SkScalar fUnderlineThickness</strong></code> |
| 4200 | |
| 4201 | Underline thickness. If the metric |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4202 | is valid, the <a href="SkPaint_Reference#FontMetrics_kUnderlineThicknessIsValid_Flag">kUnderlineThicknessIsValid Flag</a> is set in <a href="SkPaint_Reference#FontMetrics_fFlags">fFlags</a>. |
| 4203 | If <a href="SkPaint_Reference#FontMetrics_kUnderlineThicknessIsValid_Flag">kUnderlineThicknessIsValid Flag</a> is clear, <a href="SkPaint_Reference#FontMetrics_fUnderlineThickness">fUnderlineThickness</a> is zero. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4204 | |
| 4205 | <code><strong>SkScalar fUnderlinePosition</strong></code> |
| 4206 | |
| 4207 | Underline position relative to the baseline. |
| 4208 | It may be negative, to draw the underline above the baseline, zero |
| 4209 | to draw the underline on the baseline, or positive to draw the underline |
| 4210 | below the baseline. |
| 4211 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4212 | If the metric is valid, the <a href="SkPaint_Reference#FontMetrics_kUnderlinePositionIsValid_Flag">kUnderlinePositionIsValid Flag</a> is set in <a href="SkPaint_Reference#FontMetrics_fFlags">fFlags</a>. |
| 4213 | If <a href="SkPaint_Reference#FontMetrics_kUnderlinePositionIsValid_Flag">kUnderlinePositionIsValid Flag</a> is clear, <a href="SkPaint_Reference#FontMetrics_fUnderlinePosition">fUnderlinePosition</a> is zero. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4214 | |
| 4215 | <code><strong>SkScalar fStrikeoutThickness</strong></code> |
| 4216 | |
| 4217 | Strikeout thickness. If the metric |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4218 | is valid, the <a href="SkPaint_Reference#FontMetrics_kStrikeoutThicknessIsValid_Flag">kStrikeoutThicknessIsValid Flag</a> is set in <a href="SkPaint_Reference#FontMetrics_fFlags">fFlags</a>. |
| 4219 | If <a href="SkPaint_Reference#FontMetrics_kStrikeoutThicknessIsValid_Flag">kStrikeoutThicknessIsValid Flag</a> is clear, <a href="SkPaint_Reference#FontMetrics_fStrikeoutThickness">fStrikeoutThickness</a> is zero. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4220 | |
| 4221 | <code><strong>SkScalar fStrikeoutPosition</strong></code> |
| 4222 | |
| 4223 | Strikeout position relative to the baseline. |
| 4224 | It may be negative, to draw the strikeout above the baseline, zero |
| 4225 | to draw the strikeout on the baseline, or positive to draw the strikeout |
| 4226 | below the baseline. |
| 4227 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4228 | If the metric is valid, the <a href="SkPaint_Reference#FontMetrics_kStrikeoutPositionIsValid_Flag">kStrikeoutPositionIsValid Flag</a> is set in <a href="SkPaint_Reference#FontMetrics_fFlags">fFlags</a>. |
| 4229 | If <a href="SkPaint_Reference#FontMetrics_kStrikeoutPositionIsValid_Flag">kStrikeoutPositionIsValid Flag</a> is clear, <a href="SkPaint_Reference#FontMetrics_fStrikeoutPosition">fStrikeoutPosition</a> is zero. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4230 | |
| 4231 | <a name="hasUnderlineThickness"></a> |
| 4232 | ## hasUnderlineThickness |
| 4233 | |
| 4234 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4235 | bool hasUnderlineThickness(SkScalar* thickness) const |
| 4236 | </pre> |
| 4237 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4238 | If <a href="SkPaint_Reference#Font_Metrics">Font Metrics</a> has a valid underline <a href="SkPaint_Reference#thickness">thickness</a>, return true, and set |
| 4239 | <a href="SkPaint_Reference#thickness">thickness</a> to that value. If it doesn't, return false, and ignore |
| 4240 | <a href="SkPaint_Reference#thickness">thickness</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4241 | |
| 4242 | ### Parameters |
| 4243 | |
| 4244 | <table> <tr> <td><code><strong>thickness </strong></code></td> <td> |
| 4245 | storage for underline width</td> |
| 4246 | </tr> |
| 4247 | </table> |
| 4248 | |
| 4249 | ### Return Value |
| 4250 | |
| 4251 | true if font specifies underline width |
| 4252 | |
| 4253 | --- |
| 4254 | |
| 4255 | <a name="hasUnderlinePosition"></a> |
| 4256 | ## hasUnderlinePosition |
| 4257 | |
| 4258 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4259 | bool hasUnderlinePosition(SkScalar* position) const |
| 4260 | </pre> |
| 4261 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4262 | If <a href="SkPaint_Reference#Font_Metrics">Font Metrics</a> has a valid underline <a href="SkPaint_Reference#position">position</a>, return true, and set |
| 4263 | <a href="SkPaint_Reference#position">position</a> to that value. If it doesn't, return false, and ignore |
| 4264 | <a href="SkPaint_Reference#position">position</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4265 | |
| 4266 | ### Parameters |
| 4267 | |
| 4268 | <table> <tr> <td><code><strong>position </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4269 | storage for underline <a href="SkPaint_Reference#position">position</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4270 | </tr> |
| 4271 | </table> |
| 4272 | |
| 4273 | ### Return Value |
| 4274 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4275 | true if font specifies underline <a href="SkPaint_Reference#position">position</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4276 | |
| 4277 | --- |
| 4278 | |
| 4279 | <a name="hasStrikeoutThickness"></a> |
| 4280 | ## hasStrikeoutThickness |
| 4281 | |
| 4282 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4283 | bool hasStrikeoutThickness(SkScalar* thickness) const |
| 4284 | </pre> |
| 4285 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4286 | If <a href="SkPaint_Reference#Font_Metrics">Font Metrics</a> has a valid strikeout <a href="SkPaint_Reference#thickness">thickness</a>, return true, and set |
| 4287 | <a href="SkPaint_Reference#thickness">thickness</a> to that value. If it doesn't, return false, and ignore |
| 4288 | <a href="SkPaint_Reference#thickness">thickness</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4289 | |
| 4290 | ### Parameters |
| 4291 | |
| 4292 | <table> <tr> <td><code><strong>thickness </strong></code></td> <td> |
| 4293 | storage for strikeout width</td> |
| 4294 | </tr> |
| 4295 | </table> |
| 4296 | |
| 4297 | ### Return Value |
| 4298 | |
| 4299 | true if font specifies strikeout width |
| 4300 | |
| 4301 | --- |
| 4302 | |
| 4303 | <a name="hasStrikeoutPosition"></a> |
| 4304 | ## hasStrikeoutPosition |
| 4305 | |
| 4306 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4307 | bool hasStrikeoutPosition(SkScalar* position) const |
| 4308 | </pre> |
| 4309 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4310 | If <a href="SkPaint_Reference#Font_Metrics">Font Metrics</a> has a valid strikeout <a href="SkPaint_Reference#position">position</a>, return true, and set |
| 4311 | <a href="SkPaint_Reference#position">position</a> to that value. If it doesn't, return false, and ignore |
| 4312 | <a href="SkPaint_Reference#position">position</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4313 | |
| 4314 | ### Parameters |
| 4315 | |
| 4316 | <table> <tr> <td><code><strong>position </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4317 | storage for strikeout <a href="SkPaint_Reference#position">position</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4318 | </tr> |
| 4319 | </table> |
| 4320 | |
| 4321 | ### Return Value |
| 4322 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4323 | true if font specifies strikeout <a href="SkPaint_Reference#position">position</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4324 | |
| 4325 | --- |
| 4326 | |
| 4327 | <a name="getFontMetrics"></a> |
| 4328 | ## getFontMetrics |
| 4329 | |
| 4330 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4331 | SkScalar getFontMetrics(FontMetrics* metrics, SkScalar scale = 0) const |
| 4332 | </pre> |
| 4333 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4334 | Returns <a href="SkPaint_Reference#Font_Metrics">Font Metrics</a> associated with <a href="undocumented#Typeface">Typeface</a>. |
| 4335 | The return value is the recommended spacing between lines: the sum of <a href="SkPaint_Reference#metrics">metrics</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4336 | descent, ascent, and leading. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4337 | If <a href="SkPaint_Reference#metrics">metrics</a> is not nullptr, <a href="SkPaint_Reference#Font_Metrics">Font Metrics</a> is copied to <a href="SkPaint_Reference#metrics">metrics</a>. |
| 4338 | Results are scaled by <a href="SkPaint_Reference#Text_Size">Text Size</a> but does not take into account |
| 4339 | dimensions required by <a href="SkPaint_Reference#Text_Scale_X">Text Scale X</a>, <a href="SkPaint_Reference#Text_Skew_X">Text Skew X</a>, <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a>, |
| 4340 | <a href="SkPaint_Reference#Style_Stroke">Style Stroke</a>, and <a href="undocumented#Path_Effect">Path Effect</a>. |
| 4341 | Results can be additionally scaled by <a href="SkPaint_Reference#scale">scale</a>; a <a href="SkPaint_Reference#scale">scale</a> of zero |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4342 | is ignored. |
| 4343 | |
| 4344 | ### Parameters |
| 4345 | |
| 4346 | <table> <tr> <td><code><strong>metrics </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4347 | storage for <a href="SkPaint_Reference#Font_Metrics">Font Metrics</a> from <a href="undocumented#Typeface">Typeface</a>; may be nullptr</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4348 | </tr> <tr> <td><code><strong>scale </strong></code></td> <td> |
| 4349 | additional multiplier for returned values</td> |
| 4350 | </tr> |
| 4351 | </table> |
| 4352 | |
| 4353 | ### Return Value |
| 4354 | |
| 4355 | recommended spacing between lines |
| 4356 | |
| 4357 | ### Example |
| 4358 | |
| 4359 | <div><fiddle-embed name="b899d84caba6607340322d317992d070"></fiddle-embed></div> |
| 4360 | |
| 4361 | ### See Also |
| 4362 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4363 | <a href="SkPaint_Reference#Text_Size">Text Size</a> <a href="undocumented#Typeface">Typeface</a> <a href="SkPaint_Reference#Typeface_Methods">Typeface Methods</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4364 | |
| 4365 | --- |
| 4366 | |
| 4367 | <a name="getFontSpacing"></a> |
| 4368 | ## getFontSpacing |
| 4369 | |
| 4370 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4371 | SkScalar getFontSpacing() const |
| 4372 | </pre> |
| 4373 | |
| 4374 | Returns the recommended spacing between lines: the sum of metrics |
| 4375 | descent, ascent, and leading. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4376 | Result is scaled by <a href="SkPaint_Reference#Text_Size">Text Size</a> but does not take into account |
| 4377 | dimensions required by stroking and <a href="undocumented#Path_Effect">Path Effect</a>. |
| 4378 | Returns the same result as <a href="SkPaint_Reference#getFontMetrics">getFontMetrics</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4379 | |
| 4380 | ### Return Value |
| 4381 | |
| 4382 | recommended spacing between lines |
| 4383 | |
| 4384 | ### Example |
| 4385 | |
| 4386 | <div><fiddle-embed name="424741e26e1b174e43087d67422ce14f"> |
| 4387 | |
| 4388 | #### Example Output |
| 4389 | |
| 4390 | ~~~~ |
| 4391 | textSize: 12 fontSpacing: 13.9688 |
| 4392 | textSize: 18 fontSpacing: 20.9531 |
| 4393 | textSize: 24 fontSpacing: 27.9375 |
| 4394 | textSize: 32 fontSpacing: 37.25 |
| 4395 | ~~~~ |
| 4396 | |
| 4397 | </fiddle-embed></div> |
| 4398 | |
| 4399 | --- |
| 4400 | |
| 4401 | <a name="getFontBounds"></a> |
| 4402 | ## getFontBounds |
| 4403 | |
| 4404 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4405 | SkRect getFontBounds() const |
| 4406 | </pre> |
| 4407 | |
| 4408 | Returns the union of bounds of all glyphs. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4409 | Returned dimensions are computed by <a href="undocumented#Font_Manager">Font Manager</a> from font data, |
| 4410 | ignoring <a href="SkPaint_Reference#Hinting">Hinting</a>. Includes <a href="SkPaint_Reference#Text_Size">Text Size</a>, <a href="SkPaint_Reference#Text_Scale_X">Text Scale X</a>, |
| 4411 | and <a href="SkPaint_Reference#Text_Skew_X">Text Skew X</a>, but not <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a> or <a href="undocumented#Path_Effect">Path Effect</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4412 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4413 | If <a href="SkPaint_Reference#Text_Size">Text Size</a> is large, <a href="SkPaint_Reference#Text_Scale_X">Text Scale X</a> is one, and <a href="SkPaint_Reference#Text_Skew_X">Text Skew X</a> is zero, |
| 4414 | returns the same bounds as <a href="SkPaint_Reference#Font_Metrics">Font Metrics</a> { <a href="SkPaint_Reference#FontMetrics_fXMin">FontMetrics::fXMin</a>, |
| 4415 | <a href="SkPaint_Reference#FontMetrics_fTop">FontMetrics::fTop</a>, <a href="SkPaint_Reference#FontMetrics_fXMax">FontMetrics::fXMax</a>, <a href="SkPaint_Reference#FontMetrics_fBottom">FontMetrics::fBottom</a> }. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4416 | |
| 4417 | ### Return Value |
| 4418 | |
| 4419 | union of bounds of all glyphs |
| 4420 | |
| 4421 | ### Example |
| 4422 | |
| 4423 | <div><fiddle-embed name="facaddeec7943bc491988e345e27e65f"> |
| 4424 | |
| 4425 | #### Example Output |
| 4426 | |
| 4427 | ~~~~ |
| 4428 | metrics bounds = { -12.2461, -14.7891, 21.5215, 5.55469 } |
| 4429 | font bounds = { -12.2461, -14.7891, 21.5215, 5.55469 } |
| 4430 | ~~~~ |
| 4431 | |
| 4432 | </fiddle-embed></div> |
| 4433 | |
| 4434 | --- |
| 4435 | |
| 4436 | <a name="textToGlyphs"></a> |
| 4437 | ## textToGlyphs |
| 4438 | |
| 4439 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4440 | int textToGlyphs(const void* text, size_t byteLength, SkGlyphID glyphs[]) const |
| 4441 | </pre> |
| 4442 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4443 | Converts <a href="SkPaint_Reference#text">text</a> into glyph indices. |
| 4444 | Returns the number of glyph indices represented by <a href="SkPaint_Reference#text">text</a>. |
| 4445 | <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> specifies how <a href="SkPaint_Reference#text">text</a> represents characters or <a href="SkPaint_Reference#glyphs">glyphs</a>. |
| 4446 | <a href="SkPaint_Reference#glyphs">glyphs</a> may be nullptr, to compute the glyph count. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4447 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4448 | Does not check <a href="SkPaint_Reference#text">text</a> for valid character encoding or valid |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4449 | glyph indices. |
| 4450 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4451 | If <a href="SkPaint_Reference#byteLength">byteLength</a> equals zero, returns zero. |
| 4452 | If <a href="SkPaint_Reference#byteLength">byteLength</a> includes a partial character, the partial character is ignored. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4453 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4454 | If <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> is <a href="SkPaint_Reference#kUTF8_TextEncoding">kUTF8 TextEncoding</a> and |
| 4455 | <a href="SkPaint_Reference#text">text</a> contains an invalid <a href="undocumented#UTF_8">UTF-8</a> sequence, zero is returned. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4456 | |
| 4457 | ### Parameters |
| 4458 | |
| 4459 | <table> <tr> <td><code><strong>text </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4460 | character stroage encoded with <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4461 | </tr> <tr> <td><code><strong>byteLength </strong></code></td> <td> |
| 4462 | length of character storage in bytes</td> |
| 4463 | </tr> <tr> <td><code><strong>glyphs </strong></code></td> <td> |
| 4464 | storage for glyph indices; may be nullptr</td> |
| 4465 | </tr> |
| 4466 | </table> |
| 4467 | |
| 4468 | ### Return Value |
| 4469 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4470 | number of <a href="SkPaint_Reference#glyphs">glyphs</a> represented by <a href="SkPaint_Reference#text">text</a> of length <a href="SkPaint_Reference#byteLength">byteLength</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4471 | |
| 4472 | ### Example |
| 4473 | |
| 4474 | <div><fiddle-embed name="343e9471a7f7b5f09abdc3b44983433b"></fiddle-embed></div> |
| 4475 | |
| 4476 | --- |
| 4477 | |
| 4478 | <a name="countText"></a> |
| 4479 | ## countText |
| 4480 | |
| 4481 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4482 | int countText(const void* text, size_t byteLength) const |
| 4483 | </pre> |
| 4484 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4485 | Returns the number of glyphs in <a href="SkPaint_Reference#text">text</a>. |
| 4486 | Uses <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> to count the glyphs. |
| 4487 | Returns the same result as <a href="SkPaint_Reference#textToGlyphs">textToGlyphs</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4488 | |
| 4489 | ### Parameters |
| 4490 | |
| 4491 | <table> <tr> <td><code><strong>text </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4492 | character stroage encoded with <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4493 | </tr> <tr> <td><code><strong>byteLength </strong></code></td> <td> |
| 4494 | length of character storage in bytes</td> |
| 4495 | </tr> |
| 4496 | </table> |
| 4497 | |
| 4498 | ### Return Value |
| 4499 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4500 | number of glyphs represented by <a href="SkPaint_Reference#text">text</a> of length <a href="SkPaint_Reference#byteLength">byteLength</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4501 | |
| 4502 | ### Example |
| 4503 | |
| 4504 | <div><fiddle-embed name="85436c71aab5410767fc688ab0573e09"> |
| 4505 | |
| 4506 | #### Example Output |
| 4507 | |
| 4508 | ~~~~ |
| 4509 | count = 5 |
| 4510 | ~~~~ |
| 4511 | |
| 4512 | </fiddle-embed></div> |
| 4513 | |
| 4514 | --- |
| 4515 | |
| 4516 | <a name="containsText"></a> |
| 4517 | ## containsText |
| 4518 | |
| 4519 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4520 | bool containsText(const void* text, size_t byteLength) const |
| 4521 | </pre> |
| 4522 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4523 | Returns true if all <a href="SkPaint_Reference#text">text</a> corresponds to a non-zero glyph index. |
| 4524 | Returns false if any characters in <a href="SkPaint_Reference#text">text</a> are not supported in |
| 4525 | <a href="undocumented#Typeface">Typeface</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4526 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4527 | If <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> is <a href="SkPaint_Reference#kGlyphID_TextEncoding">kGlyphID TextEncoding</a>, |
| 4528 | returns true if all glyph indices in <a href="SkPaint_Reference#text">text</a> are non-zero; |
| 4529 | does not check to see if <a href="SkPaint_Reference#text">text</a> contains valid glyph indices for <a href="undocumented#Typeface">Typeface</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4530 | |
| 4531 | Returns true if bytelength is zero. |
| 4532 | |
| 4533 | ### Parameters |
| 4534 | |
| 4535 | <table> <tr> <td><code><strong>text </strong></code></td> <td> |
| 4536 | array of characters or glyphs</td> |
| 4537 | </tr> <tr> <td><code><strong>byteLength </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4538 | number of bytes in <a href="SkPaint_Reference#text">text</a> array</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4539 | </tr> |
| 4540 | </table> |
| 4541 | |
| 4542 | ### Return Value |
| 4543 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4544 | true if all <a href="SkPaint_Reference#text">text</a> corresponds to a non-zero glyph index |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4545 | |
| 4546 | ### Example |
| 4547 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4548 | <div><fiddle-embed name="9202369019552f09cd4bec7f3046fee4"><div><a href="SkPaint_Reference#containsText">containsText</a> succeeds for degree symbol, but cannot find a glyph index |
| 4549 | corresponding to the <a href="undocumented#Unicode">Unicode</a> surrogate code point.</div> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4550 | |
| 4551 | #### Example Output |
| 4552 | |
| 4553 | ~~~~ |
| 4554 | 0x00b0 == has char |
| 4555 | 0xd800 != has char |
| 4556 | ~~~~ |
| 4557 | |
| 4558 | </fiddle-embed></div> |
| 4559 | |
| 4560 | ### Example |
| 4561 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4562 | <div><fiddle-embed name="904227febfd1c2e264955da0ef66da73"><div><a href="SkPaint_Reference#containsText">containsText</a> returns true that glyph index is greater than zero, not |
| 4563 | that it corresponds to an entry in <a href="undocumented#Typeface">Typeface</a>.</div> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4564 | |
| 4565 | #### Example Output |
| 4566 | |
| 4567 | ~~~~ |
| 4568 | 0x01ff == has glyph |
| 4569 | 0x0000 != has glyph |
| 4570 | 0xffff == has glyph |
| 4571 | ~~~~ |
| 4572 | |
| 4573 | </fiddle-embed></div> |
| 4574 | |
| 4575 | ### See Also |
| 4576 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4577 | <a href="SkPaint_Reference#setTextEncoding">setTextEncoding</a> <a href="undocumented#Typeface">Typeface</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4578 | |
| 4579 | --- |
| 4580 | |
| 4581 | <a name="glyphsToUnichars"></a> |
| 4582 | ## glyphsToUnichars |
| 4583 | |
| 4584 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4585 | void glyphsToUnichars(const SkGlyphID glyphs[], int count, SkUnichar text[]) const |
| 4586 | </pre> |
| 4587 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4588 | Converts <a href="SkPaint_Reference#glyphs">glyphs</a> into <a href="SkPaint_Reference#text">text</a> if possible. |
| 4589 | <a href="undocumented#Glyph">Glyph</a> values without direct <a href="undocumented#Unicode">Unicode</a> equivalents are mapped to zero. |
| 4590 | Uses the <a href="undocumented#Typeface">Typeface</a>, but is unaffected |
| 4591 | by <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a>; the <a href="SkPaint_Reference#text">text</a> values returned are equivalent to <a href="SkPaint_Reference#kUTF32_TextEncoding">kUTF32 TextEncoding</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4592 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4593 | Only supported on platforms that use <a href="undocumented#FreeType">FreeType</a> as the <a href="undocumented#Engine">Font Engine</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4594 | |
| 4595 | ### Parameters |
| 4596 | |
| 4597 | <table> <tr> <td><code><strong>glyphs </strong></code></td> <td> |
| 4598 | array of indices into font</td> |
| 4599 | </tr> <tr> <td><code><strong>count </strong></code></td> <td> |
| 4600 | length of glyph array</td> |
| 4601 | </tr> <tr> <td><code><strong>text </strong></code></td> <td> |
| 4602 | storage for character codes, one per glyph</td> |
| 4603 | </tr> |
| 4604 | </table> |
| 4605 | |
| 4606 | ### Example |
| 4607 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4608 | <div><fiddle-embed name="c12686b0b3e0a87d0a248bbfc57e9492"><div>Convert <a href="undocumented#UTF_8">UTF-8</a> <a href="SkPaint_Reference#text">text</a> to <a href="SkPaint_Reference#glyphs">glyphs</a>; then convert <a href="SkPaint_Reference#glyphs">glyphs</a> to <a href="undocumented#Unichar">Unichar</a> code points.</div></fiddle-embed></div> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4609 | |
| 4610 | --- |
| 4611 | |
| 4612 | # <a name="Measure_Text"></a> Measure Text |
| 4613 | |
| 4614 | <a name="measureText"></a> |
| 4615 | ## measureText |
| 4616 | |
| 4617 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4618 | SkScalar measureText(const void* text, size_t length, SkRect* bounds) const |
| 4619 | </pre> |
| 4620 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4621 | Returns the advance width of <a href="SkPaint_Reference#text">text</a> if <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> is clear, |
| 4622 | and the height of <a href="SkPaint_Reference#text">text</a> if <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> is set. |
| 4623 | The advance is the normal distance to move before drawing additional <a href="SkPaint_Reference#text">text</a>. |
| 4624 | Uses <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> to decode <a href="SkPaint_Reference#text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the font metrics, |
| 4625 | and <a href="SkPaint_Reference#Text_Size">Text Size</a>, <a href="SkPaint_Reference#Text_Scale_X">Text Scale X</a>, <a href="SkPaint_Reference#Text_Skew_X">Text Skew X</a>, <a href="SkPaint_Reference#Stroke_Width">Stroke Width</a>, and |
| 4626 | <a href="undocumented#Path_Effect">Path Effect</a> to scale the metrics and <a href="SkPaint_Reference#bounds">bounds</a>. |
| 4627 | Returns the bounding box of <a href="SkPaint_Reference#text">text</a> if <a href="SkPaint_Reference#bounds">bounds</a> is not nullptr. |
| 4628 | The bounding box is computed as if the <a href="SkPaint_Reference#text">text</a> was drawn at the origin. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4629 | |
| 4630 | ### Parameters |
| 4631 | |
| 4632 | <table> <tr> <td><code><strong>text </strong></code></td> <td> |
| 4633 | character codes or glyph indices to be measured</td> |
| 4634 | </tr> <tr> <td><code><strong>length </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4635 | number of bytes of <a href="SkPaint_Reference#text">text</a> to measure</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4636 | </tr> <tr> <td><code><strong>bounds </strong></code></td> <td> |
| 4637 | returns bounding box relative to (0, 0) if not nullptr</td> |
| 4638 | </tr> |
| 4639 | </table> |
| 4640 | |
| 4641 | ### Return Value |
| 4642 | |
| 4643 | advance width or height |
| 4644 | |
| 4645 | ### Example |
| 4646 | |
| 4647 | <div><fiddle-embed name="06084f609184470135a9cd9ebc5af149"></fiddle-embed></div> |
| 4648 | |
| 4649 | --- |
| 4650 | |
| 4651 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4652 | SkScalar measureText(const void* text, size_t length) const |
| 4653 | </pre> |
| 4654 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4655 | Returns the advance width of <a href="SkPaint_Reference#text">text</a> if <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> is clear, |
| 4656 | and the height of <a href="SkPaint_Reference#text">text</a> if <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> is set. |
| 4657 | The advance is the normal distance to move before drawing additional <a href="SkPaint_Reference#text">text</a>. |
| 4658 | Uses <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> to decode <a href="SkPaint_Reference#text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the font metrics, |
| 4659 | and <a href="SkPaint_Reference#Text_Size">Text Size</a> to scale the metrics. |
| 4660 | Does not scale the advance or bounds by <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a> or <a href="undocumented#Path_Effect">Path Effect</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4661 | |
| 4662 | ### Parameters |
| 4663 | |
| 4664 | <table> <tr> <td><code><strong>text </strong></code></td> <td> |
| 4665 | character codes or glyph indices to be measured</td> |
| 4666 | </tr> <tr> <td><code><strong>length </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4667 | number of bytes of <a href="SkPaint_Reference#text">text</a> to measure</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4668 | </tr> |
| 4669 | </table> |
| 4670 | |
| 4671 | ### Return Value |
| 4672 | |
| 4673 | advance width or height |
| 4674 | |
| 4675 | ### Example |
| 4676 | |
| 4677 | <div><fiddle-embed name="f1139a5ddd17fd47c2f45f6e642cac76"> |
| 4678 | |
| 4679 | #### Example Output |
| 4680 | |
| 4681 | ~~~~ |
| 4682 | default width = 5 |
| 4683 | double width = 10 |
| 4684 | ~~~~ |
| 4685 | |
| 4686 | </fiddle-embed></div> |
| 4687 | |
| 4688 | --- |
| 4689 | |
| 4690 | <a name="breakText"></a> |
| 4691 | ## breakText |
| 4692 | |
| 4693 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4694 | size_t breakText(const void* text, size_t length, SkScalar maxWidth, |
| 4695 | SkScalar* measuredWidth = NULL) const |
| 4696 | </pre> |
| 4697 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4698 | Returns the bytes of <a href="SkPaint_Reference#text">text</a> that fit within <a href="SkPaint_Reference#maxWidth">maxWidth</a>. |
| 4699 | If <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> is clear, the <a href="SkPaint_Reference#text">text</a> fragment fits if its advance width is less than or |
| 4700 | equal to <a href="SkPaint_Reference#maxWidth">maxWidth</a>. |
| 4701 | If <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> is set, the <a href="SkPaint_Reference#text">text</a> fragment fits if its advance height is less than or |
| 4702 | equal to <a href="SkPaint_Reference#maxWidth">maxWidth</a>. |
| 4703 | Measures only while the advance is less than or equal to <a href="SkPaint_Reference#maxWidth">maxWidth</a>. |
| 4704 | Returns the advance or the <a href="SkPaint_Reference#text">text</a> fragment in <a href="SkPaint_Reference#measuredWidth">measuredWidth</a> if it not nullptr. |
| 4705 | Uses <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> to decode <a href="SkPaint_Reference#text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the font metrics, |
| 4706 | and <a href="SkPaint_Reference#Text_Size">Text Size</a> to scale the metrics. |
| 4707 | Does not scale the advance or bounds by <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a> or <a href="undocumented#Path_Effect">Path Effect</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4708 | |
| 4709 | ### Parameters |
| 4710 | |
| 4711 | <table> <tr> <td><code><strong>text </strong></code></td> <td> |
| 4712 | character codes or glyph indices to be measured</td> |
| 4713 | </tr> <tr> <td><code><strong>length </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4714 | number of bytes of <a href="SkPaint_Reference#text">text</a> to measure</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4715 | </tr> <tr> <td><code><strong>maxWidth </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4716 | advance limit; <a href="SkPaint_Reference#text">text</a> is measured while advance is less than <a href="SkPaint_Reference#maxWidth">maxWidth</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4717 | </tr> <tr> <td><code><strong>measuredWidth </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4718 | returns the width of the <a href="SkPaint_Reference#text">text</a> less than or equal to <a href="SkPaint_Reference#maxWidth">maxWidth</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4719 | </tr> |
| 4720 | </table> |
| 4721 | |
| 4722 | ### Return Value |
| 4723 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4724 | bytes of <a href="SkPaint_Reference#text">text</a> that fit, always less than or equal to <a href="SkPaint_Reference#length">length</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4725 | |
| 4726 | ### Example |
| 4727 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4728 | <div><fiddle-embed name="fd0033470ccbd5c7059670fdbf96cffc"><div><a href="undocumented#Line">Line</a> under "" shows desired width, shorter than available characters. |
| 4729 | <a href="undocumented#Line">Line</a> under "" shows measured width after breaking <a href="SkPaint_Reference#text">text</a>.</div></fiddle-embed></div> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4730 | |
| 4731 | --- |
| 4732 | |
| 4733 | <a name="getTextWidths"></a> |
| 4734 | ## getTextWidths |
| 4735 | |
| 4736 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4737 | int getTextWidths(const void* text, size_t byteLength, SkScalar widths[], |
| 4738 | SkRect bounds[] = NULL) const |
| 4739 | </pre> |
| 4740 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4741 | Retrieves the advance and <a href="SkPaint_Reference#bounds">bounds</a> for each glyph in <a href="SkPaint_Reference#text">text</a>, and returns |
| 4742 | the glyph count in <a href="SkPaint_Reference#text">text</a>. |
| 4743 | Both <a href="SkPaint_Reference#widths">widths</a> and <a href="SkPaint_Reference#bounds">bounds</a> may be nullptr. |
| 4744 | If <a href="SkPaint_Reference#widths">widths</a> is not nullptr, <a href="SkPaint_Reference#widths">widths</a> must be an array of glyph count entries. |
| 4745 | if <a href="SkPaint_Reference#bounds">bounds</a> is not nullptr, <a href="SkPaint_Reference#bounds">bounds</a> must be an array of glyph count entries. |
| 4746 | If <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> is clear, <a href="SkPaint_Reference#widths">widths</a> returns the horizontal advance. |
| 4747 | If <a href="SkPaint_Reference#kVerticalText_Flag">kVerticalText Flag</a> is set, <a href="SkPaint_Reference#widths">widths</a> returns the vertical advance. |
| 4748 | Uses <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> to decode <a href="SkPaint_Reference#text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the font metrics, |
| 4749 | and <a href="SkPaint_Reference#Text_Size">Text Size</a> to scale the <a href="SkPaint_Reference#widths">widths</a> and <a href="SkPaint_Reference#bounds">bounds</a>. |
| 4750 | Does not scale the advance by <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a> or <a href="undocumented#Path_Effect">Path Effect</a>. |
| 4751 | Does include <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a> and <a href="undocumented#Path_Effect">Path Effect</a> in the <a href="SkPaint_Reference#bounds">bounds</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4752 | |
| 4753 | ### Parameters |
| 4754 | |
| 4755 | <table> <tr> <td><code><strong>text </strong></code></td> <td> |
| 4756 | character codes or glyph indices to be measured</td> |
| 4757 | </tr> <tr> <td><code><strong>byteLength </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4758 | number of bytes of <a href="SkPaint_Reference#text">text</a> to measure</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4759 | </tr> <tr> <td><code><strong>widths </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4760 | returns <a href="SkPaint_Reference#text">text</a> advances for each glyph; may be nullptr</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4761 | </tr> <tr> <td><code><strong>bounds </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4762 | returns <a href="SkPaint_Reference#bounds">bounds</a> for each glyph relative to (0, 0); may be nullptr</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4763 | </tr> |
| 4764 | </table> |
| 4765 | |
| 4766 | ### Return Value |
| 4767 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4768 | glyph count in <a href="SkPaint_Reference#text">text</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4769 | |
| 4770 | ### Example |
| 4771 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4772 | <div><fiddle-embed name="6b9e101f49e9c2c28755c5bdcef64dfb"><div>Bounds of glyphs increase for stroked <a href="SkPaint_Reference#text">text</a>, but <a href="SkPaint_Reference#text">text</a> advance remains the same. |
| 4773 | The underlines show the <a href="SkPaint_Reference#text">text</a> advance, spaced to keep them distinct.</div></fiddle-embed></div> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4774 | |
| 4775 | --- |
| 4776 | |
| 4777 | # <a name="Text_Path"></a> Text Path |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4778 | <a href="SkPaint_Reference#Text_Path">Text Path</a> describes the geometry of glyphs used to draw text. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4779 | |
| 4780 | <a name="getTextPath"></a> |
| 4781 | ## getTextPath |
| 4782 | |
| 4783 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4784 | void getTextPath(const void* text, size_t length, SkScalar x, SkScalar y, |
| 4785 | SkPath* path) const |
| 4786 | </pre> |
| 4787 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4788 | Returns the geometry as <a href="SkPath_Reference#Path">Path</a> equivalent to the drawn <a href="SkPaint_Reference#text">text</a>. |
| 4789 | Uses <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> to decode <a href="SkPaint_Reference#text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, |
| 4790 | and <a href="SkPaint_Reference#Text_Size">Text Size</a>, <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a>, and <a href="undocumented#Path_Effect">Path Effect</a> to scale and modify the glyph paths. |
| 4791 | All of the glyph paths are stored in <a href="SkPaint_Reference#path">path</a>. |
| 4792 | Uses <a href="SkPaint_Reference#x">x</a>, <a href="SkPaint_Reference#y">y</a>, and <a href="SkPaint_Reference#Text_Align">Text Align</a> to position <a href="SkPaint_Reference#path">path</a>. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4793 | |
| 4794 | ### Parameters |
| 4795 | |
| 4796 | <table> <tr> <td><code><strong>text </strong></code></td> <td> |
| 4797 | character codes or glyph indices</td> |
| 4798 | </tr> <tr> <td><code><strong>length </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4799 | number of bytes of <a href="SkPaint_Reference#text">text</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4800 | </tr> <tr> <td><code><strong>x </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4801 | x-coordinate of the origin of the <a href="SkPaint_Reference#text">text</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4802 | </tr> <tr> <td><code><strong>y </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4803 | y-coordinate of the origin of the <a href="SkPaint_Reference#text">text</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4804 | </tr> <tr> <td><code><strong>path </strong></code></td> <td> |
| 4805 | geometry of the glyphs</td> |
| 4806 | </tr> |
| 4807 | </table> |
| 4808 | |
| 4809 | ### Example |
| 4810 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4811 | <div><fiddle-embed name="7c9e6a399f898d68026c1f0865e6f73e"><div><a href="undocumented#Text">Text</a> is added to <a href="SkPath_Reference#Path">Path</a>, offset, and subtracted from <a href="SkPath_Reference#Path">Path</a>, then added at |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4812 | the offset location. The result is rendered with one draw call.</div></fiddle-embed></div> |
| 4813 | |
| 4814 | --- |
| 4815 | |
| 4816 | <a name="getPosTextPath"></a> |
| 4817 | ## getPosTextPath |
| 4818 | |
| 4819 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4820 | void getPosTextPath(const void* text, size_t length, const SkPoint pos[], |
| 4821 | SkPath* path) const |
| 4822 | </pre> |
| 4823 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4824 | Returns the geometry as <a href="SkPath_Reference#Path">Path</a> equivalent to the drawn <a href="SkPaint_Reference#text">text</a>. |
| 4825 | Uses <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> to decode <a href="SkPaint_Reference#text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, |
| 4826 | and <a href="SkPaint_Reference#Text_Size">Text Size</a>, <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a>, and <a href="undocumented#Path_Effect">Path Effect</a> to scale and modify the glyph paths. |
| 4827 | All of the glyph paths are stored in <a href="SkPaint_Reference#path">path</a>. |
| 4828 | Uses <a href="SkPaint_Reference#pos">pos</a> array and <a href="SkPaint_Reference#Text_Align">Text Align</a> to position <a href="SkPaint_Reference#path">path</a>. |
| 4829 | <a href="SkPaint_Reference#pos">pos</a> contains a position for each glyph. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4830 | |
| 4831 | ### Parameters |
| 4832 | |
| 4833 | <table> <tr> <td><code><strong>text </strong></code></td> <td> |
| 4834 | character codes or glyph indices</td> |
| 4835 | </tr> <tr> <td><code><strong>length </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4836 | number of bytes of <a href="SkPaint_Reference#text">text</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4837 | </tr> <tr> <td><code><strong>pos </strong></code></td> <td> |
| 4838 | positions of each glyph</td> |
| 4839 | </tr> <tr> <td><code><strong>path </strong></code></td> <td> |
| 4840 | geometry of the glyphs</td> |
| 4841 | </tr> |
| 4842 | </table> |
| 4843 | |
| 4844 | ### Example |
| 4845 | |
| 4846 | <div><fiddle-embed name="7f27c93472aa99a7542fb3493076f072"><div>Simplifies three glyphs to eliminate overlaps, and strokes the result.</div></fiddle-embed></div> |
| 4847 | |
| 4848 | --- |
| 4849 | |
| 4850 | # <a name="Text_Intercepts"></a> Text Intercepts |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4851 | <a href="SkPaint_Reference#Text_Intercepts">Text Intercepts</a> describe the intersection of drawn text glyphs with a pair |
| 4852 | of lines parallel to the text advance. <a href="SkPaint_Reference#Text_Intercepts">Text Intercepts</a> permits creating a |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4853 | underline that skips descenders. |
| 4854 | |
| 4855 | <a name="getTextIntercepts"></a> |
| 4856 | ## getTextIntercepts |
| 4857 | |
| 4858 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4859 | int getTextIntercepts(const void* text, size_t length, SkScalar x, SkScalar y, |
| 4860 | const SkScalar bounds[2], SkScalar* intervals) const |
| 4861 | </pre> |
| 4862 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4863 | Returns the number of <a href="SkPaint_Reference#intervals">intervals</a> that intersect <a href="SkPaint_Reference#bounds">bounds</a>. |
| 4864 | <a href="SkPaint_Reference#bounds">bounds</a> describes a pair of lines parallel to the <a href="SkPaint_Reference#text">text</a> advance. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4865 | The return count is zero or a multiple of two, and is at most twice the number of glyphs in |
| 4866 | the string. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4867 | Uses <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> to decode <a href="SkPaint_Reference#text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, |
| 4868 | and <a href="SkPaint_Reference#Text_Size">Text Size</a>, <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a>, and <a href="undocumented#Path_Effect">Path Effect</a> to scale and modify the glyph paths. |
| 4869 | Uses <a href="SkPaint_Reference#x">x</a>, <a href="SkPaint_Reference#y">y</a>, and <a href="SkPaint_Reference#Text_Align">Text Align</a> to position <a href="SkPaint_Reference#intervals">intervals</a>. |
| 4870 | Pass nullptr for <a href="SkPaint_Reference#intervals">intervals</a> to determine the size of the interval array. |
| 4871 | <a href="SkPaint_Reference#intervals">intervals</a> are cached to improve performance for multiple calls. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4872 | |
| 4873 | ### Parameters |
| 4874 | |
| 4875 | <table> <tr> <td><code><strong>text </strong></code></td> <td> |
| 4876 | character codes or glyph indices</td> |
| 4877 | </tr> <tr> <td><code><strong>length </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4878 | number of bytes of <a href="SkPaint_Reference#text">text</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4879 | </tr> <tr> <td><code><strong>x </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4880 | x-coordinate of the origin of the <a href="SkPaint_Reference#text">text</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4881 | </tr> <tr> <td><code><strong>y </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4882 | y-coordinate of the origin of the <a href="SkPaint_Reference#text">text</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4883 | </tr> <tr> <td><code><strong>bounds </strong></code></td> <td> |
| 4884 | lower and upper line parallel to the advance</td> |
| 4885 | </tr> <tr> <td><code><strong>intervals </strong></code></td> <td> |
| 4886 | returned intersections; may be nullptr</td> |
| 4887 | </tr> |
| 4888 | </table> |
| 4889 | |
| 4890 | ### Return Value |
| 4891 | |
| 4892 | number of intersections; may be zero |
| 4893 | |
| 4894 | ### Example |
| 4895 | |
| 4896 | <div><fiddle-embed name="2a0b80ed20d193c688085b79deb5bdc9"><div>Underline uses intercepts to draw on either side of the glyph descender.</div></fiddle-embed></div> |
| 4897 | |
| 4898 | --- |
| 4899 | |
| 4900 | <a name="getPosTextIntercepts"></a> |
| 4901 | ## getPosTextIntercepts |
| 4902 | |
| 4903 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4904 | int getPosTextIntercepts(const void* text, size_t length, const SkPoint pos[], |
| 4905 | const SkScalar bounds[2], SkScalar* intervals) const |
| 4906 | </pre> |
| 4907 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4908 | Returns the number of <a href="SkPaint_Reference#intervals">intervals</a> that intersect <a href="SkPaint_Reference#bounds">bounds</a>. |
| 4909 | <a href="SkPaint_Reference#bounds">bounds</a> describes a pair of lines parallel to the <a href="SkPaint_Reference#text">text</a> advance. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4910 | The return count is zero or a multiple of two, and is at most twice the number of glyphs in |
| 4911 | the string. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4912 | Uses <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> to decode <a href="SkPaint_Reference#text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, |
| 4913 | and <a href="SkPaint_Reference#Text_Size">Text Size</a>, <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a>, and <a href="undocumented#Path_Effect">Path Effect</a> to scale and modify the glyph paths. |
| 4914 | Uses <a href="SkPaint_Reference#pos">pos</a> array and <a href="SkPaint_Reference#Text_Align">Text Align</a> to position <a href="SkPaint_Reference#intervals">intervals</a>. |
| 4915 | Pass nullptr for <a href="SkPaint_Reference#intervals">intervals</a> to determine the size of the interval array. |
| 4916 | <a href="SkPaint_Reference#intervals">intervals</a> are cached to improve performance for multiple calls. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4917 | |
| 4918 | ### Parameters |
| 4919 | |
| 4920 | <table> <tr> <td><code><strong>text </strong></code></td> <td> |
| 4921 | character codes or glyph indices</td> |
| 4922 | </tr> <tr> <td><code><strong>length </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4923 | number of bytes of <a href="SkPaint_Reference#text">text</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4924 | </tr> <tr> <td><code><strong>pos </strong></code></td> <td> |
| 4925 | positions of each glyph</td> |
| 4926 | </tr> <tr> <td><code><strong>bounds </strong></code></td> <td> |
| 4927 | lower and upper line parallel to the advance</td> |
| 4928 | </tr> <tr> <td><code><strong>intervals </strong></code></td> <td> |
| 4929 | returned intersections; may be nullptr</td> |
| 4930 | </tr> |
| 4931 | </table> |
| 4932 | |
| 4933 | ### Return Value |
| 4934 | |
| 4935 | The number of intersections; may be zero |
| 4936 | |
| 4937 | ### Example |
| 4938 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4939 | <div><fiddle-embed name="98b2dfc552d0540a7c041fe7a2839bd7"><div><a href="undocumented#Text">Text</a> intercepts draw on either side of, but not inside, glyphs in a run.</div></fiddle-embed></div> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4940 | |
| 4941 | --- |
| 4942 | |
| 4943 | <a name="getPosTextHIntercepts"></a> |
| 4944 | ## getPosTextHIntercepts |
| 4945 | |
| 4946 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4947 | int getPosTextHIntercepts(const void* text, size_t length, const SkScalar xpos[], |
| 4948 | SkScalar constY, const SkScalar bounds[2], |
| 4949 | SkScalar* intervals) const |
| 4950 | </pre> |
| 4951 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4952 | Returns the number of <a href="SkPaint_Reference#intervals">intervals</a> that intersect <a href="SkPaint_Reference#bounds">bounds</a>. |
| 4953 | <a href="SkPaint_Reference#bounds">bounds</a> describes a pair of lines parallel to the <a href="SkPaint_Reference#text">text</a> advance. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4954 | The return count is zero or a multiple of two, and is at most twice the number of glyphs in |
| 4955 | the string. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4956 | Uses <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> to decode <a href="SkPaint_Reference#text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, |
| 4957 | and <a href="SkPaint_Reference#Text_Size">Text Size</a>, <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a>, and <a href="undocumented#Path_Effect">Path Effect</a> to scale and modify the glyph paths. |
| 4958 | Uses <a href="SkPaint_Reference#xpos">xpos</a> array, <a href="SkPaint_Reference#constY">constY</a>, and <a href="SkPaint_Reference#Text_Align">Text Align</a> to position <a href="SkPaint_Reference#intervals">intervals</a>. |
| 4959 | Pass nullptr for <a href="SkPaint_Reference#intervals">intervals</a> to determine the size of the interval array. |
| 4960 | <a href="SkPaint_Reference#intervals">intervals</a> are cached to improve performance for multiple calls. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4961 | |
| 4962 | ### Parameters |
| 4963 | |
| 4964 | <table> <tr> <td><code><strong>text </strong></code></td> <td> |
| 4965 | character codes or glyph indices</td> |
| 4966 | </tr> <tr> <td><code><strong>length </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4967 | number of bytes of <a href="SkPaint_Reference#text">text</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4968 | </tr> <tr> <td><code><strong>xpos </strong></code></td> <td> |
| 4969 | positions of each glyph in x</td> |
| 4970 | </tr> <tr> <td><code><strong>constY </strong></code></td> <td> |
| 4971 | position of each glyph in y</td> |
| 4972 | </tr> <tr> <td><code><strong>bounds </strong></code></td> <td> |
| 4973 | lower and upper line parallel to the advance</td> |
| 4974 | </tr> <tr> <td><code><strong>intervals </strong></code></td> <td> |
| 4975 | returned intersections; may be nullptr</td> |
| 4976 | </tr> |
| 4977 | </table> |
| 4978 | |
| 4979 | ### Return Value |
| 4980 | |
| 4981 | number of intersections; may be zero |
| 4982 | |
| 4983 | ### Example |
| 4984 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4985 | <div><fiddle-embed name="dc9851c43acc3716aca8c9a4d40d452d"><div><a href="undocumented#Text">Text</a> intercepts do not take stroke thickness into consideration.</div></fiddle-embed></div> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4986 | |
| 4987 | --- |
| 4988 | |
| 4989 | <a name="getTextBlobIntercepts"></a> |
| 4990 | ## getTextBlobIntercepts |
| 4991 | |
| 4992 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 4993 | int getTextBlobIntercepts(const SkTextBlob* blob, const SkScalar bounds[2], |
| 4994 | SkScalar* intervals) const |
| 4995 | </pre> |
| 4996 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 4997 | Returns the number of <a href="SkPaint_Reference#intervals">intervals</a> that intersect <a href="SkPaint_Reference#bounds">bounds</a>. |
| 4998 | <a href="SkPaint_Reference#bounds">bounds</a> describes a pair of lines parallel to the text advance. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 4999 | The return count is zero or a multiple of two, and is at most twice the number of glyphs in |
| 5000 | the string. |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5001 | Uses <a href="SkPaint_Reference#Text_Encoding">Text Encoding</a> to decode text, <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, |
| 5002 | and <a href="SkPaint_Reference#Text_Size">Text Size</a>, <a href="SkPaint_Reference#Fake_Bold">Fake Bold</a>, and <a href="undocumented#Path_Effect">Path Effect</a> to scale and modify the glyph paths. |
| 5003 | Uses pos array and <a href="SkPaint_Reference#Text_Align">Text Align</a> to position <a href="SkPaint_Reference#intervals">intervals</a>. |
| 5004 | Pass nullptr for <a href="SkPaint_Reference#intervals">intervals</a> to determine the size of the interval array. |
| 5005 | <a href="SkPaint_Reference#intervals">intervals</a> are cached to improve performance for multiple calls. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5006 | |
| 5007 | ### Parameters |
| 5008 | |
| 5009 | <table> <tr> <td><code><strong>blob </strong></code></td> <td> |
| 5010 | glyphs, positions, and text paint attributes</td> |
| 5011 | </tr> <tr> <td><code><strong>bounds </strong></code></td> <td> |
| 5012 | lower and upper line parallel to the advance</td> |
| 5013 | </tr> <tr> <td><code><strong>intervals </strong></code></td> <td> |
| 5014 | returned intersections; may be nullptr</td> |
| 5015 | </tr> |
| 5016 | </table> |
| 5017 | |
| 5018 | ### Return Value |
| 5019 | |
| 5020 | number of intersections; may be zero |
| 5021 | |
| 5022 | ### Example |
| 5023 | |
| 5024 | <div><fiddle-embed name="4961b05f4f26cf270ab4948a57876341"></fiddle-embed></div> |
| 5025 | |
| 5026 | --- |
| 5027 | |
| 5028 | <a name="nothingToDraw"></a> |
| 5029 | ## nothingToDraw |
| 5030 | |
| 5031 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 5032 | bool nothingToDraw() const |
| 5033 | </pre> |
| 5034 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5035 | Returns true if <a href="SkPaint_Reference#Paint">Paint</a> prevents all drawing; |
| 5036 | otherwise, the <a href="SkPaint_Reference#Paint">Paint</a> may or may not allow drawing. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5037 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5038 | Returns true if <a href="undocumented#Blend_Mode">Blend Mode</a> and <a href="undocumented#Alpha">Color Alpha</a> are enabled, |
| 5039 | and computed <a href="undocumented#Alpha">Color Alpha</a> is zero. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5040 | |
| 5041 | ### Return Value |
| 5042 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5043 | true if <a href="SkPaint_Reference#Paint">Paint</a> prevents all drawing |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5044 | |
| 5045 | ### Example |
| 5046 | |
| 5047 | <div><fiddle-embed name="fc5a771b915ac341f56554f01d282831"> |
| 5048 | |
| 5049 | #### Example Output |
| 5050 | |
| 5051 | ~~~~ |
| 5052 | initial nothing to draw: false |
| 5053 | blend dst nothing to draw: true |
| 5054 | blend src over nothing to draw: false |
| 5055 | alpha 0 nothing to draw: true |
| 5056 | ~~~~ |
| 5057 | |
| 5058 | </fiddle-embed></div> |
| 5059 | |
| 5060 | --- |
| 5061 | |
| 5062 | # <a name="Fast_Bounds"></a> Fast Bounds |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5063 | <a href="SkPaint_Reference#Fast_Bounds">Fast Bounds</a> methods conservatively outset a drawing bounds by additional area |
| 5064 | <a href="SkPaint_Reference#Paint">Paint</a> may draw to. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5065 | |
| 5066 | <a name="canComputeFastBounds"></a> |
| 5067 | ## canComputeFastBounds |
| 5068 | |
| 5069 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 5070 | bool canComputeFastBounds() const |
| 5071 | </pre> |
| 5072 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5073 | Returns true if <a href="SkPaint_Reference#Paint">Paint</a> does not include elements requiring extensive computation |
| 5074 | to compute <a href="undocumented#Device">Device</a> bounds of drawn geometry. For instance, <a href="SkPaint_Reference#Paint">Paint</a> with <a href="undocumented#Path_Effect">Path Effect</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5075 | always returns false. |
| 5076 | |
| 5077 | ### Return Value |
| 5078 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5079 | true if <a href="SkPaint_Reference#Paint">Paint</a> allows for fast computation of bounds |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5080 | |
| 5081 | --- |
| 5082 | |
| 5083 | <a name="computeFastBounds"></a> |
| 5084 | ## computeFastBounds |
| 5085 | |
| 5086 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 5087 | const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const |
| 5088 | </pre> |
| 5089 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5090 | Only call this if <a href="SkPaint_Reference#canComputeFastBounds">canComputeFastBounds</a> returned true. This takes a |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5091 | raw rectangle (the raw bounds of a shape), and adjusts it for stylistic |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5092 | effects in the paint (e.g. stroking). If needed, it uses the <a href="SkPaint_Reference#storage">storage</a> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5093 | rect parameter. It returns the adjusted bounds that can then be used |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5094 | for <a href="SkCanvas_Reference#quickReject">SkCanvas::quickReject</a> tests. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5095 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5096 | The returned rect will either be <a href="SkPaint_Reference#orig">orig</a> or <a href="SkPaint_Reference#storage">storage</a>, thus the caller |
| 5097 | should not rely on <a href="SkPaint_Reference#storage">storage</a> being set to the result, but should always |
| 5098 | use the retured value. It is legal for <a href="SkPaint_Reference#orig">orig</a> and <a href="SkPaint_Reference#storage">storage</a> to be the same |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5099 | rect. |
| 5100 | |
| 5101 | ### Parameters |
| 5102 | |
| 5103 | <table> <tr> <td><code><strong>orig </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5104 | geometry modified by <a href="SkPaint_Reference#Paint">Paint</a> when drawn</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5105 | </tr> <tr> <td><code><strong>storage </strong></code></td> <td> |
| 5106 | computed bounds of geometry; may not be nullptr</td> |
| 5107 | </tr> |
| 5108 | </table> |
| 5109 | |
| 5110 | ### Return Value |
| 5111 | |
| 5112 | fast computed bounds |
| 5113 | |
| 5114 | --- |
| 5115 | |
| 5116 | <a name="computeFastStrokeBounds"></a> |
| 5117 | ## computeFastStrokeBounds |
| 5118 | |
| 5119 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 5120 | const SkRect& computeFastStrokeBounds(const SkRect& orig, SkRect* storage) const |
| 5121 | </pre> |
| 5122 | |
| 5123 | ### Parameters |
| 5124 | |
| 5125 | <table> <tr> <td><code><strong>orig </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5126 | geometry modified by <a href="SkPaint_Reference#Paint">Paint</a> when drawn</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5127 | </tr> <tr> <td><code><strong>storage </strong></code></td> <td> |
| 5128 | computed bounds of geometry</td> |
| 5129 | </tr> |
| 5130 | </table> |
| 5131 | |
| 5132 | ### Return Value |
| 5133 | |
| 5134 | fast computed bounds |
| 5135 | |
| 5136 | --- |
| 5137 | |
| 5138 | <a name="doComputeFastBounds"></a> |
| 5139 | ## doComputeFastBounds |
| 5140 | |
| 5141 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 5142 | const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage, |
| 5143 | Style style) const |
| 5144 | </pre> |
| 5145 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5146 | Take the <a href="SkPaint_Reference#style">style</a> explicitly, so the caller can force us to be stroked |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5147 | without having to make a copy of the paint just to change that field. |
| 5148 | |
| 5149 | ### Parameters |
| 5150 | |
| 5151 | <table> <tr> <td><code><strong>orig </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5152 | geometry modified by <a href="SkPaint_Reference#Paint">Paint</a> when drawn</td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5153 | </tr> <tr> <td><code><strong>storage </strong></code></td> <td> |
| 5154 | computed bounds of geometry</td> |
| 5155 | </tr> <tr> <td><code><strong>style </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5156 | overrides <a href="SkPaint_Reference#Style">Style</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5157 | </tr> |
| 5158 | </table> |
| 5159 | |
| 5160 | ### Return Value |
| 5161 | |
| 5162 | fast computed bounds |
| 5163 | |
| 5164 | --- |
| 5165 | |
| 5166 | <a name="toString"></a> |
| 5167 | ## toString |
| 5168 | |
| 5169 | <pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> |
| 5170 | void toString(SkString* str) const; |
| 5171 | </pre> |
| 5172 | |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5173 | Converts <a href="SkPaint_Reference#Paint">Paint</a> to machine parsable form in developer mode. |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5174 | |
| 5175 | ### Parameters |
| 5176 | |
| 5177 | <table> <tr> <td><code><strong>str </strong></code></td> <td> |
Cary Clark | 4c06f5e | 2017-08-04 12:48:24 -0400 | [diff] [blame^] | 5178 | storage for string containing parsable <a href="SkPaint_Reference#Paint">Paint</a></td> |
Cary Clark | 12799e1 | 2017-07-28 15:18:29 -0400 | [diff] [blame] | 5179 | </tr> |
| 5180 | </table> |
| 5181 | |
| 5182 | ### Example |
| 5183 | |
| 5184 | <div><fiddle-embed name="5670c04b4562908169a776c48c92d104"> |
| 5185 | |
| 5186 | #### Example Output |
| 5187 | |
| 5188 | ~~~~ |
| 5189 | text size = 12 |
| 5190 | ~~~~ |
| 5191 | |
| 5192 | </fiddle-embed></div> |
| 5193 | |
| 5194 | --- |
| 5195 | |