Conversation
expand by half a pixel to prevent anti-aliasing
Axes can now Draw() themselves and measure their size. A TightenLayout() method can be called to initiate measuring/fitting the layout to the size of the axis labels and ticks labels. In GUI controls tightening does not occur while dragging, but does occur after the mouse is dropped.
|
This PR created a functional from-scratch MVP implementation of ScottPlot using a preview package of Things I Learned
Next Steps
|
|
One reason to go with SkiaSharp directly is that it supports being compiled to WebAssembly, whereas, as far as I know, Maui.Graphics does not support this. I'm not sure if running as WebAssembly is of interest to yourself or others, but it is to me at least. |
|
Hi @erichiller, thank you for pointing this out! Browser support would be fantastic, and it's impressive to see the recent work that has been done to get SkiaSharp working in Blazor apps using WebAssembly. I'll spend some time this morning researching more about what can be done using SkiaSharp/Blazor with existing packages. However, it appears that Maui.Graphics has Blazor project that is being actively developed: I suspect that once Maui and Maui.Graphics releases, there will be NuGet packages for all the main platforms, including Blazor. I recognize targeting SkiaSharp directly would allow development to progress immediately, but I'm trying to hold-out a little more to see what Maui produces as it nears GA release. The choice between one or the other affects so much code in this library, and influences the public API with things that seem trivial but are far-reaching like whether the arguments expect |
|
Ok, that makes total sense. Is it safe to assume that ScottPlot 5 using Maui.Graphics would work on Avalonia & Linux using |
I think so, because at its core My plan is to start by exclusively making ScottPlot5 controls that use SkiaSharp. I'll create a SkiaSharp The win here is that later if a user wants to swap-out SkiaSharp with GDK or ImageSharp, they can, and none of ScottPlot's core drawing routines have to be modified. This is the promise anyway. The library still isn't fully released, and the API is still implementing breaking changes. We'll see how it shakes out as it stabilizes! PS: a working proof-of-concept is already in https://github.com/ScottPlot/ScottPlot/tree/main/dev/ScottPlot5 and it compiles on Linux but I haven't extensively tested it yet, nor have I made an Avalonia control for it. |
|
FWIW Maui just hit a stable release, so this may be worth another look soon. |
I agree! I've been gearing-up to make this post for a little while... Maui.Graphics has been in RC for a few weeks now, and likely to have its first official release this week, so we know pretty much what to expect. My Assessment
Conclusions
Next Steps
|
|
Following-up, A little time will help reveal the trajectory of .NET Maui, but the GA is pretty sketch. I find many comments on the official blog extremely negative (and I think are being pruned). .NET Maui has "released" but it's still not available in Visual Studio and requires a preview version of VS 😅 I'm going to hold my assessment for a few more months and give the dust a little time to settle. It's possible thing thing could still land in a good place, and wow I'd really love to use it, but we'll see how the next bit of time goes. Biggest remaining sticking points are no support for accurate string measurement and extremely limited support for line styles. I also realized a compromise could be to use |
I think if we have a reasonable expectation that we might switch libraries again we should write our own color classes rather than use the color classes of the most likely replacement. It prevents us from being tied to a specific library, especially an incomplete one. It may also be easier for us to port existing code if we write a (partial) re-implementation of I haven't looked deeply into A lot of those concerns are minor, provided that we expect Maui Graphics to be supported and up-to-date for a long time (although we could've reasonably expected that from System.Drawing.Common, and the two libraries do share a parent company). Minor concerns that would be more than balanced if we were getting some benefit from Maui Graphics over SkiaSharp. But I don't think they are balanced simply using the library in order to use another. |
|
EDIT: There's more up-to-date code under the MIT license The full text of the Microsoft Reference Source License is as follows (with my interpretation afterwards): LicenseMICROSOFT REFERENCE SOURCE LICENSE (MS-RSL)This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
The terms "reproduce," "reproduction" and "distribution" have the same meaning here as under U.S. copyright law. "You" means the licensee of the software. "Your company" means the company you worked for when you downloaded the software. "Reference use" means use of the software within your company as a reference, in read only form, for the sole purposes of debugging your products, maintaining your products, or enhancing the interoperability of your products with the software, and specifically excludes the right to distribute the software outside of your company. "Licensed patents" means any Licensor patent claims which read directly on the software as distributed by the Licensor under this license.
(A) Copyright Grant- Subject to the terms of this license, the Licensor grants you a non-transferable, non-exclusive, worldwide, royalty-free copyright license to reproduce the software for reference use. (B) Patent Grant- Subject to the terms of this license, the Licensor grants you a non-transferable, non-exclusive, worldwide, royalty-free patent license under licensed patents for reference use.
(A) No Trademark License- This license does not grant you any rights to use the Licensor's name, logo, or trademarks. (B) If you begin patent litigation against the Licensor over patents that you think may apply to the software (including a cross-claim or counterclaim in a lawsuit), your license to the software ends automatically. (C) The software is licensed "as-is." You bear the risk of using it. The Licensor gives no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the Licensor excludes the implied warranties of merchantability, fitness for a particular purpose and non-infringement. The meat of my concerns is whether us referencing the reference source in order to partially reimplement the API of There is another interpretation of "enhancing the interoperability of your products with the software", it may mean either that we may reference it in enhancing how ScottPlot interops with System.Drawing, or we may reference the software to enhance the interop (without saying what it enhances the interoperability with). This interpretation is unconvincing to me, because it's not how a normal person would read it, nor is it how Microsoft likely intended it to be read. Especially given the history of this license as a way to encourage companies to stay in the Microsoft ecosystem. Ambiguity in a contract does benefit the party who did not draft it, but I'm unsure if this counts as ambiguous. |
|
There's more up-to-date source code under the MIT license, we could copy-paste it if we wanted to: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Drawing.Primitives/src/System/Drawing/Color.cs You can safely ignore the above comment, unless you enjoy the pontification of someone with no legal education. |
ScottPlot 5 will use its own
|
|
That is cool, but I think users would expect them to match the named web colours, which are the same names that most graphics libraries use. Even though it means dark gray is lighter than gray. |
True - web colors will definitely be the ScottPlot defaults because they're widely used and known. According to WPF docs their colors are based on UNIX X11 named colors. It looks like web colors extend this set: https://en.wikipedia.org/wiki/Web_colors#X11_color_names
lol, this came up this week in Maui.Graphics land dotnet/Microsoft.Maui.Graphics#449
I'd love to add XKCD colors somehow because they are so expressive. I'm thinking of accessing them like |
Color: struct to define R, G, B, and A values defining a color Colors: quick access to common colors by name (defaults are web color keywords) NamedColors: namespace for additional color packs (e.g., xkcd colors, windows colors, etc) See color API discussion in #1647
https://github.com/ScottPlot/ScottPlot/blob/master/dev/roadmap.md