Exemple #1
0
    virtual void onDrawContent(SkCanvas* canvas) {
        canvas->translate(this->width()/2, this->height()/2);

        Sk3DView    view;
        view.rotateX(fRX);
        view.rotateY(fRY);
        view.applyToCanvas(canvas);

        SkPaint paint;
        if (fShaders.count() > 0) {
            bool frontFace = view.dotWithNormal(0, 0, SK_Scalar1) < 0;
            if (frontFace != fFrontFace) {
                fFrontFace = frontFace;
                fShaderIndex = (fShaderIndex + 1) % fShaders.count();
            }

            paint.setAntiAlias(true);
            paint.setShader(fShaders[fShaderIndex]);
            paint.setFilterLevel(SkPaint::kLow_FilterLevel);
            SkRect r = { -150, -150, 150, 150 };
            canvas->drawRoundRect(r, 30, 30, paint);
        }

        fRY += SampleCode::GetAnimSecondsDelta() * 90;
        if (fRY >= SkIntToScalar(360)) {
            fRY = 0;
        }
        this->inval(NULL);
    }
static void Camera_rotate(JNIEnv* env, jobject obj, jfloat x, jfloat y, jfloat z) {
    jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
    Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
    v->rotateX(x);
    v->rotateY(y);
    v->rotateZ(z);
}
Exemple #3
0
ECode CCamera::Rotate(
    /* [in] */ Float x,
    /* [in] */ Float y,
    /* [in] */ Float z)
{
    Sk3DView* v = reinterpret_cast<Sk3DView*>(mNativeInstance);
    v->rotateX(x);
    v->rotateY(y);
    v->rotateZ(z);
    return NOERROR;
}
    virtual void onDraw(SkCanvas* canvas)
    {
        this->drawBG(canvas);

        canvas->translate(this->width()/2, this->height()/2);

        Sk3DView    view;
        view.rotateX(SkIntToScalar(fRX));
        view.rotateY(SkIntToScalar(fRY));
        view.applyToCanvas(canvas);
        
        SkPaint paint;
        SkScalar rad = SkIntToScalar(50);
        SkScalar dim = rad*2;

        if (view.dotWithNormal(0, 0, SK_Scalar1) < 0) {
            paint.setColor(SK_ColorRED);
        }
        
        paint.setAntiAlias(true);

#if 0
        SkEmbossMaskFilter::Light light;
        light.fDirection[0] = SK_Scalar1;
        light.fDirection[1] = SK_Scalar1;
        light.fDirection[2] = SK_Scalar1;
        light.fAmbient = 180;
        light.fSpecular = 16 * 2;
        paint.setMaskFilter(new SkEmbossMaskFilter(light, SkIntToScalar(4)));
#endif

        canvas->drawCircle(0, 0, rad, paint);
        canvas->drawCircle(-dim, -dim, rad, paint);
        canvas->drawCircle(-dim,  dim, rad, paint);
        canvas->drawCircle( dim, -dim, rad, paint);
        canvas->drawCircle( dim,  dim, rad, paint);
        
        fRY += 1;
        if (fRY >= 360)
            fRY = 0;
        this->inval(NULL);
    }
Exemple #5
0
    virtual void onDraw(SkCanvas* canvas) {
        this->drawBG(canvas);

        canvas->translate(this->width()/2, this->height()/2);

        Sk3DView    view;
        view.rotateX(fRX);
        view.rotateY(fRY);
        view.applyToCanvas(canvas);
        
        SkPaint paint;
        SkScalar rad = SkIntToScalar(50);
        SkScalar dim = rad*2;
        if (fShaders.count() > 0) {
            bool frontFace = view.dotWithNormal(0, 0, SK_Scalar1) < 0;
            if (frontFace != fFrontFace) {
                fFrontFace = frontFace;
                fShaderIndex = (fShaderIndex + 1) % fShaders.count();
            }
        
            paint.setAntiAlias(true);
            paint.setShader(fShaders[fShaderIndex]);
#if 0
            canvas->drawCircle(0, 0, rad, paint);
            canvas->drawCircle(-dim, -dim, rad, paint);
            canvas->drawCircle(-dim,  dim, rad, paint);
            canvas->drawCircle( dim, -dim, rad, paint);
            canvas->drawCircle( dim,  dim, rad, paint);
#else
            SkRect r = { -150, -150, 150, 150 };
            canvas->drawRoundRect(r, 30, 30, paint);
#endif
        }
        
        fRY += SampleCode::GetAnimSecondsDelta() * 90;
        if (fRY >= SkIntToScalar(360)) {
            fRY = 0;
        }
        this->inval(NULL);
    }
Exemple #6
0
    virtual void onDrawContent(SkCanvas* canvas) {
        canvas->translate(this->width()/2, this->height()/2);

        Sk3DView    view;
        view.rotateX(fRX);
        view.rotateY(fRY);
        view.applyToCanvas(canvas);

        SkPaint paint;
        if (fShaders.count() > 0) {
            bool frontFace = view.dotWithNormal(0, 0, SK_Scalar1) < 0;
            if (frontFace != fFrontFace) {
                fFrontFace = frontFace;
                fShaderIndex = (fShaderIndex + 1) % fShaders.count();
            }

            paint.setAntiAlias(true);
            paint.setShader(fShaders[fShaderIndex]);
            paint.setFilterQuality(kLow_SkFilterQuality);
            SkRect r = { -150, -150, 150, 150 };
            canvas->drawRoundRect(r, 30, 30, paint);
        }
    }
static void Camera_rotateX(JNIEnv* env, jobject obj, jfloat degrees) {
    jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
    Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
    v->rotateX(degrees);
}
Exemple #8
0
static void Camera_rotateX(JNIEnv* env, jobject obj, float degrees) {
    Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
    v->rotateX(SkFloatToScalar(degrees));
}