question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: [Using Composition with Canvas]

See original GitHub issue

Hello,

I want to build a desktop app with WinUI3, to allow draw some simple diagrams like flowsheet, etc, show texts along with lines or blocks.

in WPF I can either inherit from DrawingVisual object or Shape object. but I don’t find enough examples to do this in C++/WinRT + WinUI3.

Question 1: what’s the proper way to do it in WinUi3? I’m trying to use Microsoft.UI.Composition to do this, but I don’t find a similar class like DrawingVisual, in WPF by inherit DrawingVisual, I can draw shapes or paths and render text in derived classes.

Question 2: should I use Microsoft.UI.Xaml.Shapes.Shape class as base instead? 2000 lines might be expected as the worst case in the future, to be zoomed in or out, or moved , selected something like that. is there any performance concern if I use Microsoft.UI.Xaml.Shapes.Shape ?

Question 3: should I use Microsoft.UI.Composition.CompositionSpriteShape as base class? or other class(please advise), if so, should it be a runtimeclass ,or just a normal C++ class? is *.idl file required?

Question 4: I want to render text along with these shapes, what’s the right way to do so. just simple description is fine to me.

too less resource in C++/WinRT, what a pity… I have found some like this, and now just trying to do it in C++/WinRT.

Thank you!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chrkoncommented, Mar 17, 2022

Another option: https://github.com/microsoft/Win2D

Win2D is a good Option. Just drawing on a SwapChainPanel. See Introduction or Win2D-WinUI3 WithoutControls

1reaction
kmgallahancommented, Mar 10, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Inheritance vs Composition for canvas shapes model?
So, here's my ideas, but with most design question, there's rarely ever one "correct" answer. Like you said, a State is not a...
Read more >
HTML5 Canvas - Composition
HTML5 canvas provides compositing attribute globalCompositeOperation which affect all the drawing operations. We can draw new shapes behind existing shapes and ...
Read more >
Compositing and clipping - Canvas API - MDN Web Docs
This sets the type of compositing operation to apply when drawing new shapes, where type is a string identifying which of the twelve...
Read more >
HTML5 Canvas Composition and Its Attributes
Assuming you are trying to compose two different images, the image you draw first is the "source" and the second image is the...
Read more >
New Quizzes: Display Question Titles to Students
We are using Canvas to deliver Quiz content in a secure, timed way. ... Listening Comprehension, Short Answer, Essay or Composition.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found