Essentials: System.Drawing.Color Platform Helpers

Created on 17 Apr 2018  路  6Comments  路  Source: xamarin/Essentials

Using System.Drawing.Color as our cross-platform color we should simply have platform helpers that do converstions:

  • ToPlatformColor()
  • ToSystemColor()

Also to System.Drawing.Color:

  • AddLuminosity
  • FromHex
  • FromHsla
  • FromRgb
  • FromUint
  • MultiplyAlpha
  • WithHue
  • WithLuminosity
  • WithSaturdation
in-progress

Most helpful comment

@jamesmontemagno I saw you knocked this out a while back, but just wanted to say thanks! Its great to see you guys so responsive in your issues.

All 6 comments

Just a note:
https://docs.microsoft.com/en-us/dotnet/api/system.drawing?view=netstandard-2.0

Color is available in .NET Standard 2.0

so maybe some helpers to do to and from for each platform? maybe we should drop netstandard1.0?

@jamesmontemagno just wanted to check if you thought more on the platform converters. I'm new to xamarin (but I'm coming from native mobile), so I wasn't sure what the 'best practice' would be in terms of how to structure this in a cross-platform consumable way.

Any thoughts on going from System.Drawing.Color to UIColor/android.graphics.Color?

Yeah, that is a good idea. let me re-open. They are part of Forms, but we can bring over the platform helpers.

Might also want some helpers that go the other way like System.Drawing.Color.FromUIColor(UIColor color)? I'm not sure if those exist in the SDK's themselves or not. It's also possible we want extension methods for UIColor to do this, or maybe both?

@jamesmontemagno I saw you knocked this out a while back, but just wanted to say thanks! Its great to see you guys so responsive in your issues.

Was this page helpful?
0 / 5 - 0 ratings