28 sampling, cull,
paint);
34 for (
int i = 0; i <
count; ++i) {
36 matrix.setRSXform(xform[i]);
40 canvas->
drawImageRect(atlas, tex[i], tex[i].makeOffset(-tex[i].
x(), -tex[i].
y()),
55 const char*
s =
"01234567890!@#$%^&*=+<>?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
59 for (
int y = 0;
y < atlasSize;
y += cellSize) {
60 for (
int x = 0;
x < atlasSize;
x += cellSize) {
63 int index = i % strlen(
s);
65 x + half,
y + half + half/2, font,
paint,
70 return surface->makeImageSnapshot();
90 void advance(
const SkRect& bounds) {
92 if (fCenter.
fX > bounds.right()) {
94 fVelocity.
fX = -fVelocity.
fX;
95 }
else if (fCenter.
fX < bounds.left()) {
97 fVelocity.
fX = -fVelocity.
fX;
99 if (fCenter.
fY > bounds.bottom()) {
100 if (fVelocity.
fY > 0) {
101 fVelocity.
fY = -fVelocity.
fY;
103 }
else if (fCenter.
fY < bounds.top()) {
104 if (fVelocity.
fY < 0) {
105 fVelocity.
fY = -fVelocity.
fY;
121 }
else if (fAlpha < 0) {
154 for (
int y = 0;
y < kAtlasSize;
y += kCellSize) {
155 for (
int x = 0;
x < kAtlasSize;
x += kCellSize) {
158 fTex[i].
setXYWH(sx, sy, cell, cell);
160 fRec[i].fCenter.set(sx + cell/2, sy + 3*cell/4);
175 fUseColors = !fUseColors;
183 for (
int i = 0; i < N; ++i) {
185 xform[i] = fRec[i].asRSXform();
187 colors[i] =
SkColorSetARGB((
int)(fRec[i].fAlpha * 0xFF), 0xFF, 0xFF, 0xFF);
194 const SkColor* colorsPtr = fUseColors ? colors :
nullptr;
195 fProc(canvas, fAtlas.
get(), xform, fTex, colorsPtr,
N, &cull, sampling, &
paint);
199 const SkScalar border = kMaxScale * kCellSize;
215 case 'C': fDrawable->toggleUseColors();
return true;
225 bool animate(
double )
override {
return true; }
228 bool animate(
double nanos)
override {
230 fAnimatingDrawable->setSweep(angle);
void(* DrawAtlasProc)(SkCanvas *, SkImage *, const SkRSXform[], const SkRect[], const SkColor[], int, const SkRect *, const SkSamplingOptions &, const SkPaint *)
static void draw_atlas(SkCanvas *canvas, SkImage *atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, const SkRect *cull, const SkSamplingOptions &sampling, const SkPaint *paint)
static sk_sp< SkImage > make_atlas(int atlasSize, int cellSize)
static void draw_atlas_sim(SkCanvas *canvas, SkImage *atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, const SkRect *cull, const SkSamplingOptions &sampling, const SkPaint *paint)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
@ kUTF8
uses bytes to represent UTF-8 or ASCII
#define SkScalarMod(x, y)
#define SkDoubleToScalar(x)
Type::kYUV Type::kRGBA() int(0.7 *637)
SkRect onGetBounds() override
void onDraw(SkCanvas *canvas) override
DrawAtlasDrawable(DrawAtlasProc proc, const SkRect &r)
DrawAtlasSlide(const char name[], DrawAtlasProc proc)
bool onChar(SkUnichar uni) override
SkISize getDimensions() const override
void load(SkScalar winWidth, SkScalar winHeight) override
bool animate(double) override
void draw(SkCanvas *canvas) override
void drawDrawable(SkDrawable *drawable, const SkMatrix *matrix=nullptr)
@ kFast_SrcRectConstraint
sample outside bounds; faster
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
void drawAtlas(const SkImage *atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, SkBlendMode mode, const SkSamplingOptions &sampling, const SkRect *cullRect, const SkPaint *paint)
void concat(const SkMatrix &matrix)
static void Draw(SkCanvas *, const void *text, size_t size, SkTextEncoding, SkScalar x, SkScalar y, const SkFont &, const SkPaint &, Align=kLeft_Align)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static SkImageInfo MakeN32Premul(int width, int height)
constexpr float y() const
constexpr float x() const
static SkRect Make(const SkISize &size)
void setXYWH(float x, float y, float width, float height)
void outset(float dx, float dy)