Code Monkey home page Code Monkey logo

Comments (9)

Perecli avatar Perecli commented on May 17, 2024 2

I hope your team considers adding a method to draw these type of vector XAML objects. Its a perfect candidate for your API since it is the only retained graphics library akin to the WPF version.

from windowscompositionsamples.

CrimsonArc avatar CrimsonArc commented on May 17, 2024 1

@themoretheless
That method you mentioned is not equal to WPF DrawingImage, by use WPF DrawingImage, you can set it as Image control's source, and then change the Image control's pixel size to scale your vector image to any pixel size you want. This is awesome for vector image scaling scenarios. But UWP can't do this.

from windowscompositionsamples.

pgills avatar pgills commented on May 17, 2024

Currently, there is no support for the XAML vector object (I think this is what you are referring to: https://msdn.microsoft.com/en-us/library/cc294508.aspx) using the Windows.UI.Composition API set.

from windowscompositionsamples.

Perecli avatar Perecli commented on May 17, 2024

I have a large WPF desktop app that I want to convert to UWP. All the artwork (which there is a lot of) was built in Expression Design and exported as XAML vector drawings which are imported as resources. So how do you work with vector drawings in UWP?

from windowscompositionsamples.

Perecli avatar Perecli commented on May 17, 2024

So what is the SpriteVisual's CompositionDrawingImage? Isn't that for XAML vector drawings?

from windowscompositionsamples.

pgills avatar pgills commented on May 17, 2024

SpriteVisual exposes a CompositionBrush via the Brush property. Examples of some brushes available are:

  • CompositionColorBrush which is used for solid colors
  • CompositionEffectBrush which is used for effects
  • CompositionSurfaceBrush which is used for surfaces

Currently, Windows.UI.Composition does not have a CompositionDrawingImage type.

The CompositionDrawingSurface type is leveraged for rendering content like bitmaps, not XAML vector objects.

For truly custom rendered content you can leverage Win2D and CompositionDrawingSurface. Link to Win2D sample: here

However, I don't believe that this addresses the question you asking, which is whether or not you can leverage vector objects exported from Expression Design in a UWP application?

I'm not that familiar with the types and format that Expression Design uses during export to answer your specific question; however, if those types are something like Windows.UI.Xaml.Shapes it might be possible to use them together with a Windows.UI.Xaml.Controls.Canvas in a UWP.

from windowscompositionsamples.

Perecli avatar Perecli commented on May 17, 2024

Win2D is not a retained mode model and Windows.UI.XAML.Controls.Canvas in UWP is not low level enough to be performant with thousands of drawings like the visual system in WPF is. What Expression Design outputs is not specific to it but just standard XAML vector drawings. Here is an example:

<DrawingGroup x:Key="TrackCurved1_1"> <DrawingGroup.Children> <GeometryDrawing Brush="#0036A3C0" Geometry="F1 M 549,51L 549,-1L 601,-1L 601,51L 549,51 Z "/> <GeometryDrawing Brush="#FFAAAAAA" Geometry="F1 M 593.5,48.5L 595,50C 595.833,50 596.667,50 597.5,49.5833C 598.333,49.1667 599.167,48.3333 599.583,47.5C 600,46.6667 600,45.8333 600,45L 598.531,43.5313C 581.5,26.5 578.5,19.0125 578.5,5.5L 578.5,3.5C 578,3 577.5,2.5 576.583,2.25C 575.667,2 574.333,2 573.417,2.25C 572.5,2.5 572,3 571.5,3.5L 571.5,5.5C 571.5,21 575.5,30.5 593.5,48.5 Z "> <GeometryDrawing.Pen> <Pen LineJoin="Round" Brush="#FF000000"/> </GeometryDrawing.Pen> </GeometryDrawing> </DrawingGroup.Children> </DrawingGroup>

WPF consumes stuff like this very nicely. The great advantage is that you can modify these drawings at run time through a DOM once loaded from the resource files, they are hardware accelerated, they can be placed anywhere (XAML control contents, overlays, deep trees), they can be transformed and animated with 0 visual loss, and all of that in a retained mode. Expression Design, Photoshop, and other vector tool plugins can generate this XAML easy and be inserted in your WPF app with a simple cut and paste. So you're telling me there is no UWP equivalent? Are there plans to create a presentation layer as good and productive as WPF for UWP?

from windowscompositionsamples.

pgills avatar pgills commented on May 17, 2024

Thanks for the DrawingGroup example. Unfortunately, I'm unaware of any replacement/equivalent for DrawingGroup from WPF.

from windowscompositionsamples.

themoretheless avatar themoretheless commented on May 17, 2024

Draw vector in UWP canvas
http://stackoverflow.com/a/36439591

from windowscompositionsamples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.