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.
Перейти к файлу
Sergio Pedri 52ef02a7cf Merged PR 31976: Update dependencies, prepare 1.2.1-experimental2 release
This PR prepares the 1.2.1-experimental2 release:
- Update all SDK projections, CsWinRT dependencies
- Update the changelog
- Bump the version suffix to 'experimental2'

> **NOTE:** keeping WASDK at 1.6-experimental1 due to issues with the WebView2 split, we can do that as a follow up.
2024-08-07 02:30:40 +00:00
.config Merged PR 28443: Move Win2D to OneBranch pipelines 2023-11-16 14:50:01 +00:00
.pipelines Merged PR 28443: Move Win2D to OneBranch pipelines 2023-11-16 14:50:01 +00:00
build Merged PR 31976: Update dependencies, prepare 1.2.1-experimental2 release 2024-08-07 02:30:40 +00:00
eng Update the nightly WinAppSDK-based pipeline to run jobs in parallel 2023-02-03 14:46:48 -05:00
tools Merged PR 28443: Move Win2D to OneBranch pipelines 2023-11-16 14:50:01 +00:00
winrt Merged PR 31976: Update dependencies, prepare 1.2.1-experimental2 release 2024-08-07 02:30:40 +00:00
.gitattributes Create - initial gitignore and gitattributes 2014-04-28 10:34:38 -07:00
.gitignore Merged PR 16895: Update Win2D to Reunion 1.0.0-experimental1 2021-08-27 22:59:47 +00:00
.sscignore Merged PR 22672: Ignore CFS warning since the pipeline works around it 2022-09-28 17:04:34 +00:00
CHANGELOG.md Merged PR 31976: Update dependencies, prepare 1.2.1-experimental2 release 2024-08-07 02:30:40 +00:00
CONTRIBUTING.md Add ARM64 support (#722) 2019-09-06 15:30:24 -07:00
LICENSE.txt Change license from Apache 2.0 to MIT - manually update files that include handwritten license text 2015-07-06 21:37:39 -07:00
Microsoft.Graphics.Win2D.sln Merged PR 25326: Enable Managed Tests in VS Test Explorer 2023-04-17 20:50:58 +00:00
README.md Merged PR 24469: Port ICanvasImageInterop features and other new APIs from UWP branch 2023-03-10 11:08:34 +00:00
SECURITY.md Microsoft mandatory file 2022-08-31 15:23:16 +00:00
Win2D.proj Update TargetPlatformVersion to 22621, remove net5 from name of project, change nuget dependency 2023-02-21 10:52:32 -05:00
build.cmd Merged PR 20415: Update Win2D to WinAppSDK 1.0.3 2022-04-28 15:37:47 +00:00
global.json Update TargetPlatformVersion to 22621, remove net5 from name of project, change nuget dependency 2023-02-21 10:52:32 -05:00
nuget.config Merged PR 19015: Pull changes for nightly branch into master 2022-02-09 18:30:51 +00:00
runbuild.ps1 Merged PR 16988: Fix AnyCPU compilation 2021-09-08 14:44:56 +00:00
smoke.cmd Remove 8.1 support: assorted other cleanups 2018-02-23 15:25:05 -08:00

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.

Visit the DirectX Landing Page for more resources for DirectX developers.

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.