mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 09:45:04 +00:00
Fabric: Using ColorComponents
in colorFromComponents
function
Summary: Trivial. We have a special data structure for it, why do not use it here? Reviewed By: mdvacca Differential Revision: D7738577 fbshipit-source-id: 750aa649b06f17d27906d44df07172a907cde2e5
This commit is contained in:
parent
139db66a3e
commit
9d08e2afae
@ -13,11 +13,17 @@
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
SharedColor colorFromComponents(float red, float green, float blue, float alpha) {
|
||||
const CGFloat components[] = {red, green, blue, alpha};
|
||||
SharedColor colorFromComponents(ColorComponents components) {
|
||||
const CGFloat componentsArray[] = {
|
||||
components.red,
|
||||
components.green,
|
||||
components.blue,
|
||||
components.alpha
|
||||
};
|
||||
|
||||
CGColorRef color = CGColorCreate(
|
||||
CGColorSpaceCreateDeviceRGB(),
|
||||
components
|
||||
componentsArray
|
||||
);
|
||||
|
||||
return SharedColor(color, CFRelease);
|
||||
|
@ -23,7 +23,7 @@ struct ColorComponents {
|
||||
float alpha {0};
|
||||
};
|
||||
|
||||
SharedColor colorFromComponents(float red, float green, float blue, float alpha);
|
||||
SharedColor colorFromComponents(ColorComponents components);
|
||||
ColorComponents colorComponentsFromColor(SharedColor color);
|
||||
|
||||
} // namespace react
|
||||
|
@ -36,7 +36,7 @@ SharedColor colorFromDynamic(const folly::dynamic &value) {
|
||||
abort();
|
||||
}
|
||||
|
||||
return colorFromComponents(red, green, blue, alpha);
|
||||
return colorFromComponents({red, green, blue, alpha});
|
||||
}
|
||||
|
||||
std::string colorNameFromColor(const SharedColor &value) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user