Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1 | #Topic RRect |
| 2 | #Alias Round_Rect ## |
| 3 | #Alias RRect_Reference ## |
| 4 | |
| 5 | #Class SkRRect |
| 6 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 7 | #Code |
| 8 | class SkRRect { |
| 9 | public: |
| 10 | SkRRect() = default; |
| 11 | SkRRect(const SkRRect& rrect) = default; |
| 12 | SkRRect& operator=(const SkRRect& rrect) = default; |
| 13 | |
| 14 | enum Type { |
| 15 | kEmpty_Type, |
| 16 | kRect_Type, |
| 17 | kOval_Type, |
| 18 | kSimple_Type, |
| 19 | kNinePatch_Type, |
| 20 | kComplex_Type, |
| 21 | kLastType = kComplex_Type, |
| 22 | }; |
| 23 | |
| 24 | Type getType() const; |
| 25 | Type type() const; |
| 26 | bool isEmpty() const; |
| 27 | bool isRect() const; |
| 28 | bool isOval() const; |
| 29 | bool isSimple() const; |
| 30 | bool isNinePatch() const; |
| 31 | bool isComplex() const; |
| 32 | SkScalar width() const; |
| 33 | SkScalar height() const; |
| 34 | SkVector getSimpleRadii() const; |
| 35 | void setEmpty(); |
| 36 | void setRect(const SkRect& rect); |
| 37 | static SkRRect MakeEmpty(); |
| 38 | static SkRRect MakeRect(const SkRect& r); |
| 39 | static SkRRect MakeOval(const SkRect& oval); |
| 40 | static SkRRect MakeRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad); |
| 41 | void setOval(const SkRect& oval); |
| 42 | void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad); |
| 43 | void setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad, |
| 44 | SkScalar rightRad, SkScalar bottomRad); |
| 45 | void setRectRadii(const SkRect& rect, const SkVector radii[4]); |
| 46 | |
| 47 | enum Corner { |
| 48 | kUpperLeft_Corner, |
| 49 | kUpperRight_Corner, |
| 50 | kLowerRight_Corner, |
| 51 | kLowerLeft_Corner, |
| 52 | }; |
| 53 | |
| 54 | const SkRect& rect() const; |
| 55 | SkVector radii(Corner corner) const; |
| 56 | const SkRect& getBounds() const; |
| 57 | friend bool operator==(const SkRRect& a, const SkRRect& b); |
| 58 | friend bool operator!=(const SkRRect& a, const SkRRect& b); |
| 59 | void inset(SkScalar dx, SkScalar dy, SkRRect* dst) const; |
| 60 | void inset(SkScalar dx, SkScalar dy); |
| 61 | void outset(SkScalar dx, SkScalar dy, SkRRect* dst) const; |
| 62 | void outset(SkScalar dx, SkScalar dy); |
| 63 | void offset(SkScalar dx, SkScalar dy); |
| 64 | SkRRect makeOffset(SkScalar dx, SkScalar dy) const; |
| 65 | bool contains(const SkRect& rect) const; |
| 66 | bool isValid() const; |
| 67 | |
| 68 | static constexpr size_t kSizeInMemory = 12 * sizeof(SkScalar); |
| 69 | |
| 70 | size_t writeToMemory(void* buffer) const; |
| 71 | size_t readFromMemory(const void* buffer, size_t length); |
| 72 | bool transform(const SkMatrix& matrix, SkRRect* dst) const; |
| 73 | void dump(bool asHex) const; |
| 74 | void dump() const; |
| 75 | void dumpHex() const; |
| 76 | }; |
| 77 | ## |
| 78 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 79 | SkRRect describes a rounded rectangle with a bounds and a pair of radii for each corner. |
Cary Clark | f960398 | 2018-07-17 08:20:27 -0400 | [diff] [blame] | 80 | The bounds and radii can be set so that SkRRect describes: a rectangle with sharp corners; |
| 81 | a Circle; an Oval; or a rectangle with one or more rounded corners. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 82 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 83 | SkRRect allows implementing CSS properties that describe rounded corners. |
| 84 | SkRRect may have up to eight different radii, one for each axis on each of its four |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 85 | corners. |
| 86 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 87 | SkRRect may modify the provided parameters when initializing bounds and radii. |
Cary Clark | f960398 | 2018-07-17 08:20:27 -0400 | [diff] [blame] | 88 | If either axis radii is zero or less: radii are stored as zero; corner is square. |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 89 | If corner curves overlap, radii are proportionally reduced to fit within bounds. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 90 | |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 91 | # ------------------------------------------------------------------------------ |
| 92 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 93 | #Method SkRRect() |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 94 | #In Constructors |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 95 | #Line # creates with zeroed bounds and corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 96 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 97 | Initializes bounds at (0, 0), the origin, with zero width and height. |
| 98 | Initializes corner radii to (0, 0), and sets type of kEmpty_Type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 99 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 100 | #Return empty Round_Rect ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 101 | |
| 102 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 103 | #Height 60 |
| 104 | SkRRect rrect;
|
| 105 | SkPaint p;
|
| 106 | p.setStyle(SkPaint::kStroke_Style);
|
| 107 | p.setStrokeWidth(10);
|
| 108 | canvas->drawRRect(rrect, p);
|
| 109 | rrect.setRect({10, 10, 100, 50});
|
| 110 | canvas->drawRRect(rrect, p);
|
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 111 | ## |
| 112 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 113 | #SeeAlso setEmpty isEmpty |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 114 | |
| 115 | #Method ## |
| 116 | |
| 117 | # ------------------------------------------------------------------------------ |
| 118 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 119 | #Method SkRRect(const SkRRect& rrect) |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 120 | #In Constructors |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 121 | #Line # copies bounds and corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 122 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 123 | Initializes to copy of rrect bounds and corner radii. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 124 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 125 | #Param rrect bounds and corner to copy ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 126 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 127 | #Return copy of rrect ## |
| 128 | |
| 129 | #Bug 8115 |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 130 | #Example |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 131 | #Height 60 |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 132 | SkRRect rrect = SkRRect::MakeRect({10, 10, 100, 50});
|
| 133 | SkRRect rrect2(rrect);
|
| 134 | rrect2.inset(20, 20);
|
| 135 | SkPaint p;
|
| 136 | p.setStyle(SkPaint::kStroke_Style);
|
| 137 | p.setStrokeWidth(10);
|
| 138 | canvas->drawRRect(rrect, p);
|
| 139 | canvas->drawRRect(rrect2, p);
|
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 140 | ## |
| 141 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 142 | #SeeAlso operator=(const SkRRect& rrect) MakeRect |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 143 | |
| 144 | #Method ## |
| 145 | |
| 146 | # ------------------------------------------------------------------------------ |
| 147 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 148 | #Method SkRRect& operator=(const SkRRect& rrect) |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 149 | #In Operators |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 150 | #Line # copies bounds and corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 151 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 152 | Copies rrect bounds and corner radii. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 153 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 154 | #Param rrect bounds and corner to copy ## |
| 155 | |
| 156 | #Return copy of rrect ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 157 | |
| 158 | #Example |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 159 | #Height 110 |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 160 | SkRRect rrect = SkRRect::MakeRect({40, 40, 100, 70});
|
| 161 | SkRRect rrect2 = rrect;
|
| 162 | rrect2.inset(-20, -20);
|
| 163 | SkPaint p;
|
| 164 | p.setStyle(SkPaint::kStroke_Style);
|
| 165 | p.setStrokeWidth(10);
|
| 166 | canvas->drawRRect(rrect, p);
|
| 167 | canvas->drawRRect(rrect2, p); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 168 | ## |
| 169 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 170 | #SeeAlso SkRRect(const SkRRect& rrect) MakeRect |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 171 | |
| 172 | #Method ## |
| 173 | |
| 174 | # ------------------------------------------------------------------------------ |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 175 | #Subtopic Type |
| 176 | #Line # specialization of Round_Rect geometry ## |
| 177 | |
| 178 | #PhraseDef list_of_rrect_types |
| 179 | kEmpty_Type, kRect_Type, kOval_Type, kSimple_Type, kNinePatch_Type, |
| 180 | kComplex_Type |
| 181 | ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 182 | |
| 183 | #Enum Type |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 184 | #Line # specialization of Round_Rect geometry ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 185 | |
| 186 | #Code |
| 187 | enum Type { |
| 188 | kEmpty_Type, |
| 189 | kRect_Type, |
| 190 | kOval_Type, |
| 191 | kSimple_Type, |
| 192 | kNinePatch_Type, |
| 193 | kComplex_Type, |
| 194 | kLastType = kComplex_Type, |
| 195 | }; |
| 196 | ## |
| 197 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 198 | Type describes possible specializations of Round_Rect. Each Type is |
| 199 | exclusive; a Round_Rect may only have one type. |
| 200 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 201 | Type members become progressively less restrictive; larger values of |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 202 | Type have more degrees of freedom than smaller values. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 203 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 204 | #Const kEmpty_Type 0 |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 205 | #Line # zero width or height ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 206 | Round_Rect has zero width or height. All radii are zero. |
| 207 | ## |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 208 | #Const kRect_Type 1 |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 209 | #Line # non-zero width and height, and zeroed radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 210 | Round_Rect has width and height. All radii are zero. |
| 211 | ## |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 212 | #Const kOval_Type 2 |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 213 | #Line # non-zero width and height filled with radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 214 | Round_Rect has width and height. All four x-radii are equal, |
| 215 | and at least half the width. All four y-radii are equal, |
| 216 | and at least half the height. |
| 217 | ## |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 218 | #Const kSimple_Type 3 |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 219 | #Line # non-zero width and height with equal radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 220 | Round_Rect has width and height. All four x-radii are equal and |
| 221 | greater than zero, and all four y-radii are equal and greater than |
| 222 | zero. Either x-radii are less than half the width, or y-radii is |
| 223 | less than half the height, or both. |
| 224 | ## |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 225 | #Const kNinePatch_Type 4 |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 226 | #Line # non-zero width and height with axis-aligned radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 227 | Round_Rect has width and height. Left x-radii are equal, top |
| 228 | y-radii are equal, right x-radii are equal, and bottom y-radii |
Cary Clark | f960398 | 2018-07-17 08:20:27 -0400 | [diff] [blame] | 229 | are equal. The radii do not describe Rect, Oval, or simple type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 230 | |
| 231 | The centers of the corner ellipses form an axis-aligned rectangle |
| 232 | that divides the Round_Rect into nine rectangular patches; an |
| 233 | interior rectangle, four edges, and four corners. |
| 234 | ## |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 235 | #Const kComplex_Type 5 |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 236 | #Line # non-zero width and height with arbitrary radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 237 | both radii are non-zero. |
| 238 | ## |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 239 | #Const kLastType 5 |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 240 | #Line # largest Type value ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 241 | ## |
| 242 | |
| 243 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 244 | #Height 128 |
| 245 | struct Radii { SkVector data[4]; };
|
| 246 | auto drawRRectType = [=](const SkRect& rect, const Radii& radii) {
|
| 247 | SkRRect rrect;
|
| 248 | rrect.setRectRadii(rect, radii.data);
|
| 249 | SkPaint paint;
|
| 250 | paint.setAntiAlias(true);
|
| 251 | const char* typeStr[] = { "empty", "rect", "oval", "simple", "nine patch", "complex" };
|
| 252 | paint.setTextAlign(SkPaint::kCenter_Align);
|
| 253 | canvas->drawString(typeStr[(int) rrect.type()], rect.centerX(), rect.bottom() + 20, paint);
|
| 254 | paint.setStyle(SkPaint::kStroke_Style);
|
| 255 | canvas->drawRRect(rrect, paint);
|
| 256 | };
|
| 257 | drawRRectType({ 45, 30, 45, 30}, {{{ 5, 5}, { 5, 5}, { 5, 5}, { 5, 5}}});
|
| 258 | drawRRectType({ 90, 10, 140, 30}, {{{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}}});
|
| 259 | drawRRectType({160, 10, 210, 30}, {{{25, 10}, {25, 10}, {25, 10}, {25, 10}}});
|
| 260 | drawRRectType({ 20, 80, 70, 100}, {{{ 5, 5}, { 5, 5}, { 5, 5}, { 5, 5}}});
|
| 261 | drawRRectType({ 90, 80, 140, 100}, {{{ 5, 5}, {10, 5}, {10, 5}, { 5, 5}}});
|
| 262 | drawRRectType({160, 80, 210, 100}, {{{ 5, 5}, {10, 5}, { 5, 5}, { 5, 5}}}); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 263 | ## |
| 264 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 265 | #SeeAlso Rect Path |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 266 | |
| 267 | #Enum ## |
| 268 | |
| 269 | # ------------------------------------------------------------------------------ |
| 270 | |
| 271 | #Method Type getType() const |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 272 | #In Property |
| 273 | #Line # returns Type ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 274 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 275 | Returns Type, one of: #list_of_rrect_types#. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 276 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 277 | #Return Type ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 278 | |
| 279 | #Example |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 280 | #Height 100 |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 281 | #Description |
| 282 | rrect2 is not a Rect; inset() has made it empty. |
| 283 | ## |
| 284 | SkRRect rrect = SkRRect::MakeRect({10, 10, 100, 50});
|
| 285 | SkRRect rrect2(rrect);
|
| 286 | rrect2.inset(20, 20);
|
| 287 | SkPaint p;
|
| 288 | p.setStyle(SkPaint::kStroke_Style);
|
| 289 | p.setStrokeWidth(10);
|
| 290 | std::string str("Type ");
|
| 291 | str += SkRRect::kRect_Type == rrect2.getType() ? "=" : "!";
|
| 292 | str += "= SkRRect::kRect_Type";
|
| 293 | canvas->drawString(str.c_str(), 20, 80, SkPaint());
|
| 294 | canvas->drawRRect(rrect2, p); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 295 | ## |
| 296 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 297 | #SeeAlso Type type |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 298 | |
| 299 | #Method ## |
| 300 | |
| 301 | # ------------------------------------------------------------------------------ |
| 302 | |
| 303 | #Method Type type() const |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 304 | #In Property |
| 305 | #Line # returns Type ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 306 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 307 | Returns Type, one of: #list_of_rrect_types#. |
| 308 | |
| 309 | #Return Type ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 310 | |
| 311 | #Example |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 312 | #Height 100 |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 313 | #Description |
| 314 | inset() has made rrect2 empty. |
| 315 | ## |
| 316 | SkRRect rrect = SkRRect::MakeRect({10, 10, 100, 50});
|
| 317 | SkRRect rrect2(rrect);
|
| 318 | rrect2.inset(20, 20);
|
| 319 | SkPaint p;
|
| 320 | p.setStyle(SkPaint::kStroke_Style);
|
| 321 | p.setStrokeWidth(10);
|
| 322 | std::string str("Type ");
|
| 323 | str += SkRRect::kEmpty_Type == rrect2.type() ? "=" : "!";
|
| 324 | str += "= SkRRect::kEmpty_Type";
|
| 325 | canvas->drawString(str.c_str(), 20, 80, SkPaint());
|
| 326 | canvas->drawRRect(rrect2, p); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 327 | ## |
| 328 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 329 | #SeeAlso Type getType |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 330 | |
| 331 | #Method ## |
| 332 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 333 | #Subtopic Type ## |
| 334 | |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 335 | # ------------------------------------------------------------------------------ |
| 336 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 337 | #Method bool isEmpty() const |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 338 | #In Property |
| 339 | #Line # returns true if width or height are zero ## |
| 340 | Returns true if rect().fLeft is equal to rect().fRight, or if rect().fTop is equal |
| 341 | to rect().fBottom. |
| 342 | |
| 343 | #Return true if width() or height() are zero ## |
| 344 | |
| 345 | #Example |
| 346 | #Height 100 |
| 347 | SkPaint paint;
|
| 348 | paint.setAntiAlias(true);
|
| 349 | paint.setTextAlign(SkPaint::kCenter_Align);
|
| 350 | paint.setTextSize(16);
|
| 351 | SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 10, 5);
|
| 352 | canvas->drawRRect(rrect, paint);
|
| 353 | canvas->drawString(rrect.isEmpty() ? "empty" : "not empty", 64, 90, paint);
|
| 354 | rrect.inset(40, 0);
|
| 355 | canvas->translate(128, 0);
|
| 356 | canvas->drawRRect(rrect, paint);
|
| 357 | canvas->drawString(rrect.isEmpty() ? "empty" : "not empty", 64, 90, paint); |
| 358 | ## |
| 359 | |
| 360 | #SeeAlso SkRect::isEmpty height width |
| 361 | |
| 362 | #Method ## |
| 363 | |
| 364 | # ------------------------------------------------------------------------------ |
| 365 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 366 | #Method bool isRect() const |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 367 | #In Property |
| 368 | #Line # returns true if not empty, and one radius at each corner is zero ## |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 369 | Returns true if not empty, and if either x-axis or y-axis radius at each corner |
| 370 | is zero. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 371 | |
| 372 | #Return true if not empty, and one radius at each corner is zero ## |
| 373 | |
| 374 | #Example |
| 375 | #Height 100 |
| 376 | SkPaint paint;
|
| 377 | paint.setAntiAlias(true);
|
| 378 | paint.setTextAlign(SkPaint::kCenter_Align);
|
| 379 | paint.setTextSize(16);
|
| 380 | SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
|
| 381 | canvas->drawRRect(rrect, paint);
|
| 382 | canvas->drawString(rrect.isRect() ? "rect" : "not rect", 64, 90, paint);
|
| 383 | SkVector radii[] = {{10, 10}, {0, 0}, {0, 0}, {0, 0}};
|
| 384 | rrect.setRectRadii(rrect.getBounds(), radii);
|
| 385 | canvas->translate(128, 0);
|
| 386 | canvas->drawRRect(rrect, paint);
|
| 387 | canvas->drawString(rrect.isRect() ? "rect" : "not rect", 64, 90, paint); |
| 388 | ## |
| 389 | |
| 390 | #SeeAlso isEmpty radii |
| 391 | |
| 392 | #Method ## |
| 393 | |
| 394 | # ------------------------------------------------------------------------------ |
| 395 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 396 | #Method bool isOval() const |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 397 | #In Property |
| 398 | #Line # returns true if not empty, axes radii are equal, radii fill bounds ## |
| 399 | Returns true if not empty, if all x-axis radii are equal, if all y-axis radii |
| 400 | are equal, x-axis radii are at least half the width, and y-axis radii are at |
| 401 | least half the height. |
| 402 | |
| 403 | #Return true if has identical geometry to Oval ## |
| 404 | |
| 405 | #Example |
| 406 | #Height 100 |
| 407 | #Description |
| 408 | The first radii are scaled down proportionately until both x-axis and y-axis fit |
| 409 | within the bounds. After scaling, x-axis radius is smaller than half the width; |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 410 | left Round_Rect is not an oval. The second radii are equal to half the |
| 411 | dimensions; right Round_Rect is an oval. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 412 | ## |
| 413 | SkPaint paint;
|
| 414 | paint.setAntiAlias(true);
|
| 415 | paint.setTextAlign(SkPaint::kCenter_Align);
|
| 416 | paint.setTextSize(16);
|
| 417 | SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 40, 30);
|
| 418 | canvas->drawRRect(rrect, paint);
|
| 419 | canvas->drawString(rrect.isOval() ? "oval" : "not oval", 64, 90, paint);
|
| 420 | rrect.setRectXY(rrect.getBounds(), 35, 25);
|
| 421 | canvas->translate(128, 0);
|
| 422 | canvas->drawRRect(rrect, paint);
|
| 423 | canvas->drawString(rrect.isOval() ? "oval" : "not oval", 64, 90, paint); |
| 424 | ## |
| 425 | |
| 426 | #SeeAlso isEmpty isSimple SkCanvas::drawOval |
| 427 | |
| 428 | #Method ## |
| 429 | |
| 430 | # ------------------------------------------------------------------------------ |
| 431 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 432 | #Method bool isSimple() const |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 433 | #In Property |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 434 | #Line # returns true if not empty, Rect or Oval; and axes radii are equal ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 435 | Returns true if not empty, if all x-axis radii are equal but not zero, |
| 436 | if all y-axis radii are equal but not zero; and x-axis radius is less than half |
| 437 | width(), or y-axis radius is less than half height(). |
| 438 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 439 | #Return true if not empty, Rect or Oval; and axes radii are equal ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 440 | |
| 441 | #Bug 8107 |
| 442 | #Example |
| 443 | #Height 100 |
| 444 | SkPaint paint;
|
| 445 | paint.setAntiAlias(true);
|
| 446 | paint.setTextAlign(SkPaint::kCenter_Align);
|
| 447 | paint.setTextSize(16);
|
| 448 | SkVector radii[] = {{40, 30}, {40, 30}, {40, 30}, {40, 30}};
|
| 449 | SkRRect rrect;
|
| 450 | rrect.setRectRadii({30, 10, 100, 60}, radii);
|
| 451 | canvas->drawRRect(rrect, paint);
|
| 452 | canvas->drawString(rrect.isSimple() ? "simple" : "not simple", 64, 90, paint);
|
| 453 | radii[0].fX = 35;
|
| 454 | rrect.setRectRadii(rrect.getBounds(), radii);
|
| 455 | canvas->translate(128, 0);
|
| 456 | canvas->drawRRect(rrect, paint);
|
| 457 | canvas->drawString(rrect.isSimple() ? "simple" : "not simple", 64, 90, paint); |
| 458 | ## |
| 459 | |
| 460 | #SeeAlso isEmpty isRect isOval isNinePatch |
| 461 | |
| 462 | #Method ## |
| 463 | |
| 464 | # ------------------------------------------------------------------------------ |
| 465 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 466 | #Method bool isNinePatch() const |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 467 | #In Property |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 468 | #Line # returns true if not empty, Rect, Oval or simple; and radii are axis-aligned ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 469 | Returns true if isEmpty, isRect, isOval, and isSimple return false; and if |
| 470 | left x-axis radii are equal, right x-axis radii are equal, top y-axis radii are |
| 471 | equal, and bottom y-axis radii are equal. |
| 472 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 473 | #Return true if not empty, Rect, Oval or simple; and radii are axis-aligned ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 474 | |
| 475 | #Bug 8107 |
| 476 | #Example |
| 477 | #Height 100 |
| 478 | SkPaint paint;
|
| 479 | paint.setAntiAlias(true);
|
| 480 | paint.setTextAlign(SkPaint::kCenter_Align);
|
| 481 | paint.setTextSize(16);
|
| 482 | SkVector radii[] = {{20, 30}, {40, 30}, {40, 30}, {20, 30}};
|
| 483 | SkRRect rrect;
|
| 484 | rrect.setRectRadii({30, 10, 100, 60}, radii);
|
| 485 | canvas->drawRRect(rrect, paint);
|
| 486 | canvas->drawString(rrect.isNinePatch() ? "9 patch" : "not 9 patch", 64, 90, paint);
|
| 487 | radii[0].fX = 35;
|
| 488 | rrect.setRectRadii(rrect.getBounds(), radii);
|
| 489 | canvas->translate(128, 0);
|
| 490 | canvas->drawRRect(rrect, paint);
|
| 491 | canvas->drawString(rrect.isNinePatch() ? "9 patch" : "not 9 patch", 64, 90, paint); |
| 492 | ## |
| 493 | |
| 494 | #SeeAlso isEmpty isRect isOval isSimple isComplex |
| 495 | |
| 496 | #Method ## |
| 497 | |
| 498 | # ------------------------------------------------------------------------------ |
| 499 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 500 | #Method bool isComplex() const |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 501 | #In Property |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 502 | #Line # returns true if not empty, Rect, Oval, simple, or nine-patch ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 503 | |
| 504 | Returns true if isEmpty, isRect, isOval, isSimple, and isNinePatch return false. |
| 505 | If true: width and height are greater than zero, at least one corner radii are |
| 506 | both greater than zero; left x-axis radii are not equal, or right x-axis radii |
| 507 | are not equal, or top y-axis radii are not equal, or bottom y-axis radii are not |
| 508 | equal. |
| 509 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 510 | #Return true if not empty, Rect, Oval, simple, or nine-patch ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 511 | |
| 512 | #Example |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 513 | #Height 100 |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 514 | SkPaint paint;
|
| 515 | paint.setAntiAlias(true);
|
| 516 | paint.setTextAlign(SkPaint::kCenter_Align);
|
| 517 | paint.setTextSize(16);
|
| 518 | SkVector radii[] = {{25, 30}, {40, 30}, {40, 30}, {20, 30}};
|
| 519 | SkRRect rrect;
|
| 520 | rrect.setRectRadii({30, 10, 100, 60}, radii);
|
| 521 | canvas->drawRRect(rrect, paint);
|
| 522 | canvas->drawString(rrect.isComplex() ? "complex" : "not complex", 64, 90, paint);
|
| 523 | radii[0].fX = 20;
|
| 524 | rrect.setRectRadii(rrect.getBounds(), radii);
|
| 525 | canvas->translate(128, 0);
|
| 526 | canvas->drawRRect(rrect, paint);
|
| 527 | canvas->drawString(rrect.isComplex() ? "complex" : "not complex", 64, 90, paint); |
| 528 | ## |
| 529 | |
| 530 | #SeeAlso isEmpty isRect isOval isSimple isNinePatch |
| 531 | |
| 532 | #Method ## |
| 533 | |
| 534 | # ------------------------------------------------------------------------------ |
| 535 | |
| 536 | #Method SkScalar width() const |
| 537 | #In Property |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 538 | #Line # returns span in x-axis ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 539 | Returns span on the x-axis. This does not check if result fits in 32-bit float; |
| 540 | result may be infinity. |
| 541 | |
| 542 | #Return bounds().fRight minus bounds().fLeft ## |
| 543 | |
| 544 | #Example |
| 545 | #Description |
| 546 | SkRRect::MakeRect sorts its input, so width() is always zero or larger. |
| 547 | ## |
| 548 | SkRRect unsorted = SkRRect::MakeRect({ 15, 25, 10, 5 });
|
| 549 | SkDebugf("unsorted width: %g\n", unsorted.width());
|
| 550 | SkRRect large = SkRRect::MakeRect({ -FLT_MAX, 1, FLT_MAX, 2 });
|
| 551 | SkDebugf("large width: %.0f\n", large.width()); |
| 552 | #StdOut |
| 553 | unsorted width: 5
|
| 554 | large width: inf |
| 555 | ## |
| 556 | ## |
| 557 | |
| 558 | #SeeAlso SkRect::width height getBounds |
| 559 | |
| 560 | #Method ## |
| 561 | |
| 562 | # ------------------------------------------------------------------------------ |
| 563 | |
| 564 | #Method SkScalar height() const |
| 565 | #In Property |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 566 | #Line # returns span in y-axis ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 567 | Returns span on the y-axis. This does not check if result fits in 32-bit float; |
| 568 | result may be infinity. |
| 569 | |
| 570 | #Return bounds().fBottom minus bounds().fTop ## |
| 571 | |
| 572 | #Example |
| 573 | #Description |
| 574 | SkRRect::MakeRect sorts its input, so height() is always zero or larger. |
| 575 | ## |
| 576 | SkRRect unsorted = SkRRect::MakeRect({ 15, 25, 10, 20 }); |
| 577 | SkDebugf("unsorted height: %g\n", unsorted.height()); |
| 578 | SkRRect large = SkRRect::MakeRect({ 1, -FLT_MAX, 2, FLT_MAX }); |
| 579 | SkDebugf("large height: %.0f\n", large.height()); |
| 580 | #StdOut |
| 581 | unsorted height: 5
|
| 582 | large height: inf |
| 583 | ## |
| 584 | ## |
| 585 | |
| 586 | #SeeAlso SkRect.height width getBounds |
| 587 | |
| 588 | #Method ## |
| 589 | |
| 590 | # ------------------------------------------------------------------------------ |
| 591 | |
| 592 | #Method SkVector getSimpleRadii() const |
| 593 | #In Property |
| 594 | #Line # returns corner radii for simple types ## |
| 595 | |
Cary Clark | d2ca79c | 2018-08-10 13:09:13 -0400 | [diff] [blame] | 596 | Returns top-left corner radii. If type() returns kEmpty_Type, kRect_Type, |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 597 | kOval_Type, or kSimple_Type, returns a value representative of all corner radii. |
| 598 | If type() returns kNinePatch_Type or kComplex_Type, at least one of the |
| 599 | remaining three corners has a different value. |
| 600 | |
| 601 | #Return corner radii for simple types ## |
| 602 | |
| 603 | #Example |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 604 | #Height 100 |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 605 | auto drawDetails = [=](const SkRRect& rrect) {
|
| 606 | SkPaint paint;
|
| 607 | paint.setAntiAlias(true);
|
| 608 | paint.setTextAlign(SkPaint::kCenter_Align);
|
| 609 | paint.setTextSize(12);
|
| 610 | canvas->drawRRect(rrect, paint);
|
| 611 | SkVector corner = rrect.getSimpleRadii();
|
| 612 | std::string label = "corner: " + std::to_string(corner.fX).substr(0, 3) + ", " +
|
| 613 | std::to_string(corner.fY).substr(0, 3);
|
| 614 | canvas->drawString(label.c_str(), 64, 90, paint);
|
| 615 | canvas->translate(128, 0);
|
| 616 | };
|
| 617 | SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
|
| 618 | drawDetails(rrect);
|
| 619 | rrect.setRectXY(rrect.getBounds(), 5, 8);
|
| 620 | drawDetails(rrect);
|
| 621 | ## |
| 622 | |
| 623 | #SeeAlso radii getBounds getType isSimple |
| 624 | |
| 625 | #Method ## |
| 626 | |
| 627 | # ------------------------------------------------------------------------------ |
| 628 | |
| 629 | #Method void setEmpty() |
| 630 | #In Set |
| 631 | #Line # zeroes width, height, and corner radii ## |
| 632 | |
| 633 | Sets bounds to zero width and height at (0, 0), the origin. Sets |
| 634 | corner radii to zero and sets type to kEmpty_Type. |
| 635 | |
| 636 | #Example |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 637 | #Height 80 |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 638 | #Description |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 639 | Nothing blue is drawn because Round_Rect is set to empty. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 640 | ## |
| 641 | SkPaint paint;
|
| 642 | SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
|
| 643 | canvas->drawRRect(rrect, paint);
|
| 644 | rrect.setEmpty();
|
| 645 | paint.setColor(SK_ColorBLUE);
|
| 646 | canvas->drawRRect(rrect, paint); |
| 647 | ## |
| 648 | |
| 649 | #SeeAlso MakeEmpty setRect |
| 650 | |
| 651 | #Method ## |
| 652 | |
| 653 | # ------------------------------------------------------------------------------ |
| 654 | |
| 655 | #Method void setRect(const SkRect& rect) |
| 656 | #In Set |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 657 | #Line # sets Round_Rect bounds with zeroed corners ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 658 | |
| 659 | Sets bounds to sorted rect, and sets corner radii to zero. |
| 660 | If set bounds has width and height, and sets type to kRect_Type; |
| 661 | otherwise, sets type to kEmpty_Type. |
| 662 | |
| 663 | #Param rect bounds to set ## |
| 664 | |
| 665 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 666 | #Height 90 |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 667 | SkPaint paint;
|
| 668 | SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
|
| 669 | canvas->drawRRect(rrect, paint);
|
| 670 | rrect.setRect({60, 30, 120, 80});
|
| 671 | paint.setColor(SK_ColorBLUE);
|
| 672 | canvas->drawRRect(rrect, paint); |
| 673 | ## |
| 674 | |
| 675 | #SeeAlso MakeRect setRectXY |
| 676 | |
| 677 | #Method ## |
| 678 | |
| 679 | # ------------------------------------------------------------------------------ |
| 680 | |
| 681 | #Method static SkRRect MakeEmpty() |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 682 | #In Constructors |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 683 | #Line # creates with zeroed bounds and corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 684 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 685 | Initializes bounds at (0, 0), the origin, with zero width and height. |
| 686 | Initializes corner radii to (0, 0), and sets type of kEmpty_Type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 687 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 688 | #Return empty Round_Rect ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 689 | |
| 690 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 691 | #Height 90 |
| 692 | SkRRect rrect = SkRRect::MakeEmpty();
|
| 693 | SkRRect rrect2(rrect);
|
| 694 | rrect2.inset(-20, -20);
|
| 695 | SkPaint p;
|
| 696 | p.setStyle(SkPaint::kStroke_Style);
|
| 697 | p.setStrokeWidth(10);
|
| 698 | std::string str("Type ");
|
| 699 | str += SkRRect::kEmpty_Type == rrect2.type() ? "=" : "!";
|
| 700 | str += "= SkRRect::kEmpty_Type";
|
| 701 | canvas->drawString(str.c_str(), 20, 80, SkPaint());
|
| 702 | canvas->drawRRect(rrect2, p); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 703 | ## |
| 704 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 705 | #SeeAlso SkRRect() SkRect::MakeEmpty |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 706 | |
| 707 | #Method ## |
| 708 | |
| 709 | # ------------------------------------------------------------------------------ |
| 710 | |
| 711 | #Method static SkRRect MakeRect(const SkRect& r) |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 712 | #In Constructors |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 713 | #Line # copies bounds and zeroes corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 714 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 715 | Initializes to copy of r bounds and zeroes corner radii. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 716 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 717 | #Param r bounds to copy ## |
| 718 | |
| 719 | #Return copy of r ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 720 | |
| 721 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 722 | #Height 70 |
| 723 | SkPaint paint;
|
| 724 | SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
|
| 725 | canvas->drawRRect(rrect, paint);
|
| 726 | rrect.setOval(rrect.getBounds());
|
| 727 | paint.setColor(SK_ColorBLUE);
|
| 728 | canvas->drawRRect(rrect, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 729 | ## |
| 730 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 731 | #SeeAlso setRect MakeOval MakeRectXY |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 732 | |
| 733 | #Method ## |
| 734 | |
| 735 | # ------------------------------------------------------------------------------ |
| 736 | |
| 737 | #Method static SkRRect MakeOval(const SkRect& oval) |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 738 | #In Constructors |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 739 | #Line # creates Oval to fit bounds ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 740 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 741 | Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 742 | to half oval.height(). If oval bounds is empty, sets to kEmpty_Type. |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 743 | Otherwise, sets to kOval_Type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 744 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 745 | #Param oval bounds of Oval ## |
| 746 | |
| 747 | #Return Oval ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 748 | |
| 749 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 750 | #Height 70 |
| 751 | SkPaint paint;
|
| 752 | SkRRect rrect = SkRRect::MakeOval({30, 10, 100, 60});
|
| 753 | canvas->drawRRect(rrect, paint);
|
| 754 | rrect.setRect(rrect.getBounds());
|
| 755 | paint.setColor(SK_ColorBLUE);
|
| 756 | paint.setBlendMode(SkBlendMode::kDifference);
|
| 757 | canvas->drawRRect(rrect, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 758 | ## |
| 759 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 760 | #SeeAlso setOval MakeRect MakeRectXY |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 761 | |
| 762 | #Method ## |
| 763 | |
| 764 | # ------------------------------------------------------------------------------ |
| 765 | |
| 766 | #Method static SkRRect MakeRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad) |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 767 | #In Constructors |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 768 | #Line # creates rounded rectangle ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 769 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 770 | Sets to rounded rectangle with the same radii for all four corners. |
| 771 | If rect is empty, sets to kEmpty_Type. |
| 772 | Otherwise, if xRad and yRad are zero, sets to kRect_Type. |
| 773 | Otherwise, if xRad is at least half rect.width() and yRad is at least half |
| 774 | rect.height(), sets to kOval_Type. |
| 775 | Otherwise, sets to kSimple_Type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 776 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 777 | #Param rect bounds of rounded rectangle ## |
| 778 | #Param xRad x-axis radius of corners ## |
| 779 | #Param yRad y-axis radius of corners ## |
| 780 | |
| 781 | #Return rounded rectangle ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 782 | |
| 783 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 784 | #Height 70 |
| 785 | SkPaint paint;
|
| 786 | SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 20, 20);
|
| 787 | canvas->drawRRect(rrect, paint);
|
| 788 | rrect.setRect(rrect.getBounds());
|
| 789 | paint.setColor(SK_ColorBLUE);
|
| 790 | paint.setBlendMode(SkBlendMode::kModulate);
|
| 791 | canvas->drawRRect(rrect, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 792 | ## |
| 793 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 794 | #SeeAlso setRectXY |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 795 | |
| 796 | #Method ## |
| 797 | |
| 798 | # ------------------------------------------------------------------------------ |
| 799 | |
| 800 | #Method void setOval(const SkRect& oval) |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 801 | #In Set |
| 802 | #Line # replaces with Oval to fit bounds ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 803 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 804 | Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 805 | to half oval.height(). If oval bounds is empty, sets to kEmpty_Type. |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 806 | Otherwise, sets to kOval_Type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 807 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 808 | #Param oval bounds of Oval ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 809 | |
| 810 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 811 | #Height 70 |
| 812 | SkPaint paint;
|
| 813 | SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 20, 20);
|
| 814 | canvas->drawRRect(rrect, paint);
|
| 815 | rrect.setOval(rrect.getBounds());
|
| 816 | paint.setColor(SK_ColorWHITE);
|
| 817 | paint.setBlendMode(SkBlendMode::kExclusion);
|
| 818 | canvas->drawRRect(rrect, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 819 | ## |
| 820 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 821 | #SeeAlso MakeOval |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 822 | |
| 823 | #Method ## |
| 824 | |
| 825 | # ------------------------------------------------------------------------------ |
| 826 | |
| 827 | #Method void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad) |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 828 | #In Set |
| 829 | #Line # replaces with rounded rectangle ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 830 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 831 | Sets to rounded rectangle with the same radii for all four corners. |
| 832 | If rect is empty, sets to kEmpty_Type. |
| 833 | Otherwise, if xRad or yRad is zero, sets to kRect_Type. |
| 834 | Otherwise, if xRad is at least half rect.width() and yRad is at least half |
| 835 | rect.height(), sets to kOval_Type. |
| 836 | Otherwise, sets to kSimple_Type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 837 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 838 | #Param rect bounds of rounded rectangle ## |
| 839 | #Param xRad x-axis radius of corners ## |
| 840 | #Param yRad y-axis radius of corners ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 841 | |
| 842 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 843 | #Height 70 |
| 844 | SkPaint paint;
|
| 845 | SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 20, 20);
|
| 846 | canvas->drawRRect(rrect, paint);
|
| 847 | rrect.setRectXY(rrect.getBounds(), 5, 5);
|
| 848 | paint.setColor(SK_ColorWHITE);
|
| 849 | paint.setBlendMode(SkBlendMode::kExclusion);
|
| 850 | canvas->drawRRect(rrect, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 851 | ## |
| 852 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 853 | #SeeAlso MakeRectXY SkPath::addRoundRect |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 854 | |
| 855 | #Method ## |
| 856 | |
| 857 | # ------------------------------------------------------------------------------ |
| 858 | |
| 859 | #Method void setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad, |
| 860 | SkScalar rightRad, SkScalar bottomRad) |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 861 | #In Set |
| 862 | #Line # replaces with rounded rectangle ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 863 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 864 | Sets bounds to rect. Sets radii to (leftRad, topRad), (rightRad, topRad), |
| 865 | (rightRad, bottomRad), (leftRad, bottomRad). |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 866 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 867 | If rect is empty, sets to kEmpty_Type. |
| 868 | Otherwise, if leftRad and rightRad are zero, sets to kRect_Type. |
| 869 | Otherwise, if topRad and bottomRad are zero, sets to kRect_Type. |
| 870 | Otherwise, if leftRad and rightRad are equal and at least half rect.width(), and |
| 871 | topRad and bottomRad are equal at least half rect.height(), sets to kOval_Type. |
| 872 | Otherwise, if leftRad and rightRad are equal, and topRad and bottomRad are equal, |
| 873 | sets to kSimple_Type. Otherwise, sets to kNinePatch_Type. |
| 874 | |
| 875 | Nine patch refers to the nine parts defined by the radii: one center rectangle, |
| 876 | four edge patches, and four corner patches. |
| 877 | |
| 878 | #Param rect bounds of rounded rectangle ## |
| 879 | #Param leftRad left-top and left-bottom x-axis radius ## |
| 880 | #Param topRad left-top and right-top y-axis radius ## |
| 881 | #Param rightRad right-top and right-bottom x-axis radius ## |
| 882 | #Param bottomRad left-bottom and right-bottom y-axis radius ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 883 | |
| 884 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 885 | #Height 70 |
| 886 | SkPaint paint;
|
| 887 | paint.setAntiAlias(true);
|
| 888 | SkRRect rrect;
|
| 889 | rrect.setNinePatch({30, 10, 100, 60}, 10, 20, 20, 10);
|
| 890 | canvas->drawRRect(rrect, paint);
|
| 891 | paint.setColor(SK_ColorWHITE);
|
| 892 | const SkRect r = rrect.getBounds();
|
| 893 | canvas->drawLine(r.fLeft, r.fTop + rrect.radii(SkRRect::kUpperLeft_Corner).fY,
|
| 894 | r.fRight, r.fTop + rrect.radii(SkRRect::kUpperRight_Corner).fY, paint);
|
| 895 | canvas->drawLine(r.fLeft, r.fBottom - rrect.radii(SkRRect::kLowerLeft_Corner).fY,
|
| 896 | r.fRight, r.fBottom - rrect.radii(SkRRect::kLowerRight_Corner).fY, paint);
|
| 897 | canvas->drawLine(r.fLeft + rrect.radii(SkRRect::kUpperLeft_Corner).fX, r.fTop,
|
| 898 | r.fLeft + rrect.radii(SkRRect::kLowerLeft_Corner).fX, r.fBottom, paint);
|
| 899 | canvas->drawLine(r.fRight - rrect.radii(SkRRect::kUpperRight_Corner).fX, r.fTop,
|
| 900 | r.fRight - rrect.radii(SkRRect::kLowerRight_Corner).fX, r.fBottom, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 901 | ## |
| 902 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 903 | #SeeAlso setRectRadii |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 904 | |
| 905 | #Method ## |
| 906 | |
| 907 | # ------------------------------------------------------------------------------ |
| 908 | |
| 909 | #Method void setRectRadii(const SkRect& rect, const SkVector radii[4]) |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 910 | #In Set |
| 911 | #Line # replaces with rounded rectangle ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 912 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 913 | Sets bounds to rect. Sets radii array for individual control of all for corners. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 914 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 915 | If rect is empty, sets to kEmpty_Type. |
| 916 | Otherwise, if one of each corner radii are zero, sets to kRect_Type. |
| 917 | Otherwise, if all x-axis radii are equal and at least half rect.width(), and |
| 918 | all y-axis radii are equal at least half rect.height(), sets to kOval_Type. |
| 919 | Otherwise, if all x-axis radii are equal, and all y-axis radii are equal, |
| 920 | sets to kSimple_Type. Otherwise, sets to kNinePatch_Type. |
| 921 | |
| 922 | #Param rect bounds of rounded rectangle ## |
| 923 | #Param radii corner x-axis and y-axis radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 924 | |
| 925 | #Example |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 926 | #Height 128 |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 927 | SkPaint paint;
|
| 928 | paint.setStrokeWidth(15);
|
| 929 | paint.setStrokeCap(SkPaint::kSquare_Cap);
|
| 930 | paint.setAntiAlias(true);
|
| 931 | float intervals[] = { 5, 21.75f };
|
| 932 | paint.setStyle(SkPaint::kStroke_Style);
|
| 933 | paint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
|
| 934 | SkPath path;
|
| 935 | SkRRect rrect;
|
| 936 | SkVector corners[] = {{15, 17}, {17, 19}, {19, 15}, {15, 15}};
|
| 937 | rrect.setRectRadii({20, 20, 100, 100}, corners);
|
| 938 | path.addRRect(rrect, SkPath::kCW_Direction);
|
| 939 | canvas->drawPath(path, paint);
|
| 940 | path.rewind();
|
| 941 | path.addRRect(rrect, SkPath::kCCW_Direction, 1);
|
| 942 | canvas->translate(120, 0);
|
| 943 | canvas->drawPath(path, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 944 | ## |
| 945 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 946 | #SeeAlso setNinePatch SkPath::addRoundRect |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 947 | |
| 948 | #Method ## |
| 949 | |
| 950 | # ------------------------------------------------------------------------------ |
| 951 | |
| 952 | #Enum Corner |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 953 | #Line # corner radii order ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 954 | |
| 955 | #Code |
| 956 | enum Corner { |
| 957 | kUpperLeft_Corner, |
| 958 | kUpperRight_Corner, |
| 959 | kLowerRight_Corner, |
| 960 | kLowerLeft_Corner, |
| 961 | }; |
| 962 | ## |
| 963 | |
| 964 | The radii are stored: top-left, top-right, bottom-right, bottom-left. |
| 965 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 966 | #Const kUpperLeft_Corner 0 |
| 967 | #Line # index of top-left corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 968 | ## |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 969 | #Const kUpperRight_Corner 1 |
| 970 | #Line # index of top-right corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 971 | ## |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 972 | #Const kLowerRight_Corner 2 |
| 973 | #Line # index of bottom-right corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 974 | ## |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 975 | #Const kLowerLeft_Corner 3 |
| 976 | #Line # index of bottom-left corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 977 | ## |
| 978 | |
| 979 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 980 | #Height 70 |
| 981 | SkPaint paint;
|
| 982 | paint.setAntiAlias(true);
|
| 983 | SkRRect rrect;
|
| 984 | SkVector corners[] = {{25, 17}, {17, 19}, {19, 15}, {15, 15}};
|
| 985 | rrect.setRectRadii({30, 10, 100, 60}, corners);
|
| 986 | canvas->drawRRect(rrect, paint);
|
| 987 | paint.setColor(SK_ColorWHITE);
|
| 988 | const SkRect r = rrect.getBounds();
|
| 989 | canvas->drawLine(r.fLeft, r.fTop + rrect.radii(SkRRect::kUpperLeft_Corner).fY,
|
| 990 | r.fRight, r.fTop + rrect.radii(SkRRect::kUpperRight_Corner).fY, paint);
|
| 991 | canvas->drawLine(r.fLeft, r.fBottom - rrect.radii(SkRRect::kLowerLeft_Corner).fY,
|
| 992 | r.fRight, r.fBottom - rrect.radii(SkRRect::kLowerRight_Corner).fY, paint);
|
| 993 | canvas->drawLine(r.fLeft + rrect.radii(SkRRect::kUpperLeft_Corner).fX, r.fTop,
|
| 994 | r.fLeft + rrect.radii(SkRRect::kLowerLeft_Corner).fX, r.fBottom, paint);
|
| 995 | canvas->drawLine(r.fRight - rrect.radii(SkRRect::kUpperRight_Corner).fX, r.fTop,
|
| 996 | r.fRight - rrect.radii(SkRRect::kLowerRight_Corner).fX, r.fBottom, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 997 | ## |
| 998 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 999 | #SeeAlso radii |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1000 | |
| 1001 | #Enum ## |
| 1002 | |
| 1003 | # ------------------------------------------------------------------------------ |
| 1004 | |
| 1005 | #Method const SkRect& rect() const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1006 | #In Property |
| 1007 | #Line # returns bounds ## |
| 1008 | Returns bounds. Bounds may have zero width or zero height. Bounds right is |
| 1009 | greater than or equal to left; bounds bottom is greater than or equal to top. |
| 1010 | Result is identical to getBounds. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1011 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1012 | #Return bounding box ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1013 | |
| 1014 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1015 | for (SkScalar left : { SK_ScalarNaN, SK_ScalarInfinity, 100.f, 50.f, 25.f} ) {
|
| 1016 | SkRRect rrect1 = SkRRect::MakeRectXY({left, 20, 60, 220}, 50, 200);
|
| 1017 | SkDebugf("left bounds: (%g) %g\n", left, rrect1.rect().fLeft);
|
| 1018 | } |
| 1019 | #StdOut |
| 1020 | left bounds: (nan) 0
|
| 1021 | left bounds: (inf) 0
|
| 1022 | left bounds: (100) 60
|
| 1023 | left bounds: (50) 50
|
| 1024 | left bounds: (25) 25 |
| 1025 | ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1026 | ## |
| 1027 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1028 | #SeeAlso getBounds |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1029 | |
| 1030 | #Method ## |
| 1031 | |
| 1032 | # ------------------------------------------------------------------------------ |
| 1033 | |
| 1034 | #Method SkVector radii(Corner corner) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1035 | #In Property |
| 1036 | #Line # returns x-axis and y-axis radii for one corner ## |
| 1037 | Returns Scalar pair for radius of curve on x-axis and y-axis for one corner. |
| 1038 | Both radii may be zero. If not zero, both are positive and finite. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1039 | |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1040 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1041 | #Param corner one of: kUpperLeft_Corner, kUpperRight_Corner, |
| 1042 | kLowerRight_Corner, kLowerLeft_Corner |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1043 | ## |
| 1044 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1045 | #Return x-axis and y-axis radii for one corner ## |
| 1046 | |
| 1047 | #Example |
| 1048 | #Description |
| 1049 | Finite values are scaled proportionately to fit; other values are set to zero. |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1050 | Scaled values cannot be larger than 25, half the bounding Round_Rect width. |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1051 | Small scaled values are halved to scale in proportion to the y-axis corner |
| 1052 | radius, which is twice the bounds height. |
| 1053 | ## |
| 1054 | for (SkScalar radiusX : { SK_ScalarNaN, SK_ScalarInfinity, 100.f, 50.f, 25.f} ) {
|
| 1055 | SkRRect rrect1 = SkRRect::MakeRectXY({10, 20, 60, 220}, radiusX, 200);
|
| 1056 | SkDebugf("left corner: (%g) %g\n", radiusX, rrect1.radii(SkRRect::kUpperLeft_Corner).fX);
|
| 1057 | }
|
| 1058 | #StdOut |
| 1059 | left corner: (nan) 0
|
| 1060 | left corner: (inf) 0
|
| 1061 | left corner: (100) 25
|
| 1062 | left corner: (50) 25
|
| 1063 | left corner: (25) 12.5 |
| 1064 | ## |
| 1065 | ## |
| 1066 | |
| 1067 | #SeeAlso Corner |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1068 | |
| 1069 | #Method ## |
| 1070 | |
| 1071 | # ------------------------------------------------------------------------------ |
| 1072 | |
| 1073 | #Method const SkRect& getBounds() const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1074 | #In Property |
| 1075 | #Line # returns bounds ## |
| 1076 | Returns bounds. Bounds may have zero width or zero height. Bounds right is |
| 1077 | greater than or equal to left; bounds bottom is greater than or equal to top. |
| 1078 | Result is identical to rect(). |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1079 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1080 | #Return bounding box ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1081 | |
| 1082 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1083 | #Height 120 |
| 1084 | SkPaint paint;
|
| 1085 | SkRRect rrect = SkRRect::MakeRectXY({20, 20, 220, 100}, 15, 15);
|
| 1086 | canvas->drawRRect(rrect, paint);
|
| 1087 | paint.setColor(SK_ColorWHITE);
|
| 1088 | rrect = SkRRect::MakeOval(rrect.getBounds());
|
| 1089 | canvas->drawRRect(rrect, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1090 | ## |
| 1091 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1092 | #SeeAlso rect |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1093 | |
| 1094 | #Method ## |
| 1095 | |
| 1096 | # ------------------------------------------------------------------------------ |
| 1097 | |
| 1098 | #Method bool operator==(const SkRRect& a, const SkRRect& b) |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 1099 | #In Operators |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1100 | #Line # returns true if members are equal ## |
| 1101 | Returns true if bounds and radii in a are equal to bounds and radii in b. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1102 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1103 | a and b are not equal if either contain NaN. a and b are equal if members |
| 1104 | contain zeroes width different signs. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1105 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1106 | #Param a Rect bounds and radii to compare ## |
| 1107 | #Param b Rect bounds and radii to compare ## |
| 1108 | |
| 1109 | #Return true if members are equal ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1110 | |
| 1111 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1112 | SkRRect rrect1 = SkRRect::MakeRectXY({10, 20, 60, 220}, 50, 200);
|
| 1113 | SkRRect rrect2 = SkRRect::MakeRectXY(rrect1.rect(), 25, 100);
|
| 1114 | SkRRect rrect3 = SkRRect::MakeOval(rrect1.rect());
|
| 1115 | canvas->drawRRect(rrect1, SkPaint());
|
| 1116 | std::string str = "rrect1 " + std::string(rrect1 == rrect2 ? "=" : "!") + "= rrect2";
|
| 1117 | canvas->drawString(str.c_str(), 10, 240, SkPaint());
|
| 1118 | canvas->translate(70, 0);
|
| 1119 | canvas->drawRRect(rrect2, SkPaint());
|
| 1120 | canvas->translate(70, 0);
|
| 1121 | canvas->drawRRect(rrect3, SkPaint());
|
| 1122 | str = "rrect2 " + std::string(rrect2 == rrect3 ? "=" : "!") + "= rrect3";
|
| 1123 | canvas->drawString(str.c_str(), -20, 240, SkPaint()); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1124 | ## |
| 1125 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1126 | #SeeAlso operator!=(const SkRRect& a, const SkRRect& b) |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1127 | |
| 1128 | #Method ## |
| 1129 | |
| 1130 | # ------------------------------------------------------------------------------ |
| 1131 | |
| 1132 | #Method bool operator!=(const SkRRect& a, const SkRRect& b) |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 1133 | #In Operators |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1134 | #Line # returns true if members are unequal ## |
| 1135 | Returns true if bounds and radii in a are not equal to bounds and radii in b. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1136 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1137 | a and b are not equal if either contain NaN. a and b are equal if members |
| 1138 | contain zeroes width different signs. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1139 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1140 | #Param a Rect bounds and radii to compare ## |
| 1141 | #Param b Rect bounds and radii to compare ## |
| 1142 | |
| 1143 | #Return true if members are not equal ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1144 | |
| 1145 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1146 | SkRRect rrect1 = SkRRect::MakeRectXY({10, 20, 60, 220}, 50, 100);
|
| 1147 | SkRRect rrect2 = SkRRect::MakeRectXY(rrect1.rect(), 50, 50);
|
| 1148 | SkRRect rrect3 = SkRRect::MakeOval(rrect1.rect());
|
| 1149 | canvas->drawRRect(rrect1, SkPaint());
|
| 1150 | std::string str = "rrect1 " + std::string(rrect1 == rrect2 ? "=" : "!") + "= rrect2";
|
| 1151 | canvas->drawString(str.c_str(), 10, 240, SkPaint());
|
| 1152 | canvas->translate(70, 0);
|
| 1153 | canvas->drawRRect(rrect2, SkPaint());
|
| 1154 | canvas->translate(70, 0);
|
| 1155 | canvas->drawRRect(rrect3, SkPaint());
|
| 1156 | str = "rrect2 " + std::string(rrect2 == rrect3 ? "=" : "!") + "= rrect3";
|
| 1157 | canvas->drawString(str.c_str(), -20, 240, SkPaint()); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1158 | ## |
| 1159 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1160 | #SeeAlso operator==(const SkRRect& a, const SkRRect& b) |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1161 | |
| 1162 | #Method ## |
| 1163 | |
| 1164 | # ------------------------------------------------------------------------------ |
| 1165 | |
| 1166 | #Method void inset(SkScalar dx, SkScalar dy, SkRRect* dst) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1167 | #In Inset_Outset_Offset |
| 1168 | #Line # insets bounds and radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1169 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1170 | Copies Round_Rect to dst, then insets dst bounds by dx and dy, and adjusts dst |
| 1171 | radii by dx and dy. dx and dy may be positive, negative, or zero. dst may be |
| 1172 | Round_Rect. |
| 1173 | |
| 1174 | If either corner radius is zero, the corner has no curvature and is unchanged. |
| 1175 | Otherwise, if adjusted radius becomes negative, pins radius to zero. |
| 1176 | If dx exceeds half dst bounds width, dst bounds left and right are set to |
| 1177 | bounds x-axis center. If dy exceeds half dst bounds height, dst bounds top and |
| 1178 | bottom are set to bounds y-axis center. |
| 1179 | |
| 1180 | If dx or dy cause the bounds to become infinite, dst bounds is zeroed. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1181 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1182 | #Param dx added to rect().fLeft, and subtracted from rect().fRight ## |
| 1183 | #Param dy added to rect().fTop, and subtracted from rect().fBottom ## |
| 1184 | #Param dst insets bounds and radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1185 | |
| 1186 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1187 | SkPaint paint;
|
| 1188 | paint.setAntiAlias(true);
|
| 1189 | paint.setStyle(SkPaint::kStroke_Style);
|
| 1190 | SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
|
| 1191 | for (int index = 0; index < 25; ++index) {
|
| 1192 | canvas->drawRRect(rrect, paint);
|
| 1193 | rrect.inset(-3, 3, &rrect);
|
| 1194 | }
|
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1195 | ## |
| 1196 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1197 | #SeeAlso outset offset makeOffset |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1198 | |
| 1199 | #Method ## |
| 1200 | |
| 1201 | # ------------------------------------------------------------------------------ |
| 1202 | |
| 1203 | #Method void inset(SkScalar dx, SkScalar dy) |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1204 | #In Inset_Outset_Offset |
| 1205 | #Line # insets bounds and radii ## |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1206 | Insets bounds by dx and dy, and adjusts radii by dx and dy. dx and dy may be |
| 1207 | positive, negative, or zero. |
| 1208 | |
| 1209 | If either corner radius is zero, the corner has no curvature and is unchanged. |
| 1210 | Otherwise, if adjusted radius becomes negative, pins radius to zero. |
| 1211 | If dx exceeds half bounds width, bounds left and right are set to |
| 1212 | bounds x-axis center. If dy exceeds half bounds height, bounds top and |
| 1213 | bottom are set to bounds y-axis center. |
| 1214 | |
| 1215 | If dx or dy cause the bounds to become infinite, bounds is zeroed. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1216 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1217 | #Param dx added to rect().fLeft, and subtracted from rect().fRight ## |
| 1218 | #Param dy added to rect().fTop, and subtracted from rect().fBottom ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1219 | |
| 1220 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1221 | SkPaint paint;
|
| 1222 | paint.setAntiAlias(true);
|
| 1223 | paint.setStyle(SkPaint::kStroke_Style);
|
| 1224 | SkRRect rrect = SkRRect::MakeRectXY({10, 20, 180, 220}, 50, 100);
|
| 1225 | for (int index = 0; index < 25; ++index) {
|
| 1226 | canvas->drawRRect(rrect, paint);
|
| 1227 | rrect.inset(3, 3);
|
| 1228 | } |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1229 | ## |
| 1230 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1231 | #SeeAlso outset offset makeOffset |
| 1232 | |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1233 | |
| 1234 | #Method ## |
| 1235 | |
| 1236 | # ------------------------------------------------------------------------------ |
| 1237 | |
| 1238 | #Method void outset(SkScalar dx, SkScalar dy, SkRRect* dst) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1239 | #In Inset_Outset_Offset |
| 1240 | #Line # outsets bounds and radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1241 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1242 | Outsets dst bounds by dx and dy, and adjusts radii by dx and dy. dx and dy may be |
| 1243 | positive, negative, or zero. |
| 1244 | |
| 1245 | If either corner radius is zero, the corner has no curvature and is unchanged. |
| 1246 | Otherwise, if adjusted radius becomes negative, pins radius to zero. |
| 1247 | If dx exceeds half dst bounds width, dst bounds left and right are set to |
| 1248 | bounds x-axis center. If dy exceeds half dst bounds height, dst bounds top and |
| 1249 | bottom are set to bounds y-axis center. |
| 1250 | |
| 1251 | If dx or dy cause the bounds to become infinite, dst bounds is zeroed. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1252 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1253 | #Param dx subtracted from rect().fLeft, and added to rect().fRight ## |
| 1254 | #Param dy subtracted from rect().fTop, and added to rect().fBottom ## |
| 1255 | #Param dst outset bounds and radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1256 | |
| 1257 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1258 | SkPaint paint;
|
| 1259 | paint.setAntiAlias(true);
|
| 1260 | paint.setStyle(SkPaint::kStroke_Style);
|
| 1261 | SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
|
| 1262 | for (int index = 0; index < 25; ++index) {
|
| 1263 | canvas->drawRRect(rrect, paint);
|
| 1264 | rrect.outset(-3, 3, &rrect);
|
| 1265 | }
|
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1266 | ## |
| 1267 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1268 | #SeeAlso inset offset makeOffset |
| 1269 | |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1270 | |
| 1271 | #Method ## |
| 1272 | |
| 1273 | # ------------------------------------------------------------------------------ |
| 1274 | |
| 1275 | #Method void outset(SkScalar dx, SkScalar dy) |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1276 | #In Inset_Outset_Offset |
| 1277 | #Line # outsets bounds and radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1278 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1279 | Outsets bounds by dx and dy, and adjusts radii by dx and dy. dx and dy may be |
| 1280 | positive, negative, or zero. |
| 1281 | |
| 1282 | If either corner radius is zero, the corner has no curvature and is unchanged. |
| 1283 | Otherwise, if adjusted radius becomes negative, pins radius to zero. |
| 1284 | If dx exceeds half bounds width, bounds left and right are set to |
| 1285 | bounds x-axis center. If dy exceeds half bounds height, bounds top and |
| 1286 | bottom are set to bounds y-axis center. |
| 1287 | |
| 1288 | If dx or dy cause the bounds to become infinite, bounds is zeroed. |
| 1289 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1290 | #Param dx subtracted from rect().fLeft, and added to rect().fRight ## |
| 1291 | #Param dy subtracted from rect().fTop, and added to rect().fBottom ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1292 | |
| 1293 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1294 | SkPaint paint;
|
| 1295 | paint.setAntiAlias(true);
|
| 1296 | paint.setStyle(SkPaint::kStroke_Style);
|
| 1297 | SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
|
| 1298 | for (int index = 0; index < 25; ++index) {
|
| 1299 | canvas->drawRRect(rrect, paint);
|
| 1300 | rrect.outset(3, 3);
|
| 1301 | }
|
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1302 | ## |
| 1303 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1304 | #SeeAlso inset offset makeOffset |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1305 | |
| 1306 | #Method ## |
| 1307 | |
| 1308 | # ------------------------------------------------------------------------------ |
| 1309 | |
| 1310 | #Method void offset(SkScalar dx, SkScalar dy) |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1311 | #In Inset_Outset_Offset |
| 1312 | #Line # offsets bounds and radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1313 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1314 | Translates Round_Rect by (dx, dy). |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1315 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1316 | #Param dx offset added to rect().fLeft and rect().fRight ## |
| 1317 | #Param dy offset added to rect().fTop and rect().fBottom ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1318 | |
| 1319 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1320 | SkPaint paint;
|
| 1321 | paint.setAntiAlias(true);
|
| 1322 | paint.setStyle(SkPaint::kStroke_Style);
|
| 1323 | SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
|
| 1324 | for (int index = 0; index < 25; ++index) {
|
| 1325 | canvas->drawRRect(rrect, paint);
|
| 1326 | rrect.offset(3, 3);
|
| 1327 | }
|
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1328 | ## |
| 1329 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1330 | #SeeAlso makeOffset inset outset |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1331 | |
| 1332 | #Method ## |
| 1333 | |
| 1334 | # ------------------------------------------------------------------------------ |
| 1335 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 1336 | #Method SkRRect makeOffset(SkScalar dx, SkScalar dy) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1337 | #In Inset_Outset_Offset |
| 1338 | #Line # offsets bounds and radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1339 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1340 | Returns Round_Rect translated by (dx, dy). |
| 1341 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1342 | #Param dx offset added to rect().fLeft and rect().fRight ## |
| 1343 | #Param dy offset added to rect().fTop and rect().fBottom ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1344 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1345 | #Return Round_Rect bounds offset by (dx, dy), with unchanged corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1346 | |
| 1347 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1348 | SkPaint paint;
|
| 1349 | paint.setAntiAlias(true);
|
| 1350 | paint.setStyle(SkPaint::kStroke_Style);
|
| 1351 | SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
|
| 1352 | for (int index = 0; index < 25; ++index) {
|
| 1353 | canvas->drawRRect(rrect, paint);
|
| 1354 | rrect = rrect.makeOffset(-3, 3);
|
| 1355 | } |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1356 | ## |
| 1357 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1358 | #SeeAlso offset inset outset |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1359 | |
| 1360 | #Method ## |
| 1361 | |
| 1362 | # ------------------------------------------------------------------------------ |
| 1363 | |
| 1364 | #Method bool contains(const SkRect& rect) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1365 | #In Intersection |
| 1366 | #Line # returns true if Rect is inside ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1367 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1368 | Returns true if rect is inside the bounds and corner radii, and if |
| 1369 | Round_Rect and rect are not empty. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1370 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1371 | #Param rect area tested for containment ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1372 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1373 | #Return true if Round_Rect contains rect ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1374 | |
| 1375 | #Example |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1376 | #Height 110 |
| 1377 | SkRect test = {10, 10, 110, 80};
|
| 1378 | SkRRect rrect = SkRRect::MakeRect(test);
|
| 1379 | SkRRect oval = SkRRect::MakeOval(test);
|
| 1380 | test.inset(10, 10);
|
| 1381 | SkPaint paint;
|
| 1382 | paint.setAntiAlias(true);
|
| 1383 | paint.setTextAlign(SkPaint::kCenter_Align);
|
| 1384 | canvas->drawString(rrect.contains(test) ? "contains" : "does not contain", 55, 100, paint);
|
| 1385 | canvas->drawString(oval.contains(test) ? "contains" : "does not contain", 185, 100, paint);
|
| 1386 | paint.setStyle(SkPaint::kStroke_Style);
|
| 1387 | canvas->drawRRect(rrect, paint);
|
| 1388 | canvas->drawRect(test, paint);
|
| 1389 | canvas->translate(120, 0);
|
| 1390 | canvas->drawRRect(oval, paint);
|
| 1391 | canvas->drawRect(test, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1392 | ## |
| 1393 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1394 | #SeeAlso SkRect::contains |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1395 | |
| 1396 | #Method ## |
| 1397 | |
| 1398 | # ------------------------------------------------------------------------------ |
| 1399 | |
| 1400 | #Method bool isValid() const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1401 | #In Utility |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1402 | #Line # returns if type() matches bounds and radii ## |
| 1403 | Returns true if bounds and radii values are finite and describe a Round_Rect |
| 1404 | Type that matches getType. All Round_Rect methods construct valid types, |
| 1405 | even if the input values are not valid. Invalid Round_Rect data can only |
| 1406 | be generated by corrupting memory. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1407 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1408 | #Return true if bounds and radii match type() ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1409 | |
| 1410 | #Example |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1411 | #Height 110 |
| 1412 | SkRRect rrect = SkRRect::MakeRect({10, 10, 110, 80});
|
| 1413 | SkRRect corrupt = rrect;
|
| 1414 | *((float*) &corrupt) = 120;
|
| 1415 | SkPaint paint;
|
| 1416 | paint.setAntiAlias(true);
|
| 1417 | paint.setTextAlign(SkPaint::kCenter_Align);
|
| 1418 | canvas->drawString(rrect.isValid() ? "is valid" : "is corrupted", 55, 100, paint);
|
| 1419 | canvas->drawString(corrupt.isValid() ? "is valid" : "is corrupted", 185, 100, paint);
|
| 1420 | paint.setStyle(SkPaint::kStroke_Style);
|
| 1421 | canvas->drawRRect(rrect, paint);
|
| 1422 | canvas->translate(120, 0);
|
| 1423 | canvas->drawRRect(corrupt, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1424 | ## |
| 1425 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1426 | #SeeAlso Type getType |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1427 | |
| 1428 | #Method ## |
| 1429 | |
| 1430 | # ------------------------------------------------------------------------------ |
| 1431 | |
| 1432 | #Const kSizeInMemory 48 |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1433 | #Line # storage space for Round_Rect ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1434 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1435 | Space required to serialize SkRRect into a buffer. Always a multiple of four. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1436 | |
| 1437 | #Const ## |
| 1438 | |
| 1439 | # ------------------------------------------------------------------------------ |
| 1440 | |
| 1441 | #Method size_t writeToMemory(void* buffer) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1442 | #In Utility |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1443 | #Line # writes Round_Rect to buffer ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1444 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1445 | Writes Round_Rect to buffer. Writes kSizeInMemory bytes, and returns |
| 1446 | kSizeInMemory, the number of bytes written. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1447 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1448 | #Param buffer storage for Round_Rect ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1449 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1450 | #Return bytes written, kSizeInMemory ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1451 | |
| 1452 | #Example |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1453 | #Height 110 |
| 1454 | SkRRect rrect = SkRRect::MakeRect({10, 10, 110, 80});
|
| 1455 | char storage[SkRRect::kSizeInMemory];
|
| 1456 | rrect.writeToMemory(storage);
|
| 1457 | SkRRect copy;
|
| 1458 | copy.readFromMemory(storage, sizeof(storage));
|
| 1459 | SkPaint paint;
|
| 1460 | paint.setAntiAlias(true);
|
| 1461 | paint.setTextAlign(SkPaint::kCenter_Align);
|
| 1462 | canvas->drawString("rrect", 55, 100, paint);
|
| 1463 | canvas->drawString("copy", 185, 100, paint);
|
| 1464 | paint.setStyle(SkPaint::kStroke_Style);
|
| 1465 | canvas->drawRRect(rrect, paint);
|
| 1466 | canvas->translate(120, 0);
|
| 1467 | canvas->drawRRect(copy, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1468 | ## |
| 1469 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1470 | #SeeAlso readFromMemory |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1471 | |
| 1472 | #Method ## |
| 1473 | |
| 1474 | # ------------------------------------------------------------------------------ |
| 1475 | |
| 1476 | #Method size_t readFromMemory(const void* buffer, size_t length) |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1477 | #In Utility |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1478 | #Line # reads Round_Rect from buffer ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1479 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1480 | Reads Round_Rect from buffer, reading kSizeInMemory bytes. |
| 1481 | Returns kSizeInMemory, bytes read if length is at least kSizeInMemory. |
| 1482 | Otherwise, returns zero. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1483 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1484 | #Param buffer memory to read from ## |
| 1485 | #Param length size of buffer ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1486 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1487 | #Return bytes read, or 0 if length is less than kSizeInMemory |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1488 | ## |
| 1489 | |
| 1490 | #Example |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1491 | #Height 110 |
| 1492 | SkVector radii[] = {{5, 5}, {10, 10}, {15, 15}, {5, 5}};
|
| 1493 | SkRRect rrect;
|
| 1494 | rrect.setRectRadii({10, 10, 110, 80}, radii);
|
| 1495 | char storage[SkRRect::kSizeInMemory];
|
| 1496 | rrect.writeToMemory(storage);
|
| 1497 | SkRRect copy;
|
| 1498 | copy.readFromMemory(storage, sizeof(storage));
|
| 1499 | SkPaint paint;
|
| 1500 | paint.setAntiAlias(true);
|
| 1501 | paint.setTextAlign(SkPaint::kCenter_Align);
|
| 1502 | canvas->drawString("rrect", 55, 100, paint);
|
| 1503 | canvas->drawString("copy", 185, 100, paint);
|
| 1504 | paint.setStyle(SkPaint::kStroke_Style);
|
| 1505 | canvas->drawRRect(rrect, paint);
|
| 1506 | canvas->translate(120, 0);
|
| 1507 | canvas->drawRRect(copy, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1508 | ## |
| 1509 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1510 | #SeeAlso writeToMemory |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1511 | |
| 1512 | #Method ## |
| 1513 | |
| 1514 | # ------------------------------------------------------------------------------ |
| 1515 | |
| 1516 | #Method bool transform(const SkMatrix& matrix, SkRRect* dst) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1517 | #In Inset_Outset_Offset |
| 1518 | #Line # scales and offsets into copy ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1519 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1520 | Transforms by Round_Rect by matrix, storing result in dst. |
| 1521 | Returns true if Round_Rect transformed can be represented by another Round_Rect. |
| 1522 | Returns false if matrix contains transformations other than scale and translate. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1523 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1524 | Asserts in debug builds if Round_Rect equals dst. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1525 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1526 | #Param matrix SkMatrix specifying the transform ## |
| 1527 | #Param dst SkRRect to store the result ## |
| 1528 | |
| 1529 | #Return true if transformation succeeded. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1530 | ## |
| 1531 | |
| 1532 | #Example |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1533 | #Height 110 |
| 1534 | SkVector radii[] = {{5, 5}, {10, 10}, {15, 15}, {5, 5}};
|
| 1535 | SkRRect rrect;
|
| 1536 | rrect.setRectRadii({10, 10, 110, 80}, radii);
|
| 1537 | SkRRect transformed;
|
| 1538 | SkMatrix matrix = SkMatrix::MakeRectToRect(rrect.rect(), {140, 30, 220, 80},
|
| 1539 | SkMatrix::kCenter_ScaleToFit);
|
| 1540 | bool success = rrect.transform(matrix, &transformed);
|
| 1541 | SkPaint paint;
|
| 1542 | paint.setAntiAlias(true);
|
| 1543 | paint.setTextAlign(SkPaint::kCenter_Align);
|
| 1544 | canvas->drawString("rrect", 55, 100, paint);
|
| 1545 | canvas->drawString(success ? "transformed" : "transform failed", 185, 100, paint);
|
| 1546 | paint.setStyle(SkPaint::kStroke_Style);
|
| 1547 | canvas->drawRRect(rrect, paint);
|
| 1548 | canvas->drawRRect(transformed, paint); |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1549 | ## |
| 1550 | |
Cary Clark | 80247e5 | 2018-07-11 16:18:41 -0400 | [diff] [blame] | 1551 | #SeeAlso SkPath::transform |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1552 | |
| 1553 | #Method ## |
| 1554 | |
| 1555 | # ------------------------------------------------------------------------------ |
| 1556 | |
| 1557 | #Method void dump(bool asHex) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1558 | #In Utility |
| 1559 | #Line # sends text representation to standard output ## |
| 1560 | Writes text representation of Round_Rect to standard output. |
| 1561 | Set asHex true to generate exact binary representations |
| 1562 | of floating point numbers. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1563 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1564 | #Param asHex true if SkScalar values are written as hexadecimal ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1565 | |
| 1566 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1567 | SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
|
| 1568 | for (bool dumpAsHex : { false, true } ) {
|
| 1569 | rrect.dump(dumpAsHex);
|
| 1570 | } |
| 1571 | #StdOut |
| 1572 | SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
|
| 1573 | const SkPoint corners[] = {
|
| 1574 | { 0, 0 },
|
| 1575 | { 0, 0 },
|
| 1576 | { 0, 0 },
|
| 1577 | { 0, 0 },
|
| 1578 | };
|
| 1579 | SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
| 1580 | SkBits2Float(0x3f2aaaab), /* 0.666667 */
|
| 1581 | SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
| 1582 | SkBits2Float(0x3f2aaaab) /* 0.666667 */);
|
| 1583 | const SkPoint corners[] = {
|
| 1584 | { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
| 1585 | { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
| 1586 | { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
| 1587 | { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
| 1588 | }; |
| 1589 | ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1590 | ## |
| 1591 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1592 | #SeeAlso dumpHex SkRect::dump SkPath::dump SkPathMeasure::dump |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1593 | |
| 1594 | #Method ## |
| 1595 | |
| 1596 | # ------------------------------------------------------------------------------ |
| 1597 | |
| 1598 | #Method void dump() const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1599 | #In Utility |
| 1600 | #Line # sends text representation using floats to standard output ## |
| 1601 | Writes text representation of Round_Rect to standard output. The representation |
| 1602 | may be directly compiled as C++ code. Floating point values are written |
| 1603 | with limited precision; it may not be possible to reconstruct original |
| 1604 | Round_Rect from output. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1605 | |
| 1606 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1607 | SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
|
| 1608 | rrect.dump();
|
| 1609 | SkRect bounds = SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
|
| 1610 | const SkPoint corners[] = {
|
| 1611 | { 0, 0 },
|
| 1612 | { 0, 0 },
|
| 1613 | { 0, 0 },
|
| 1614 | { 0, 0 },
|
| 1615 | };
|
| 1616 | SkRRect copy;
|
| 1617 | copy.setRectRadii(bounds, corners);
|
| 1618 | SkDebugf("rrect is " "%s" "equal to copy\n", rrect == copy ? "" : "not ");
|
| 1619 | #StdOut |
| 1620 | SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
|
| 1621 | const SkPoint corners[] = {
|
| 1622 | { 0, 0 },
|
| 1623 | { 0, 0 },
|
| 1624 | { 0, 0 },
|
| 1625 | { 0, 0 },
|
| 1626 | };
|
| 1627 | rrect is not equal to copy |
| 1628 | ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1629 | ## |
| 1630 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1631 | #SeeAlso dumpHex SkRect::dump SkPath::dump SkPathMeasure::dump |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1632 | |
| 1633 | #Method ## |
| 1634 | |
| 1635 | # ------------------------------------------------------------------------------ |
| 1636 | |
| 1637 | #Method void dumpHex() const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1638 | #In Utility |
| 1639 | #Line # sends text representation using hexadecimal to standard output ## |
| 1640 | Writes text representation of Round_Rect to standard output. The representation |
| 1641 | may be directly compiled as C++ code. Floating point values are written |
| 1642 | in hexadecimal to preserve their exact bit pattern. The output reconstructs the |
| 1643 | original Round_Rect. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1644 | |
| 1645 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1646 | SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
|
| 1647 | rrect.dumpHex();
|
| 1648 | SkRect bounds = SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
| 1649 | SkBits2Float(0x3f2aaaab), /* 0.666667 */
|
| 1650 | SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
| 1651 | SkBits2Float(0x3f2aaaab) /* 0.666667 */);
|
| 1652 | const SkPoint corners[] = {
|
| 1653 | { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
| 1654 | { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
| 1655 | { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
| 1656 | { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
| 1657 | };
|
| 1658 | SkRRect copy;
|
| 1659 | copy.setRectRadii(bounds, corners);
|
| 1660 | SkDebugf("rrect is " "%s" "equal to copy\n", rrect == copy ? "" : "not "); |
| 1661 | #StdOut |
| 1662 | SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
| 1663 | SkBits2Float(0x3f2aaaab), /* 0.666667 */
|
| 1664 | SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
| 1665 | SkBits2Float(0x3f2aaaab) /* 0.666667 */);
|
| 1666 | const SkPoint corners[] = {
|
| 1667 | { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
| 1668 | { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
| 1669 | { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
| 1670 | { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
| 1671 | };
|
| 1672 | rrect is equal to copy |
| 1673 | ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1674 | ## |
| 1675 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1676 | #SeeAlso dump SkRect::dumpHex SkPath::dumpHex |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1677 | |
| 1678 | #Method ## |
| 1679 | |
| 1680 | #Class SkRRect ## |
| 1681 | |
| 1682 | #Topic RRect ## |