diff options
author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-09-22 20:14:42 +0000 |
---|---|---|
committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-09-22 20:14:42 +0000 |
commit | 8e2af7eb8979ddd97bfd1615ccc173e66fe902d6 (patch) | |
tree | 8cc64592b1a5c8a339a621e7cc8431e261a28057 | |
parent | b53ebeabf0d5d8ce0d143f4086f395d677448c89 (diff) |
update sample to use new two-point-radial gradients from senorblanco!!!
git-svn-id: http://skia.googlecode.com/svn/trunk@363 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | samplecode/SampleGradients.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/samplecode/SampleGradients.cpp b/samplecode/SampleGradients.cpp index dff96baad7..f3705bcfd4 100644 --- a/samplecode/SampleGradients.cpp +++ b/samplecode/SampleGradients.cpp @@ -81,10 +81,23 @@ static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, data.fPos, data.fCount, mapper); } +static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data, + SkShader::TileMode tm, SkUnitMapper* mapper) { + SkPoint center0, center1; + center0.set(SkScalarAve(pts[0].fX, pts[1].fX), + SkScalarAve(pts[0].fY, pts[1].fY)); + center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), + SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); + return SkGradientShader::CreateTwoPointRadial( + center1, (pts[1].fX - pts[0].fX) / 7, + center0, (pts[1].fX - pts[0].fX) / 2, + data.fColors, data.fPos, data.fCount, tm, mapper); +} + typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm, SkUnitMapper* mapper); static const GradMaker gGradMakers[] = { - MakeLinear, MakeRadial, MakeSweep + MakeLinear, MakeRadial, MakeSweep, Make2Radial }; /////////////////////////////////////////////////////////////////////////////// @@ -121,7 +134,7 @@ protected: paint.setDither(true); canvas->save(); - canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); + canvas->translate(SkIntToScalar(20), SkIntToScalar(10)); for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) { canvas->save(); for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) { @@ -137,7 +150,7 @@ protected: canvas->restore(); canvas->translate(0, SkIntToScalar(370)); - test_alphagradients(canvas); + // test_alphagradients(canvas); } private: |