aboutsummaryrefslogtreecommitdiffhomepage
path: root/docs/SkCanvas_Reference.bmh
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2017-12-11 16:03:17 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-11 21:47:38 +0000
commit2f466242c7289b246d7ef665aa50006cfd11aa36 (patch)
treef41d3ac2559c624a132fa74e3334ccbc5cfd1ceb /docs/SkCanvas_Reference.bmh
parentbb091a08d1c60ccf3d014d94490c5b4134586ee2 (diff)
working on image and nightly housekeeping bot
Add more examples and docs for SkImage; still a ways to go. Fix bit-rotted examples. Add typedef support. Add json driver to pick files to work on; remove special-casing. Fix unordered map traversal that made md output unreliable. TBR=rmistry@google.com Docs-Preview: https://skia.org/?cl=80060 Bug: skia:6898 Change-Id: Ib8eb9fdfa5a9db61c8332e657fa2e2f4b96a665f Reviewed-on: https://skia-review.googlesource.com/80060 Reviewed-by: Cary Clark <caryclark@skia.org> Commit-Queue: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'docs/SkCanvas_Reference.bmh')
-rw-r--r--docs/SkCanvas_Reference.bmh98
1 files changed, 62 insertions, 36 deletions
diff --git a/docs/SkCanvas_Reference.bmh b/docs/SkCanvas_Reference.bmh
index b2c70f5477..8979b87581 100644
--- a/docs/SkCanvas_Reference.bmh
+++ b/docs/SkCanvas_Reference.bmh
@@ -4711,14 +4711,15 @@ void draw(SkCanvas* canvas) {
#Code
struct Lattice {
- enum Flags {...
-
- const int* fXDivs;
- const int* fYDivs;
- const Flags* fFlags;
- int fXCount;
- int fYCount;
- const SkIRect* fBounds;
+ enum RectType ...
+
+ const int* fXDivs;
+ const int* fYDivs;
+ const RectType* fRectTypes;
+ int fXCount;
+ int fYCount;
+ const SkIRect* fBounds;
+ const SkColor* fColors;
};
##
@@ -4730,17 +4731,28 @@ void draw(SkCanvas* canvas) {
The grid entries not on even columns and rows are scaled to fit the
remaining space, if any.
- #Enum Flags
+ #Enum RectType
#Code
- enum Flags : uint8_t {
- kTransparent_Flags = 1 << 0,
+ enum RectType : uint8_t {
+ kDefault = 0,
+ kTransparent,
+ kFixedColor,
};
##
- Optional setting per rectangular grid entry to make it transparent.
+ Optional setting per rectangular grid entry to make it transparent,
+ or to fill the grid entry with a color.
- #Const kTransparent_Flags 1
- Set to skip lattice rectangle by making it transparent.
+ #Const kDefault 0
+ Draws Bitmap into lattice rectangle.
+ ##
+
+ #Const kTransparent 1
+ Skips lattice rectangle by making it transparent.
+ ##
+
+ #Const kFixedColor 2
+ Draws one of fColors into lattice rectangle.
##
##
@@ -4760,14 +4772,16 @@ void draw(SkCanvas* canvas) {
grid entries.
##
- #Member const Flags* fFlags
- Optional array of Flags, one per rectangular grid entry:
+ #Member const RectType* fRectTypes
+ Optional array of fill types, one per rectangular grid entry:
array length must be
#Formula
(fXCount + 1) * (fYCount + 1)
##
.
+ Each RectType is one of: kDefault, kTransparent, kFixedColor.
+
Array entries correspond to the rectangular grid entries, ascending
left to right and then top to bottom.
##
@@ -4787,6 +4801,18 @@ void draw(SkCanvas* canvas) {
If nullptr, source bounds is dimensions of Bitmap or Image.
##
+ #Member const SkColor* fColors
+ Optional array of colors, one per rectangular grid entry.
+ Array length must be
+ #Formula
+ (fXCount + 1) * (fYCount + 1)
+ ##
+ .
+
+ Array entries correspond to the rectangular grid entries, ascending
+ left to right, then top to bottom.
+ ##
+
#Struct Lattice ##
#Method void drawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattice, const SkRect& dst,
@@ -5329,26 +5355,26 @@ Image_Filter, and Draw_Looper; apply to blob.
#Example
#Height 120
void draw(SkCanvas* canvas) {
- SkTextBlobBuilder textBlobBuilder;
- const char bunny[] = "/(^x^)\\";
- const int len = sizeof(bunny) - 1;
- uint16_t glyphs[len];
- SkPaint paint;
- paint.textToGlyphs(bunny, len, glyphs);
+ SkTextBlobBuilder textBlobBuilder;
+ const char bunny[] = "/(^x^)\\";
+ const int len = sizeof(bunny) - 1;
+ uint16_t glyphs[len];
+ SkPaint paint;
+ paint.textToGlyphs(bunny, len, glyphs);
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- int runs[] = { 3, 1, 3 };
- SkPoint textPos = { 20, 100 };
- int glyphIndex = 0;
- for (auto runLen : runs) {
- paint.setTextSize(1 == runLen ? 20 : 50);
- const SkTextBlobBuilder::RunBuffer& run =
- textBlobBuilder.allocRun(paint, runLen, textPos.fX, textPos.fY);
- memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);
- textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);
- glyphIndex += runLen;
- }
- sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
- paint.reset();
+ int runs[] = { 3, 1, 3 };
+ SkPoint textPos = { 20, 100 };
+ int glyphIndex = 0;
+ for (auto runLen : runs) {
+ paint.setTextSize(1 == runLen ? 20 : 50);
+ const SkTextBlobBuilder::RunBuffer& run =
+ textBlobBuilder.allocRun(paint, runLen, textPos.fX, textPos.fY);
+ memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);
+ textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);
+ glyphIndex += runLen;
+ }
+ sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
+ paint.reset();
canvas->drawTextBlob(blob.get(), 0, 0, paint);
}
##
@@ -5390,7 +5416,7 @@ Paint attributes related to text, like text size, have no effect on paint passed
SkPaint paint;
paint.setTextSize(50);
paint.setColor(SK_ColorRED);
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
+ paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
const SkTextBlobBuilder::RunBuffer& run =
textBlobBuilder.allocRun(paint, 1, 20, 100);
run.glyphs[0] = 20;