Draw Rectangle

Rectangle.png

A) As displayObject:

bool RectangleDraw::Draw(Direct2DContext* ctx, D2D1::Matrix3x2F* mtx) {
    ctx->SetStrokeStyle(1, 0, 0);
    ctx->SetFillStyle(0, 0, 1);

    ctx->lineWidth = 2;

    ctx->rect(0, 0, 150, 70);

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

B) As state object:

    Shape* rectShape= new Shape();

    rectShape->graphics.setStrokeStyle(1, 0, 0);
    rectShape->graphics.setFillStyle(0, 0, 1);

    rectShape->graphics.setLineWidth(2);

    rectShape->graphics.rect(0, 0, 150, 70);

    rectShape->graphics.fill();
    rectShape->graphics.stroke();

_stage->addChild(rectShape);

Last edited Mar 27, 2013 at 9:00 PM by TypeOverride, version 2

Comments

No comments yet.