зеркало из https://github.com/mozilla/moz-skia.git
add debugging code for degenerate gradients (to be removed later)
git-svn-id: http://skia.googlecode.com/svn/trunk@1805 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
5f068f15cc
Коммит
13636fe4b9
|
@ -24,6 +24,40 @@
|
||||||
#include "SkImageDecoder.h"
|
#include "SkImageDecoder.h"
|
||||||
#include "SkBlurMaskFilter.h"
|
#include "SkBlurMaskFilter.h"
|
||||||
|
|
||||||
|
static void test_gradient2(SkCanvas* canvas) {
|
||||||
|
/*
|
||||||
|
ctx.fillStyle = '#f00';
|
||||||
|
ctx.fillRect(0, 0, 100, 50);
|
||||||
|
|
||||||
|
var g = ctx.createRadialGradient(-80, 25, 70, 0, 25, 150);
|
||||||
|
g.addColorStop(0, '#f00');
|
||||||
|
g.addColorStop(0.01, '#0f0');
|
||||||
|
g.addColorStop(0.99, '#0f0');
|
||||||
|
g.addColorStop(1, '#f00');
|
||||||
|
ctx.fillStyle = g;
|
||||||
|
ctx.fillRect(0, 0, 100, 50);
|
||||||
|
*/
|
||||||
|
SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorGREEN, SK_ColorRED };
|
||||||
|
SkScalar pos[] = { 0, SkFloatToScalar(0.01f), SkFloatToScalar(0.99f), SK_Scalar1 };
|
||||||
|
SkPoint c0 = { -80, 25 };
|
||||||
|
SkScalar r0 = 70;
|
||||||
|
SkPoint c1 = { 0, 25 };
|
||||||
|
SkScalar r1 = 150;
|
||||||
|
SkShader* s = SkGradientShader::CreateTwoPointRadial(c0, r0, c1, r1, colors,
|
||||||
|
pos, SK_ARRAY_COUNT(pos),
|
||||||
|
SkShader::kClamp_TileMode);
|
||||||
|
|
||||||
|
SkPaint paint;
|
||||||
|
paint.setShader(s)->unref();
|
||||||
|
|
||||||
|
canvas->drawPaint(paint);
|
||||||
|
|
||||||
|
paint.setShader(NULL);
|
||||||
|
paint.setStyle(SkPaint::kStroke_Style);
|
||||||
|
SkRect r = { 0, 0, 100, 50 };
|
||||||
|
canvas->drawRect(r, paint);
|
||||||
|
}
|
||||||
|
|
||||||
static void setNamedTypeface(SkPaint* paint, const char name[]) {
|
static void setNamedTypeface(SkPaint* paint, const char name[]) {
|
||||||
SkTypeface* face = SkTypeface::CreateFromName(name, SkTypeface::kNormal);
|
SkTypeface* face = SkTypeface::CreateFromName(name, SkTypeface::kNormal);
|
||||||
paint->setTypeface(face);
|
paint->setTypeface(face);
|
||||||
|
@ -86,6 +120,10 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void onDrawContent(SkCanvas* canvas) {
|
virtual void onDrawContent(SkCanvas* canvas) {
|
||||||
|
if (false) {
|
||||||
|
test_gradient2(canvas);
|
||||||
|
return;
|
||||||
|
}
|
||||||
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
|
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
|
||||||
|
|
||||||
const struct {
|
const struct {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче