55 canvas->
clear(0xFF101010);
59 for (
int x = 0;
x <
WIDTH;
x += 16) {
72 spotTarget.
fY + 70.7214f * sinAzimuth,
80 spotTarget.
fY + 50 * sinAzimuth,
100 for (
int i = 0;
i < 3;
i++) {
101 const SkIRect* cr = (
i == 1) ? &cropRect : (
i == 2) ? &fullSizeCropRect :
nullptr;
109 distantDirection,
SK_ColorWHITE, surfaceScale, kd, input, cr));
113 spotLocation, spotTarget, spotExponent1, cutoffAngleSmall,
SK_ColorWHITE,
114 surfaceScale, kd, input, cr));
119 spotLocation, spotTarget, spotExponent10, cutoffAngleNone,
SK_ColorWHITE,
120 surfaceScale, kd, input, cr));
125 spotLocation, spotTarget, spotExponent1, cutoffAngleNone,
SK_ColorWHITE,
126 surfaceScaleSmall, kd, input, cr));
131 distantDirection, greenYellow, surfaceScale, 4.f * kd, input, cr));
138 pointLocation,
SK_ColorWHITE, surfaceScale, ks, shininess, input, cr));
142 distantDirection,
SK_ColorWHITE, surfaceScale, ks, shininess, input, cr));
146 spotLocation, spotTarget, spotExponent1, cutoffAngleSmall,
SK_ColorWHITE,
147 surfaceScale, ks, shininess, input, cr));
152 spotLocation, spotTarget, spotExponent10, cutoffAngleNone,
SK_ColorWHITE,
153 surfaceScale, ks, shininess, input, cr));
158 spotLocation, spotTarget, spotExponent1, cutoffAngleNone,
SK_ColorWHITE,
159 surfaceScaleSmall, ks, shininess, input, cr));
164 distantDirection, greenYellow, surfaceScale, 4.f * ks, shininess, input, cr));
172 constexpr SkScalar kDesiredDurationSecs = 15.0f;
174 fAzimuth = kStartAzimuth +
TimeUtils::Scaled(1
e-9 * nanos, 360.0f/kDesiredDurationSecs, 360.0f);
179 inline static constexpr int kStartAzimuth = 225;
184 using INHERITED =
GM;
189DEF_GM(
return new ImageLightingGM;)
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
constexpr SkColor SK_ColorWHITE
#define SkDegreesToRadians(degrees)
#define SkScalarSin(radians)
#define SkScalarCos(radians)
sk_sp< SkImage > asImage() const
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void clipIRect(const SkIRect &irect, SkClipOp op=SkClipOp::kIntersect)
void clear(SkColor color)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
static sk_sp< SkImageFilter > PointLitDiffuse(const SkPoint3 &location, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > DistantLitSpecular(const SkPoint3 &direction, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > DistantLitDiffuse(const SkPoint3 &direction, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Offset(SkScalar dx, SkScalar dy, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > PointLitSpecular(const SkPoint3 &location, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > SpotLitDiffuse(const SkPoint3 &location, const SkPoint3 &target, SkScalar falloffExponent, SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > SpotLitSpecular(const SkPoint3 &location, const SkPoint3 &target, SkScalar falloffExponent, SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
void setColor(SkColor color)
GM(SkColor backgroundColor=SK_ColorWHITE)
void drawClippedBitmap(SkCanvas *canvas, const SkPaint &paint, int x, int y)
void onDraw(SkCanvas *canvas) override
void onOnceBeforeDraw() override
bool onAnimate(double nanos) override
SkISize getISize() override
SkString getName() const override
static float Scaled(float time, float speed, float period=0)
DEF_GM(return F(C(clipbox), 0.0f, 0.0f, {})) DEF_GM(return F(C(clipbox)
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 SkPoint3 Make(SkScalar x, SkScalar y, SkScalar z)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)