blob: beacecb89bbd5177905588f586e10c70e46c65c1 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
reed@google.combf0001d2014-01-13 14:53:55 +00007
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "include/core/SkCanvas.h"
9#include "include/core/SkColorFilter.h"
10#include "include/core/SkColorPriv.h"
11#include "include/core/SkGraphics.h"
12#include "include/core/SkPath.h"
13#include "include/core/SkRegion.h"
14#include "include/core/SkShader.h"
15#include "include/core/SkTime.h"
16#include "include/core/SkTypeface.h"
17#include "include/effects/SkGradientShader.h"
18#include "include/utils/SkRandom.h"
19#include "samplecode/Sample.h"
20#include "src/core/SkBlurMask.h"
21#include "src/effects/SkEmbossMaskFilter.h"
22#include "src/utils/SkUTF.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000023
Ben Wagnerb2c4ea62018-08-08 11:36:17 -040024class EmbossView : public Sample {
reed@android.com8a1c16f2008-12-17 15:59:43 +000025 SkEmbossMaskFilter::Light fLight;
26public:
rmistry@google.comae933ce2012-08-23 18:19:56 +000027 EmbossView() {
reed@android.com8a1c16f2008-12-17 15:59:43 +000028 fLight.fDirection[0] = SK_Scalar1;
29 fLight.fDirection[1] = SK_Scalar1;
30 fLight.fDirection[2] = SK_Scalar1;
31 fLight.fAmbient = 128;
32 fLight.fSpecular = 16*2;
33 }
rmistry@google.comae933ce2012-08-23 18:19:56 +000034
reed@android.com8a1c16f2008-12-17 15:59:43 +000035protected:
Hal Canary8a027312019-07-03 10:55:44 -040036 virtual SkString name() { return SkString("Emboss"); }
reed@android.com8a1c16f2008-12-17 15:59:43 +000037
reed@google.com961ddb02011-05-05 14:03:48 +000038 virtual void onDrawContent(SkCanvas* canvas) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000039 SkPaint paint;
rmistry@google.comae933ce2012-08-23 18:19:56 +000040
reed@android.com8a1c16f2008-12-17 15:59:43 +000041 paint.setAntiAlias(true);
42 paint.setStyle(SkPaint::kStroke_Style);
43 paint.setStrokeWidth(SkIntToScalar(10));
reedefdfd512016-04-04 10:02:58 -070044 paint.setMaskFilter(SkEmbossMaskFilter::Make(SkBlurMask::ConvertRadiusToSigma(4), fLight));
Mike Reedc8bea7d2019-04-09 13:55:36 -040045 paint.setShader(SkShaders::Color(SK_ColorBLUE));
reed@android.com8a1c16f2008-12-17 15:59:43 +000046 paint.setDither(true);
rmistry@google.comae933ce2012-08-23 18:19:56 +000047
reed@android.com8a1c16f2008-12-17 15:59:43 +000048 canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50),
49 SkIntToScalar(30), paint);
50 }
rmistry@google.comae933ce2012-08-23 18:19:56 +000051
reed@android.com8a1c16f2008-12-17 15:59:43 +000052private:
53
Ben Wagnerb2c4ea62018-08-08 11:36:17 -040054 typedef Sample INHERITED;
reed@android.com8a1c16f2008-12-17 15:59:43 +000055};
56
57//////////////////////////////////////////////////////////////////////////////
58
Ben Wagnerb2c4ea62018-08-08 11:36:17 -040059DEF_SAMPLE( return new EmbossView(); )