Skip to content

Commit 2dc7a95

Browse files
initial push (#3598)
* initial push * initial push * initial push * initial push
1 parent 548a77f commit 2dc7a95

File tree

4 files changed

+116
-1
lines changed

4 files changed

+116
-1
lines changed

hub/apps/develop/graphics.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
title: Graphics
33
description: This article provides an index of development features that are related to scenarios involving graphics in Windows apps.
44
ms.topic: article
5-
ms.date: 05/11/2021
5+
ms.date: 05/25/2023
66
keywords:
77
---
88

99
# Graphics
1010

1111
This article provides an index of development features that are related to scenarios involving graphics in Windows apps.
1212

13+
## Win2D
14+
15+
[Win2D](/graphics/win2d.md) is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration.
16+
1317
## Windows App SDK features
1418

1519
The [Windows App SDK](../windows-app-sdk/index.md) provides the following features related to graphics scenarios for Windows 10 and later OS releases.
@@ -18,6 +22,7 @@ The [Windows App SDK](../windows-app-sdk/index.md) provides the following featur
1822
|---------|-------------|
1923
| [Render text with DWriteCore](../windows-app-sdk/dwritecore.md) | Use the C++/COM APIs in the [DWriteCore headers](/windows/windows-app-sdk/api/win32/_dwritecore/) of the Windows App SDK to render text using a device-independent text layout system, high quality sub-pixel Microsoft ClearType text rendering, hardware-accelerated text, multi-format text, wide language support, and much more. |
2024

25+
2126
## Windows OS features
2227

2328
Windows 10 and later OS releases provide a wide variety of APIs related to graphics scenarios for apps. These features are available via a combination of WinRT and Win32 (C++ and COM) APIs provided by the [Windows SDK](https://developer.microsoft.com/windows/downloads/windows-sdk).
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: Hello Win2D World
3+
description: Display 'Hello world' using Win2D.
4+
ms.date: 05/25/2023
5+
ms.topic: article
6+
keywords: windows 10, windows 11, windows app sdk, winui, windows ui, graphics, games
7+
ms.localizationpriority: medium
8+
---
9+
10+
# Hello Win2D World
11+
12+
Launch Visual Studio, and create a new project.
13+
14+
Add a CanvasControl to your XAML page to host the Win2D view.
15+
16+
* Double-click on MainWindow.xaml in Solution Explorer to open the XAML editor
17+
* Add the **Microsoft.Graphics.Canvas.UI.Xaml** namespace next to the existing xmlns statements:
18+
19+
```xmls
20+
xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml"
21+
```
22+
23+
Next, add a CanvasControl inside the existing Grid control:
24+
25+
```xmls
26+
<Grid>
27+
<canvas:CanvasControl Draw="CanvasControl_Draw" ClearColor="CornflowerBlue"/>
28+
</Grid>
29+
```
30+
31+
Now add some Win2D drawing code. Edit **MainWindow.xaml.cs**, and add:
32+
33+
34+
```cs
35+
using Microsoft.UI;
36+
using Microsoft.UI.Xaml.Controls;
37+
using Microsoft.Graphics.Canvas.UI.Xaml;
38+
39+
public sealed partial class MainWindow : Window
40+
{
41+
public MainWindow()
42+
{
43+
this.InitializeComponent();
44+
}
45+
46+
void CanvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
47+
{
48+
args.DrawingSession.DrawEllipse(155, 115, 80, 30, Colors.Black, 3);
49+
args.DrawingSession.DrawText("Hello, Win2D world!", 100, 100, Colors.Yellow);
50+
}
51+
}
52+
```
53+
54+
Press **F5** to launch and run the project.
55+
56+
## See Also
57+
58+
* Win2D [Quick start](https://microsoft.github.io/Win2D/WinUI3/html/QuickStart.htm)

hub/apps/develop/win2d/index.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: Win2D
3+
description: Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration.
4+
ms.date: 05/25/2023
5+
ms.topic: article
6+
keywords: windows 10, windows 11, windows app sdk, winui, windows ui, graphics, games
7+
ms.localizationpriority: medium
8+
---
9+
10+
# Win2D
11+
12+
> [!NOTE]
13+
> Win2D on WinUI 3 is a work in progress. Some features are not supported, and some of the documentation still points to older WinUI2 concepts and classes. For information on using Win2D with UWP apps, see the [Win2D UWP Documentation](https://microsoft.github.io/Win2D/WinUI2/html/Introduction.htm) on GitHub.
14+
15+
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.
16+
17+
It's ideal for creating simple games, displays such as charts, and other simple 2D graphics.
18+
19+
## Get Started
20+
21+
Win2D is available as a NuGet package, or as source code [on GitHub](https://github.com/microsoft/Win2D).
22+
23+
### Install Win2D
24+
25+
Add the Win2D NuGet package to your WinUI 3 app:
26+
27+
* From within Visual Studio, go to **Tools**, **NuGet Package Manager**, **Manage NuGet Packages for Solution..**
28+
* Type **Win2D** into the **Search Online** box, and hit **Enter**.
29+
* Select the **Microsoft.Graphics.Win2D** package and click **Install**, then **OK**.
30+
* Accept the license agreement.
31+
* Click **Close**.
32+
33+
Next, visit [Hello Win2D World](hellowin2dworld.md) or the [Quick start](https://microsoft.github.io/Win2D/WinUI3/html/QuickStart.htm) to learn about creating a simple app.
34+
35+
## Reference
36+
37+
The [Win2D APIs](https://microsoft.github.io/Win2D/WinUI3/html/APIReference.htm).
38+
39+
## Articles
40+
41+
A list of useful [Win2D topics](https://microsoft.github.io/Win2D/WinUI3/html/Articles.htm).
42+
43+
## See Also
44+
45+
Win2D [on GitHub](https://github.com/microsoft/Win2D)

hub/apps/toc.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,13 @@ items:
356356
href: windows-app-sdk/composition.md
357357
- name: Render text with DWriteCore
358358
href: windows-app-sdk/dwritecore.md
359+
- name: Win2D
360+
items:
361+
- name: "Overview of Win2D"
362+
href: develop/win2d/index.md
363+
- name: "Hello Win2D World"
364+
href: develop/win2d/hellowin2dworld.md
365+
359366
- name: Data and files
360367
items:
361368
- name: App resources

0 commit comments

Comments
 (0)