Skip to content

Commit

Permalink
Fabric: Implementation of insetBy(Rect, EdgeInsets) -> Rect
Browse files Browse the repository at this point in the history
Summary:
A function in graphics/geometry which adjusts a rectangle by the given edge insets.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22284644

fbshipit-source-id: ad78abd7889b4457c450b2cc43fb73054aef2c79
  • Loading branch information
shergin authored and facebook-github-bot committed Jun 29, 2020
1 parent 8c14d51 commit 559c60c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ReactCommon/fabric/graphics/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@ using EdgeInsets = RectangleEdges<Float>;
*/
using CornerInsets = RectangleCorners<Float>;

/*
* Adjusts a rectangle by the given edge insets.
*/
inline Rect insetBy(Rect rect, EdgeInsets insets) {
return Rect{{rect.origin.x + insets.left, rect.origin.y + insets.top},
{rect.size.width - insets.left - insets.right,
rect.size.height - insets.top - insets.bottom}};
}

} // namespace react
} // namespace facebook

Expand Down

0 comments on commit 559c60c

Please sign in to comment.