| Index: gm/lighting.cpp
|
| diff --git a/gm/lighting.cpp b/gm/lighting.cpp
|
| index e0a317d3287ddd73ad05125f6011d79ebe890ee2..4dac5a9df8e1b0e9757faacb7b8556111b727de4 100644
|
| --- a/gm/lighting.cpp
|
| +++ b/gm/lighting.cpp
|
| @@ -17,7 +17,8 @@ namespace skiagm {
|
|
|
| class ImageLightingGM : public GM {
|
| public:
|
| - ImageLightingGM() {
|
| + ImageLightingGM()
|
| + : fAzimuth(225) {
|
| this->setBGColor(0xFF000000);
|
| }
|
|
|
| @@ -57,19 +58,25 @@ protected:
|
| canvas->restore();
|
| }
|
| }
|
| - SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10));
|
| - SkScalar azimuthRad = SkDegreesToRadians(SkIntToScalar(225));
|
| + SkScalar cosAzimuth;
|
| + SkScalar sinAzimuth = SkScalarSinCos(SkDegreesToRadians(fAzimuth), &cosAzimuth);
|
| +
|
| + SkPoint3 spotTarget = SkPoint3::Make(SkIntToScalar(40), SkIntToScalar(40), 0);
|
| + SkPoint3 spotLocation = SkPoint3::Make(spotTarget.fX + 70.7214f * cosAzimuth,
|
| + spotTarget.fY + 70.7214f * sinAzimuth,
|
| + spotTarget.fZ + SkIntToScalar(20));
|
| + SkScalar spotExponent = SK_Scalar1;
|
| +
|
| + SkPoint3 pointLocation = SkPoint3::Make(spotTarget.fX + 50 * cosAzimuth,
|
| + spotTarget.fY + 50 * sinAzimuth,
|
| + SkIntToScalar(10));
|
| SkScalar elevationRad = SkDegreesToRadians(SkIntToScalar(5));
|
| - SkPoint3 distantDirection = SkPoint3::Make(SkScalarMul(SkScalarCos(azimuthRad),
|
| +
|
| + SkPoint3 distantDirection = SkPoint3::Make(SkScalarMul(cosAzimuth,
|
| SkScalarCos(elevationRad)),
|
| - SkScalarMul(SkScalarSin(azimuthRad),
|
| + SkScalarMul(sinAzimuth,
|
| SkScalarCos(elevationRad)),
|
| SkScalarSin(elevationRad));
|
| - SkPoint3 spotLocation = SkPoint3::Make(SkIntToScalar(-10),
|
| - SkIntToScalar(-10),
|
| - SkIntToScalar(20));
|
| - SkPoint3 spotTarget = SkPoint3::Make(SkIntToScalar(40), SkIntToScalar(40), 0);
|
| - SkScalar spotExponent = SK_Scalar1;
|
| SkScalar cutoffAngle = SkIntToScalar(15);
|
| SkScalar kd = SkIntToScalar(2);
|
| SkScalar ks = SkIntToScalar(1);
|
| @@ -149,8 +156,14 @@ protected:
|
| }
|
| }
|
|
|
| + bool onAnimate(const SkAnimTimer& timer) override {
|
| + fAzimuth = (fAzimuth + 2) % 360;
|
| + return true;
|
| + }
|
| +
|
| private:
|
| SkBitmap fBitmap;
|
| + int fAzimuth;
|
|
|
| typedef GM INHERITED;
|
| };
|
|
|