aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/SampleAndroidShadows.cpp
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2017-01-25 09:39:46 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-25 15:29:07 +0000
commitbce7496d7dd9131cc7121389a55f6d512ee7661e (patch)
tree123c8568e919e09db600d21aae858ef09bfe6327 /samplecode/SampleAndroidShadows.cpp
parentb92234a3210bce532f103d71002f4e04d336a182 (diff)
Add geometric implementation for ambient shadows
Original: https://skia-review.googlesource.com/7273 BUG=skia:6119 Change-Id: Ie7debd7727768f55dafad922a2b8b9fd3a638fda Reviewed-on: https://skia-review.googlesource.com/7500 Commit-Queue: Jim Van Verth <jvanverth@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'samplecode/SampleAndroidShadows.cpp')
-rw-r--r--samplecode/SampleAndroidShadows.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/samplecode/SampleAndroidShadows.cpp b/samplecode/SampleAndroidShadows.cpp
index d9e513b5c4..8f2859282b 100644
--- a/samplecode/SampleAndroidShadows.cpp
+++ b/samplecode/SampleAndroidShadows.cpp
@@ -25,6 +25,8 @@ class ShadowsView : public SampleView {
SkPath fRectPath;
SkPath fRRPath;
SkPath fCirclePath;
+ SkPath fFunkyRRPath;
+ SkPath fCubicPath;
SkPoint3 fLightPos;
bool fShowAmbient;
@@ -46,6 +48,13 @@ protected:
fCirclePath.addCircle(0, 0, 50);
fRectPath.addRect(SkRect::MakeXYWH(-100, -50, 200, 100));
fRRPath.addRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(-100, -50, 200, 100), 4, 4));
+ fFunkyRRPath.addRoundRect(SkRect::MakeXYWH(-50, -50, SK_Scalar1 * 100, SK_Scalar1 * 100),
+ 40 * SK_Scalar1, 20 * SK_Scalar1,
+ SkPath::kCW_Direction);
+ fCubicPath.cubicTo(100 * SK_Scalar1, 50 * SK_Scalar1,
+ 20 * SK_Scalar1, 100 * SK_Scalar1,
+ 0 * SK_Scalar1, 0 * SK_Scalar1);
+
fLightPos = SkPoint3::Make(-700, -700, 2800);
}
@@ -431,20 +440,20 @@ protected:
canvas->translate(200, 90);
lightPos.fX += 200;
lightPos.fY += 90;
- this->drawShadowedPath(canvas, fRectPath, 2, paint, kAmbientAlpha,
+ this->drawShadowedPath(canvas, fRRPath, 2, paint, kAmbientAlpha,
lightPos, kLightWidth, kSpotAlpha);
paint.setColor(SK_ColorRED);
canvas->translate(250, 0);
lightPos.fX += 250;
- this->drawShadowedPath(canvas, fRRPath, 4, paint, kAmbientAlpha,
+ this->drawShadowedPath(canvas, fRectPath, 4, paint, kAmbientAlpha,
lightPos, kLightWidth, kSpotAlpha);
paint.setColor(SK_ColorBLUE);
canvas->translate(-250, 110);
lightPos.fX -= 250;
lightPos.fY += 110;
- this->drawShadowedPath(canvas, fCirclePath, 8, paint, 0.0f,
+ this->drawShadowedPath(canvas, fCirclePath, 8, paint, 0,
lightPos, kLightWidth, 0.5f);
paint.setColor(SK_ColorGREEN);
@@ -452,6 +461,19 @@ protected:
lightPos.fX += 250;
this->drawShadowedPath(canvas, fRRPath, 64, paint, kAmbientAlpha,
lightPos, kLightWidth, kSpotAlpha);
+
+ paint.setColor(SK_ColorYELLOW);
+ canvas->translate(-250, 110);
+ lightPos.fX -= 250;
+ lightPos.fY += 110;
+ this->drawShadowedPath(canvas, fFunkyRRPath, 8, paint, kAmbientAlpha,
+ lightPos, kLightWidth, kSpotAlpha);
+
+ paint.setColor(SK_ColorCYAN);
+ canvas->translate(250, 0);
+ lightPos.fX += 250;
+ this->drawShadowedPath(canvas, fCubicPath, 16, paint, kAmbientAlpha,
+ lightPos, kLightWidth, kSpotAlpha);
}
protected: