2008-12-17 15:59:43 +00:00
|
|
|
#include "SampleCode.h"
|
|
|
|
#include "SkView.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "Sk64.h"
|
|
|
|
#include "SkColorShader.h"
|
|
|
|
#include "SkEmbossMaskFilter.h"
|
|
|
|
#include "SkGradientShader.h"
|
|
|
|
#include "SkGraphics.h"
|
|
|
|
#include "SkImageDecoder.h"
|
|
|
|
#include "SkKernel33MaskFilter.h"
|
|
|
|
#include "SkPath.h"
|
|
|
|
#include "SkRandom.h"
|
|
|
|
#include "SkRegion.h"
|
|
|
|
#include "SkShader.h"
|
|
|
|
#include "SkUtils.h"
|
|
|
|
#include "SkColorPriv.h"
|
|
|
|
#include "SkColorFilter.h"
|
|
|
|
#include "SkTime.h"
|
|
|
|
#include "SkTypeface.h"
|
|
|
|
#include "SkXfermode.h"
|
|
|
|
|
2011-05-05 14:03:48 +00:00
|
|
|
class EmbossView : public SampleView {
|
2008-12-17 15:59:43 +00:00
|
|
|
SkEmbossMaskFilter::Light fLight;
|
|
|
|
public:
|
2011-05-05 14:03:48 +00:00
|
|
|
EmbossView() {
|
2008-12-17 15:59:43 +00:00
|
|
|
fLight.fDirection[0] = SK_Scalar1;
|
|
|
|
fLight.fDirection[1] = SK_Scalar1;
|
|
|
|
fLight.fDirection[2] = SK_Scalar1;
|
|
|
|
fLight.fAmbient = 128;
|
|
|
|
fLight.fSpecular = 16*2;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// overrides from SkEventSink
|
2011-05-05 14:03:48 +00:00
|
|
|
virtual bool onQuery(SkEvent* evt) {
|
|
|
|
if (SampleCode::TitleQ(*evt)) {
|
2008-12-17 15:59:43 +00:00
|
|
|
SampleCode::TitleR(evt, "Emboss");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return this->INHERITED::onQuery(evt);
|
|
|
|
}
|
|
|
|
|
2011-05-05 14:03:48 +00:00
|
|
|
virtual void onDrawContent(SkCanvas* canvas) {
|
2008-12-17 15:59:43 +00:00
|
|
|
SkPaint paint;
|
|
|
|
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
paint.setStrokeWidth(SkIntToScalar(10));
|
|
|
|
paint.setMaskFilter(new SkEmbossMaskFilter(fLight, SkIntToScalar(4)))->unref();
|
|
|
|
paint.setShader(new SkColorShader(SK_ColorBLUE))->unref();
|
|
|
|
paint.setDither(true);
|
|
|
|
|
|
|
|
canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50),
|
|
|
|
SkIntToScalar(30), paint);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2011-05-05 14:03:48 +00:00
|
|
|
typedef SampleView INHERITED;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static SkView* MyFactory() { return new EmbossView; }
|
|
|
|
static SkViewRegister reg(MyFactory);
|
|
|
|
|