argb-ness from John
This commit is contained in:
1 parent
231f596ad7
commit
9a76d9c857
2 files changed
+12
-8
No files matched your search
@@ -16,14 +16,8 @@ namespace bts.proto {
|
||||
|
||||
public NullableColorProto(uint value) =>
|
||||
_value = value;
|
||||
|
||||
public Color? value {
|
||||
get {
|
||||
if (_value.HasValue)
|
||||
return _value.Value.rgb_color();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public Color? value => _value?.rgb_color();
|
||||
public Color? argb => _value?.argb_color();
|
||||
|
||||
public bool Equals(NullableColorProto other) =>
|
||||
EqualityComparer.nullable_equals(_value, other._value);
|
||||
|
||||
@@ -66,11 +66,18 @@ namespace mbts.ui {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: replace this method with 'argb_color'
|
||||
// - before that, need to verify that no settings/colors become 'invisible' as a result.
|
||||
public static Color rgb_color(this UInt32 color) {
|
||||
var bytes = BitConverter.GetBytes(color);
|
||||
return Color.FromRgb(bytes[2], bytes[1], bytes[0]);
|
||||
}
|
||||
|
||||
public static Color argb_color(this uint color) {
|
||||
var bytes = BitConverter.GetBytes(color);
|
||||
return Color.FromArgb(bytes[3], bytes[2], bytes[1], bytes[0]);
|
||||
}
|
||||
|
||||
public static SolidColorBrush to_brush(this BTSColor color) =>
|
||||
new SolidColorBrush(color);
|
||||
|
||||
@@ -103,6 +110,9 @@ namespace mbts.ui {
|
||||
return brush;
|
||||
}
|
||||
|
||||
public static Color with(this Color color, byte alpha) =>
|
||||
Color.FromArgb(alpha, color.R, color.G, color.B);
|
||||
|
||||
public static SolidColorBrush with(this SolidColorBrush brush, double opacity) {
|
||||
brush.Opacity = opacity;
|
||||
return brush;
|
||||
|
||||
Reference in new issue
Block a user