Microsoft introduces a new 2D graphics API for the Windows Runtime

Microsoft has announced Win2D, a Windows Runtime API that wraps Direct2D (part of DirectX), for accelerated graphics in Windows Store apps.

The new API is described here and you can download the current binary here. It is in its early stages, but already supports basic drawing, bitmap loading, some image effects, and a vector and matrix math library. Here is some sample code:

void canvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
args.DrawingSession.Clear(Colors.CornflowerBlue);
args.DrawingSession.DrawEllipse(190, 125, 140, 40, Colors.Black, 6);
args.DrawingSession.DrawText("Hello, world!", 100, 100, Colors.Yellow);
}

Although this hardly looks exciting, it is important because it enables accelerated custom drawing from languages other than C++, and without needing to learn Direct2D itself. It will be easier to make rich custom controls, or casual 2D games.

That said, there are already alternative C# wrappers for DirectX in Windows Runtime apps, such as SharpDX.

Some of the comments on the MSDN post are sceptical:

Managed DirectX and XNA were however cancelled despite the frustration from the community which in response created open source alternatives to save the projects and customers that had invested in technology Microsoft introduced.

I understand that the future is "uncertain", but is this technology something that we should dare invest in or will it see the same fate as it’s earlier incarnations?

Microsoft’s Shawn Hargreaves assures:

Win2D is absolutely not a side project or some kind of stop gap that will later be replaced by anything different.

The target here is universal apps, so not just Windows Store apps but also Windows Phone. Despite the hesitant reception for the Windows Runtime in Windows 8, it looks as if Microsoft is still committed to the platform and that it will remain centre stage in Windows vNext.