2014-09-04 02:46:39 +04:00
|
|
|
# Win2D
|
2014-06-28 00:53:27 +04:00
|
|
|
|
2015-04-16 23:45:29 +03:00
|
|
|
Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics
|
|
|
|
rendering with GPU acceleration. It is available to C# and C++ developers
|
|
|
|
writing Windows apps for Windows 8.1, Windows Phone 8.1 and Windows 10. It
|
|
|
|
utilizes the power of Direct2D, and integrates seamlessly with XAML and
|
|
|
|
CoreWindow.
|
2014-07-29 21:50:27 +04:00
|
|
|
|
2015-04-17 05:49:29 +03:00
|
|
|
##### Where to get it
|
2014-11-18 04:27:43 +03:00
|
|
|
- [NuGet packages](http://www.nuget.org/packages/Win2D)
|
2015-04-17 05:49:29 +03:00
|
|
|
- [Source code](http://github.com/Microsoft/Win2D)
|
|
|
|
|
|
|
|
##### How to use it
|
2014-11-18 04:27:43 +03:00
|
|
|
- [Documentation](http://microsoft.github.io/Win2D)
|
2015-05-27 21:08:57 +03:00
|
|
|
- [Sample code](http://github.com/Microsoft/Win2D-samples) -
|
|
|
|
*also available in the Store for
|
2015-04-17 05:49:29 +03:00
|
|
|
[Windows](http://apps.microsoft.com/windows/en-us/app/win2d-example-gallery/b668cfe1-e280-4c1e-adc1-09b7981ab084) and
|
2015-05-27 07:17:32 +03:00
|
|
|
[Phone](http://www.windowsphone.com/en-us/store/app/win2d-example-gallery/8797b9cb-1443-475f-9a43-dd959de6fcc1)*
|
2015-04-17 05:49:29 +03:00
|
|
|
|
|
|
|
##### More info
|
2014-09-04 02:46:39 +04:00
|
|
|
- [Features](http://github.com/Microsoft/Win2D/wiki/Features) - *what's implemented so far*
|
|
|
|
- [Backlog](http://github.com/Microsoft/Win2D/wiki/Backlog) - *what we plan to add next*
|
|
|
|
- [Team blog](http://blogs.msdn.com/b/win2d)
|
2015-04-17 05:49:29 +03:00
|
|
|
- [Report a bug or ask a question](http://github.com/Microsoft/Win2D/issues)
|
2015-07-07 06:54:04 +03:00
|
|
|
- [License](http://opensource.org/licenses/MIT)
|
2014-09-08 08:28:05 +04:00
|
|
|
- [Contributing](http://github.com/Microsoft/Win2D/blob/master/CONTRIBUTING.md)
|
2014-08-27 21:56:08 +04:00
|
|
|
|
|
|
|
## Code Example
|
|
|
|
To give you a flavor of what the code looks like, here is a snippet of XAML:
|
|
|
|
```xml
|
2015-04-11 02:41:52 +03:00
|
|
|
xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml"
|
2014-08-27 21:56:08 +04:00
|
|
|
|
|
|
|
<Grid>
|
2014-11-18 04:27:43 +03:00
|
|
|
<canvas:CanvasControl Draw="canvasControl_Draw" ClearColor="CornflowerBlue" />
|
2014-08-27 21:56:08 +04:00
|
|
|
</Grid>
|
|
|
|
```
|
|
|
|
and C#:
|
|
|
|
```cs
|
|
|
|
void canvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
|
|
|
|
{
|
2014-09-25 21:23:18 +04:00
|
|
|
args.DrawingSession.DrawEllipse(155, 115, 80, 30, Colors.Black, 3);
|
2014-09-04 02:35:40 +04:00
|
|
|
args.DrawingSession.DrawText("Hello, world!", 100, 100, Colors.Yellow);
|
2014-08-27 21:56:08 +04:00
|
|
|
}
|
|
|
|
```
|
2014-07-29 21:50:27 +04:00
|
|
|
|
2014-11-18 04:27:43 +03:00
|
|
|
## Using Win2D
|
|
|
|
|
|
|
|
The [documentation](http://microsoft.github.io/Win2D) explains how to install Visual
|
|
|
|
Studio, add the Win2D NuGet package to your project, and get started using the API.
|
|
|
|
|
|
|
|
## Building Win2D from source
|
2014-07-29 21:50:27 +04:00
|
|
|
|
2014-11-18 04:27:43 +03:00
|
|
|
##### Clone Repository
|
2014-07-29 21:50:27 +04:00
|
|
|
- Go to 'View' -> 'Team Explorer' -> 'Local Git Repositories' -> 'Clone'
|
2014-09-04 02:46:39 +04:00
|
|
|
- Add the Win2D repository URL (https://github.com/Microsoft/Win2D.git) and hit 'Clone'
|
2014-07-29 21:50:27 +04:00
|
|
|
|
2014-11-18 04:27:43 +03:00
|
|
|
##### Build NuGet Packages
|
2015-01-28 00:28:54 +03:00
|
|
|
- If using Visual Studio 2013:
|
|
|
|
- In Windows search, type 'Visual Studio Tools', and select that folder to open it
|
|
|
|
- Launch 'Developer Command Prompt for VS2013'
|
|
|
|
- If using Visual Studio 2015:
|
|
|
|
- Launch 'MSBuild Command Prompt for VS2015'
|
2014-09-04 02:46:39 +04:00
|
|
|
- Change directory to your cloned Win2D repository and run 'build'
|
2014-07-29 21:50:27 +04:00
|
|
|
|
2014-11-18 04:27:43 +03:00
|
|
|
##### 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
|
2014-07-29 21:50:27 +04:00
|
|
|
- Click 'OK'
|
|
|
|
|
2014-11-18 04:27:43 +03:00
|
|
|
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.
|
2015-04-03 20:58:18 +03:00
|
|
|
|
2015-04-14 23:44:12 +03:00
|
|
|
If you are building with Visual Studio 2013, then the generated package is
|
2015-04-17 22:38:41 +03:00
|
|
|
called "Win2D-NoUAP". This contains everything the usual Win2D package contains
|
2015-05-12 03:07:18 +03:00
|
|
|
apart from any Universal Windows Platform binaries.
|