Draw Line

Line.png

A) As displayObject:

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

    ctx->lineWidth = 2;

    ctx->beginPath();

    ctx->moveTo(0, 0);
    ctx->lineTo(100, 0);
    ctx->lineTo(40, 100);
    ctx->lineTo(0, 70); ctx->stroke(); return true; }
LineDraw* lineDraw = new LineDraw();
_stage->addChild(lineDraw);

B) As state object:

    Shape* lineShape = new Shape();

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

    lineShape->graphics.setLineWidth(2);

    lineShape->graphics.beginPath();

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

    lineShape->graphics.stroke();

    _stage->addChild(lineShape);

Last edited Mar 26, 2013 at 7:07 AM by TypeOverride, version 12

Comments

No comments yet.