Replace "percent" with "fraction" where appropriate

This commit is contained in:
Adlai Holler 2016-06-17 10:34:45 -07:00 committed by Adlai Holler
parent 49b65fd783
commit eb9f86cfdb
8 changed files with 15 additions and 15 deletions

View File

@ -83,7 +83,7 @@ typedef UIImage * _Nullable (^asimagenode_modification_block_t)(UIImage *image);
*
* @discussion This value defines a rectangle that is to be featured by the
* receiver. The rectangle is specified as a "unit rectangle," using
* percentages of the source image's width and height, e.g. CGRectMake(0.5, 0,
* fractions of the source image's width and height, e.g. CGRectMake(0.5, 0,
* 0.5, 1.0) will feature the full right half a photo. If the cropRect is
* empty, the content mode of the receiver will be used to determine its
* dimensions, and only the cropRect's origin will be used for positioning. The

View File

@ -17,7 +17,7 @@ typedef NS_ENUM(NSInteger, ASRelativeDimensionType) {
/** Just a number. It will always resolve to exactly this amount. This is the default type. */
ASRelativeDimensionTypePoints,
/** Multiplied to a provided parent amount to resolve a final amount. */
ASRelativeDimensionTypePercent,
ASRelativeDimensionTypeFraction,
};
typedef struct {
@ -44,7 +44,7 @@ extern ASRelativeDimension ASRelativeDimensionMake(ASRelativeDimensionType type,
extern ASRelativeDimension ASRelativeDimensionMakeWithPoints(CGFloat points);
extern ASRelativeDimension ASRelativeDimensionMakeWithPercent(CGFloat percent);
extern ASRelativeDimension ASRelativeDimensionMakeWithFraction(CGFloat fraction);
extern ASRelativeDimension ASRelativeDimensionCopy(ASRelativeDimension aDimension);

View File

@ -32,10 +32,10 @@ ASRelativeDimension ASRelativeDimensionMakeWithPoints(CGFloat points)
return ASRelativeDimensionMake(ASRelativeDimensionTypePoints, points);
}
ASRelativeDimension ASRelativeDimensionMakeWithPercent(CGFloat percent)
ASRelativeDimension ASRelativeDimensionMakeWithFraction(CGFloat fraction)
{
// ASDisplayNodeCAssert( 0 <= percent && percent <= 1.0, @"ASRelativeDimension percent value (%f) must be between 0 and 1.", percent);
return ASRelativeDimensionMake(ASRelativeDimensionTypePercent, percent);
// ASDisplayNodeCAssert( 0 <= fraction && fraction <= 1.0, @"ASRelativeDimension fraction value (%f) must be between 0 and 1.", fraction);
return ASRelativeDimensionMake(ASRelativeDimensionTypeFraction, fraction);
}
ASRelativeDimension ASRelativeDimensionCopy(ASRelativeDimension aDimension)
@ -53,7 +53,7 @@ NSString *NSStringFromASRelativeDimension(ASRelativeDimension dimension)
switch (dimension.type) {
case ASRelativeDimensionTypePoints:
return [NSString stringWithFormat:@"%.0fpt", dimension.value];
case ASRelativeDimensionTypePercent:
case ASRelativeDimensionTypeFraction:
return [NSString stringWithFormat:@"%.0f%%", dimension.value * 100.0];
}
}
@ -63,7 +63,7 @@ CGFloat ASRelativeDimensionResolve(ASRelativeDimension dimension, CGFloat parent
switch (dimension.type) {
case ASRelativeDimensionTypePoints:
return dimension.value;
case ASRelativeDimensionTypePercent:
case ASRelativeDimensionTypeFraction:
return dimension.value * parent;
}
}

View File

@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
A layout spec that wraps another layoutable child, applying insets around it.
If the child has a size specified as a percentage, the percentage is resolved against this spec's parent
If the child has a size specified as a fraction, the fraction is resolved against this spec's parent
size **after** applying insets.
@example ASOuterLayoutSpec contains an ASInsetLayoutSpec with an ASInnerLayoutSpec. Suppose that:

View File

@ -117,7 +117,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - ASStaticLayoutable
/**
If specified, the child's size is restricted according to this size. Percentages are resolved relative to the static layout spec.
If specified, the child's size is restricted according to this size. Fractions are resolved relative to the static layout spec.
*/
@property (nonatomic, assign) ASRelativeSizeRange sizeRange;

View File

@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol ASStaticLayoutable
/**
If specified, the child's size is restricted according to this size. Percentages are resolved relative to the static layout spec.
If specified, the child's size is restricted according to this size. Fractions are resolved relative to the static layout spec.
*/
@property (nonatomic, assign) ASRelativeSizeRange sizeRange;

View File

@ -20,7 +20,7 @@ ASDISPLAYNODE_EXTERN_C_BEGIN
@param sourceImageSize The size of the encoded image.
@param boundsSize The bounds in which the image will be displayed.
@param contentMode The mode that defines how image will be scaled and cropped to fit. Supported values are UIViewContentModeScaleToAspectFill and UIViewContentModeScaleToAspectFit.
@param cropRect A rectangle that is to be featured by the cropped image. The rectangle is specified as a "unit rectangle," using percentages of the source image's width and height, e.g. CGRectMake(0.5, 0, 0.5, 1.0) will feature the full right half a photo. If the cropRect is empty, the contentMode will be used to determine the drawRect's size, and only the cropRect's origin will be used for positioning.
@param cropRect A rectangle that is to be featured by the cropped image. The rectangle is specified as a "unit rectangle," using fractions of the source image's width and height, e.g. CGRectMake(0.5, 0, 0.5, 1.0) will feature the full right half a photo. If the cropRect is empty, the contentMode will be used to determine the drawRect's size, and only the cropRect's origin will be used for positioning.
@param forceUpscaling A boolean that indicates you would *not* like the backing size to be downscaled if the image is smaller than the destination size. Setting this to YES will result in higher memory usage when images are smaller than their destination.
@discussion If the image is smaller than the size and UIViewContentModeScaleToAspectFill is specified, we suggest the input size so it will be efficiently upscaled on the GPU by the displaying layer at composite time.
*/

View File

@ -330,7 +330,7 @@ static NSArray *defaultSubnodesWithSameSize(CGSize subnodeSize, BOOL flex)
subnode2.staticSize = {50, 50};
ASRatioLayoutSpec *child1 = [ASRatioLayoutSpec ratioLayoutSpecWithRatio:1.5 child:subnode1];
child1.flexBasis = ASRelativeDimensionMakeWithPercent(1);
child1.flexBasis = ASRelativeDimensionMakeWithFraction(1);
child1.flexGrow = YES;
child1.flexShrink = YES;
@ -508,7 +508,7 @@ static NSArray *defaultSubnodesWithSameSize(CGSize subnodeSize, BOOL flex)
[self testStackLayoutSpecWithStyle:style sizeRange:kOverflowSize subnodes:subnodes identifier:@"overflow"];
}
- (void)testPercentageFlexBasisResolvesAgainstParentSize
- (void)testFractionalFlexBasisResolvesAgainstParentSize
{
ASStackLayoutSpecStyle style = {.direction = ASStackLayoutDirectionHorizontal};
@ -520,7 +520,7 @@ static NSArray *defaultSubnodesWithSameSize(CGSize subnodeSize, BOOL flex)
// This should override the intrinsic size of 50pts and instead compute to 50% = 100pts.
// The result should be that the red box is twice as wide as the blue and gree boxes after flexing.
((ASStaticSizeDisplayNode *)subnodes[0]).flexBasis = ASRelativeDimensionMakeWithPercent(0.5);
((ASStaticSizeDisplayNode *)subnodes[0]).flexBasis = ASRelativeDimensionMakeWithFraction(0.5);
static ASSizeRange kSize = {{200, 0}, {200, INFINITY}};
[self testStackLayoutSpecWithStyle:style sizeRange:kSize subnodes:subnodes identifier:nil];