Files
react-native-svg/apple/Brushes/RNSVGPainterBrush.mm
Wojciech Lewicki 98c14b4f45 chore: add CI for JS, iOS and Android formatting (#1782)
Added CI workflow and local pre-commit hook for formatting and linting the newly added JS, iOS and Android code.
2022-08-16 12:00:32 +02:00

45 lines
1.0 KiB
Plaintext

/**
* Copyright (c) 2015-present, Horcrux.
* All rights reserved.
*
* This source code is licensed under the MIT-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "RNSVGPainterBrush.h"
#import <React/RCTLog.h>
#import "RCTConvert+RNSVG.h"
#import "RNSVGPainter.h"
@implementation RNSVGPainterBrush
- (instancetype)initWithArray:(NSArray *)array
{
if ((self = [super initWithArray:array])) {
if (array.count != 2) {
RCTLogError(@"-[%@ %@] expects 2 elements, received %@", self.class, NSStringFromSelector(_cmd), array);
return nil;
}
self.brushRef = [array objectAtIndex:1];
}
return self;
}
- (void)paint:(CGContextRef)context opacity:(CGFloat)opacity painter:(RNSVGPainter *)painter bounds:(CGRect)bounds
{
BOOL transparency = opacity < 1;
if (transparency) {
CGContextSetAlpha(context, opacity);
CGContextBeginTransparencyLayer(context, NULL);
}
[painter paint:context bounds:bounds];
if (transparency) {
CGContextEndTransparencyLayer(context);
}
}
@end