Elmish.wpf: Recommendations for 2D and 3D graphics?

Created on 13 Dec 2019  路  7Comments  路  Source: elmish/Elmish.WPF

Does anyone know of good 2D or 3D graphics libraries that they would like to recommend? Of course libraries that are functional or "MVU-compatible" are prefered, but this is not necessary.

Here are the ones currently at the top of my list:

question

All 7 comments

I decided to go with SkiaSharp, and it is going very well. Of course I converted the mouse, single touch API, and multitouch API events to commands as demonstrated in the EventBindingsAndBehaviors sample. The only weird part was how to handle the drawing event, which I don't think is specific to SkiaSharp.

I tell SkiaSharp that I want the screen redrawn by calling UIElement.InvalidateVisual. Then SkiaSharp raises the SKCanvasView.PaintSurface event to allow me to draw. Unlike everywhere else in my Elmish.WPF application, I have to mutate the provided event args of that event. As a functional programmer, it is more accurate to say that I am pro purity/immutability than that I am anti impurity/mutability. I will mutate when I have to, and this is a situation where I must.

But Elmish.WPF requires me to return a message, so I created a case in my message type called NoOp, which returns the same model and an empty list of commands.

I think it is worth considering that we expand the binding possibilities to allow for binding functions with a "set" function that returns Unit instead of a message type.

It has been (as still is) on my TODO list to raise this concern in the much similar case of radio buttons.

Cool, thanks. So if I understand correctly you're not drawing with geometry and brushes provided by WPF? Instead you used a Skia-Control to draw? Why if I may ask? Afraid of performance issues?

Oh, huh. This may seem strange, but I didn't realize that was an option. I will definitely look into using WPF and reply here with my findings and conclusion.

:-) I will post my conclusions here as well. I already did it, but with plain C#:
WPF Custom Canvas with OnRender()

Wow, impressive! That demo looks very good.

@bender2k14 Can this be closed, or do you want it to stay open?

We can close this. I will still add comments in the future if/when I ever try 2D graphics directly in WPF (instead of via SkiaSharp).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KingKnecht picture KingKnecht  路  6Comments

BentTranberg picture BentTranberg  路  13Comments

TysonMN picture TysonMN  路  7Comments

awaynemd picture awaynemd  路  5Comments

ArthurFSharp picture ArthurFSharp  路  12Comments