forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support CompositionStretch and [Horizontal|Vertical]AlignmentRa…
…tio and use that for ImageBrush
- Loading branch information
1 parent
f3f0051
commit b0854ef
Showing
4 changed files
with
163 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
namespace Windows.Foundation; | ||
|
||
internal static class SizeExtensions | ||
{ | ||
internal static double AspectRatio(this Size size) | ||
{ | ||
var w = size.Width; | ||
var h = size.Height; | ||
switch (w) | ||
{ | ||
case double.NegativeInfinity: | ||
return -1; | ||
case double.PositiveInfinity: | ||
return 1; | ||
case double.NaN: | ||
return 1; | ||
case 0.0d: | ||
return 1; | ||
} | ||
switch (h) | ||
{ | ||
case double.NegativeInfinity: | ||
return -1; | ||
case double.PositiveInfinity: | ||
return 1; | ||
case double.NaN: | ||
return 1; | ||
case 0.0d: | ||
return 1; // special case | ||
case 1.0d: | ||
return w; | ||
} | ||
return w / h; | ||
} | ||
|
||
#if __IOS__ || __MACOS__ | ||
internal static double AspectRatio(this CoreGraphics.CGSize size) | ||
{ | ||
var w = size.Width; | ||
var h = size.Height; | ||
if (w == nfloat.NegativeInfinity) | ||
{ | ||
return -1; | ||
} | ||
else if (w == nfloat.PositiveInfinity) | ||
{ | ||
return 1; | ||
} | ||
else if (w == nfloat.NaN) | ||
{ | ||
return 1; | ||
} | ||
else if (w == 0.0d) | ||
{ | ||
return 1; | ||
} | ||
if (h == nfloat.NegativeInfinity) | ||
{ | ||
return -1; | ||
} | ||
else if (h == nfloat.PositiveInfinity) | ||
{ | ||
return 1; | ||
} | ||
else if (h == nfloat.NaN) | ||
{ | ||
return 1; | ||
} | ||
else if (h == 0.0d) | ||
{ | ||
return 1; // special case | ||
} | ||
else if (h == 1.0d) | ||
{ | ||
return w; | ||
} | ||
return w / h; | ||
} | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters