Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration. It is available to C#, C++ and VB developers writing apps for the Windows Universal Platform (UWP). It utilizes the power of Direct2D, and integrates seamlessly with XAML and CoreWindow.
Перейти к файлу
Ian Blaauw 5047f60851 Merged PR 16971: Build streamlining for WindowsAppSdk + tooling
This PR:
- Makes it much easier to update the WindowsAppSdk, with the version number being much more consolidated
  - This also has the bonus of making the .vcxproj files way more readable
- Updates the code checker to ignore vscode files and powershell scripts
- Adds a `runbuilds.ps1` script that mimics build.cmd, but adds hooks to customize what actually gets built
2021-09-07 18:59:14 +00:00
build Merged PR 16971: Build streamlining for WindowsAppSdk + tooling 2021-09-07 18:59:14 +00:00
tools Merged PR 16971: Build streamlining for WindowsAppSdk + tooling 2021-09-07 18:59:14 +00:00
winrt Merged PR 16971: Build streamlining for WindowsAppSdk + tooling 2021-09-07 18:59:14 +00:00
.gitattributes
.gitignore Merged PR 16895: Update Win2D to Reunion 1.0.0-experimental1 2021-08-27 22:59:47 +00:00
CHANGELOG.md Update Changelog 0.8.2.23 2021-08-17 16:04:20 -07:00
CONTRIBUTING.md Add ARM64 support (#722) 2019-09-06 15:30:24 -07:00
LICENSE.txt
Microsoft.Graphics.Win2D.sln Updated Win2D to ProjectReunion.0.5.0 2021-04-01 09:38:43 -07:00
README.md Merged PR 16895: Update Win2D to Reunion 1.0.0-experimental1 2021-08-27 22:59:47 +00:00
Win2D.proj Merged PR 16895: Update Win2D to Reunion 1.0.0-experimental1 2021-08-27 22:59:47 +00:00
build.cmd Updated Win2D to ProjectReunion.0.5.0 2021-04-01 09:38:43 -07:00
global.json Merged PR 15776: Moved Win2D to Reunion 0.5.7 2021-05-24 22:40:43 +00:00
nuget.config Updated Win2D to ProjectReunion.0.5.0 2021-04-01 09:38:43 -07:00
runbuild.ps1 Merged PR 16971: Build streamlining for WindowsAppSdk + tooling 2021-09-07 18:59:14 +00:00
smoke.cmd

README.md

Transitioning Win2D to Reunion is In-Progress

Moving Win2D over to WindowsAppSdk and WinUI3 is a work in progress, and some features such as CanvasAnimatedControl have partial or no support.

Win2D

Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration. It is available to C#, C++ and VB developers writing apps for WinUI3. It utilizes the power of Direct2D, and integrates seamlessly with XAML.

Where to get it
How to use it
More info

Code Example

To give you a flavor of what the code looks like, here is a snippet of XAML:

xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml"

<Grid>
    <canvas:CanvasControl Draw="canvasControl_Draw" ClearColor="CornflowerBlue" />
</Grid>

and C#:

void canvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
    args.DrawingSession.DrawEllipse(155, 115, 80, 30, Colors.Black, 3);
    args.DrawingSession.DrawText("Hello, world!", 100, 100, Colors.Yellow);
}

or C++/CX:

void MainPage::CanvasControl_Draw(CanvasControl^ sender, CanvasDrawEventArgs^ args)
{
    args->DrawingSession->DrawEllipse(155, 115, 80, 30, Colors::Black, 3);
    args->DrawingSession->DrawText("Hello, world!", 100, 100, Colors::Yellow);
}

or C++/WinRT:

void MainPage::CanvasControl_Draw(CanvasControl const& sender, CanvasDrawEventArgs const& args)
{
    args.DrawingSession().DrawEllipse(155, 115, 80, 30, Colors::Black(), 3);
    args.DrawingSession().DrawText(L"Hello, world!", 100, 100, Colors::Yellow());
}

or VB:

Sub canvasControl_Draw(sender As CanvasControl, args As CanvasDrawEventArgs)
    args.DrawingSession.DrawEllipse(155, 115, 80, 30, Colors.Black, 3)
    args.DrawingSession.DrawText("Hello, world!", 100, 100, Colors.Yellow)
End Sub

Using Win2D

The documentation explains how to install Visual Studio, add the Win2D NuGet package to your project, and get started using the API.

Building Win2D from source

Requirements
  • Visual Studio 2019 16.9 with Tools for Universal Windows Apps 15.0.27428.01 and Windows SDK 18362
Clone Repository
Build NuGet Packages
  • Launch 'Developer Command Prompt for VS2019'
  • Change directory to your cloned Win2D repository and run 'build'
Point Visual Studio at the resulting 'bin' directory
  • In Visual Studio, go to 'Tools' -> 'NuGet Package Manager' -> 'Package Manager Settings'
  • Choose 'Package Sources'
  • Click the '+' button to add a new source
  • Set 'Name' to 'Win2D' (or a name of your choosing)
  • Set 'Source' to the full path to the 'bin' directory (inside your cloned Win2D repository)
  • Click the 'Update' button
  • Click 'OK'

Locally built versions of Win2D are marked as prerelease, so you must change the 'Stable Only' setting to 'Include Prerelease' when adding them to your project.


This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.