Draw Rectangle with linear gradient style

Gradient_linear.png

A) As displayObject:

bool LinearGradientDraw::Draw(Direct2DContext* ctx, D2D1::Matrix3x2F* mtx) {
    ctx->rect(0, 0, 150, 70);
   
    CanvasGradient canvasGradient = ctx->createLinearGradient(0, 0, 150, 0);
    canvasGradient.addColorStop(0, Color::BLUE);
    canvasGradient.addColorStop(1, Color::GREEN);
    canvasGradient.addColorStop(0.5, Color::RED);
   
    ctx->SetFillStyle(canvasGradient);

    CanvasGradient canvasGradient2 = ctx->createLinearGradient(0, 0, 150, 0);
    canvasGradient2.addColorStop(0, Color::RED);
    canvasGradient2.addColorStop(1, Color::BLUE);
   
    ctx->SetStrokeStyle(canvasGradient2);

    ctx->fill();
    ctx->stroke(); return true; }
LinearGradientDraw* linearGradientDraw = new LinearGradientDraw();
_stage->addChild(linearGradientDraw);

B) As state object:

    Not supported yet

Last edited Mar 27, 2013 at 8:04 PM by TypeOverride, version 3

Comments

No comments yet.