Draw Polygon

Polygon.png

A) As displayObject:

bool PolygonDraw::Draw(Direct2DContext* ctx, D2D1::Matrix3x2F* mtx) {
    ctx->SetStrokeStyle(1, 0, 0);
    ctx->SetFillStyle(0, 0, 1);    
ctx->lineWidth = 2; ctx->beginPath();

    ctx->moveTo(0, 0);
    ctx->lineTo(100, 0);
    ctx->lineTo(40, 100);
    ctx->lineTo(0, 70); ctx->closePath();

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

B) As state object:

    Shape* polygonShape = new Shape();

    polygonShape->graphics.setStrokeStyle(1, 0, 0);

    polygonShape->graphics.setLineWidth(2);

    polygonShape->graphics.beginPath();

    polygonShape->graphics.moveTo(0, 0);
    polygonShape->graphics.lineTo(100, 0);
    polygonShape->graphics.lineTo(40, 100);
    polygonShape->graphics.lineTo(0, 70);

polygonShape->graphics.closePath();
polygonShape->graphics.fill(); polygonShape->graphics.stroke();
_stage->addChild(polygonShape);

Last edited Mar 26, 2013 at 8:11 AM by TypeOverride, version 6

Comments

No comments yet.