35 const char* str =
"The quick brown fox jumped over the lazy dog.";
53 canvas->saveLayer(
nullptr, &filterPaint);
59#define WIDTH_HEIGHT 256
93 std::move(imageSource), &cropRect));
95 canvas->saveLayer(
nullptr, &filterPaint);
114 this->drawRow(canvas, 16.f);
116 this->drawRow(canvas, 0.f);
129 float width,
float borderInset = 0.f) {
134 paint.setAntiAlias(
true);
137 rect.inset(borderInset, borderInset);
147 SkRect widgetBounds = {16.f, 24.f, 220.f, 248.f};
148 widgetBounds.
offset(fX, fY);
150 constexpr float kZoomAmount = 2.5f;
153 constexpr SkRect kOutBounds = {0.f, 0.f, 256.f, 256.f};
158 SkRect clippedWidget = widgetBounds;
162 zoomCenter = zoomCenter * (1.f - 1.f / kZoomAmount);
163 SkRect srcRect = {clippedWidget.
fLeft / kZoomAmount + zoomCenter.
fX,
164 clippedWidget.
fTop / kZoomAmount + zoomCenter.
fY,
165 clippedWidget.
fRight / kZoomAmount + zoomCenter.
fX,
166 clippedWidget.
fBottom / kZoomAmount + zoomCenter.
fY};
178 canvas->
saveLayer({
nullptr,
nullptr, magnifier.
get(), 0});
193 paint.setImageFilter(magnifier);
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorBLACK
sk_sp< T > sk_ref_sp(T *obj)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
void onDraw(SkCanvas *canvas) override
SkString getName() const override
bool onAnimate(double nanos) override
SkISize getISize() override
int saveLayer(const SkRect *bounds, const SkPaint *paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void translate(SkScalar dx, SkScalar dy)
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
void clear(SkColor color)
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
static sk_sp< SkImageFilter > Magnifier(const SkRect &lensBounds, SkScalar zoomAmount, SkScalar inset, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
void setImageFilter(sk_sp< SkImageFilter > imageFilter)
@ kStroke_Style
set to stroke geometry
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
SkScalar nextRangeScalar(SkScalar min, SkScalar max)
uint32_t nextULessThan(uint32_t count)
uint32_t nextBits(unsigned bitCount)
static void draw_content(SkCanvas *canvas, float maxTextSize, int count)
DEF_SIMPLE_GM_BG(imagemagnifier, canvas, WIDTH, HEIGHT, SK_ColorBLACK)
static sk_sp< SkImage > make_img()
sk_sp< SkBlender > blender SkRect rect
static float SineWave(double time, float periodInSecs, float phaseInSecs, float min, float max)
font
Font Metadata and Metrics.
static SkRect inset(const SkRect &r)
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo MakeS32(int width, int height, SkAlphaType at)
SkScalar fBottom
larger y-axis bounds
bool intersect(const SkRect &r)
SkScalar fLeft
smaller x-axis bounds
SkScalar fRight
larger x-axis bounds
void offset(float dx, float dy)
constexpr SkPoint center() const
static constexpr SkRect MakeWH(float w, float h)
SkScalar fTop
smaller y-axis bounds