Draw Circle

Circle.png

A) As displayObject:

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

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

    ctx->lineWidth = 2;

    ctx->beginPath();
    ctx->arc(0, 0, 60, 0, M_PI*2, true);
    ctx->closePath();

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

B) As state object:

    const double PI = 3.14159265358979323846;

    Shape* circleShape = new Shape();

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

    circleShape->graphics.setLineWidth(2);

    circleShape->graphics.beginPath();
    circleShape->graphics.arc(0, 0, 60, 0, PI*2, true);
    circleShape->graphics.closePath();

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

_stage->addChild(circleShape);

Last edited Mar 26, 2013 at 2:39 AM by TypeOverride, version 11

Comments

No comments yet.