1 /*
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  */
7 
8 #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"
23 
24 class EmbossView : public Sample {
25     SkEmbossMaskFilter::Light   fLight;
26 public:
EmbossView()27     EmbossView() {
28         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     }
34 
35 protected:
name()36     SkString name() override { return SkString("Emboss"); }
37 
onDrawContent(SkCanvas * canvas)38     void onDrawContent(SkCanvas* canvas) override {
39         SkPaint paint;
40 
41         paint.setAntiAlias(true);
42         paint.setStyle(SkPaint::kStroke_Style);
43         paint.setStrokeWidth(SkIntToScalar(10));
44         paint.setMaskFilter(SkEmbossMaskFilter::Make(SkBlurMask::ConvertRadiusToSigma(4), fLight));
45         paint.setShader(SkShaders::Color(SK_ColorBLUE));
46         paint.setDither(true);
47 
48         canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50),
49                            SkIntToScalar(30), paint);
50     }
51 
52 private:
53 
54     using INHERITED = Sample;
55 };
56 
57 //////////////////////////////////////////////////////////////////////////////
58 
59 DEF_SAMPLE( return new EmbossView(); )
60