This project is read-only.

Currently the following API are available:
- geometries, brushes, bitmap, stroke style, text format, text layout, transforms

(Missing, from the top of my head, would be 2d effects, glyph run and lots of DWrite)


When drawing a scene (whether D2D or D3D), for performance reason, one should initialize all items first and just call the draw primitives while rendering.

For example lets create a few geometry and brushes

public MyD2DScene()
    bImage = new BitmapBrush { Bitmap = new Bitmap(), };

    bYRB = new LinearGradientBrush
        StartPoint = new Point(100, 100),
        EndPoint = new Point(800, 800),
        GradientStops = new []
            new GradientStop { position = 0, color = Colors.Yellow },
            new GradientStop { position = 0.4f, color = Colors.Red },
            new GradientStop { position = 1, color = Colors.Blue},

    gPath = new PathGeometry();
    using (var sink = gPath.Open())
        sink.BeginFigure(new Point(), FIGURE_BEGIN.FILLED);
        sink.AddLines(new[] {
            new Point(25, 200),
            new Point(275, 175),
            new Point(50, 30),


In that scene snippet I created an image brush from a resource image, a gradient brush and a simple path geometry.


Now I can just render all my items with just few drawing command, like so (for the geometry):

public void Render(DXContext ctxt)
    var g = new D2DGraphics(ctxt);

    g.Transform = DXMath.translate2d(pSkewedRect);
    g.FillGeometry(gPath, bImage);
    g.DrawGeometry(gPath, bYRB, 12, sDash);



Finally the sample Sample_D2D in the source code is good place to explore D2D in action

Last edited Feb 7, 2013 at 2:57 PM by lloyd, version 3


No comments yet.