react-native-camera-kit/ios/lib/ReactNativeCameraKit/CKOverlayObject.m

53 lines
1.1 KiB
Mathematica
Raw Normal View History

2016-07-19 09:42:13 +00:00
//
// CKOverlayObject.m
// ReactNativeCameraKit
//
// Created by Ran Greenberg on 17/07/2016.
// Copyright © 2016 Wix. All rights reserved.
//
#import "CKOverlayObject.h"
@interface CKOverlayObject ()
@property (nonatomic, readwrite) float width;
@property (nonatomic, readwrite) float height;
@property (nonatomic, readwrite) float ratio;
@end
@implementation CKOverlayObject
-(instancetype)initWithString:(NSString*)str {
self = [super init];
if (self) {
[self commonInit:str];
}
return self;
}
-(void)commonInit:(NSString*)str {
NSArray<NSString*> *array = [str componentsSeparatedByString:@":"];
if (array.count == 2) {
2016-07-21 07:04:46 +00:00
float height = [array[0] floatValue];
float width = [array[1] floatValue];
2016-07-19 09:42:13 +00:00
2016-07-21 07:04:46 +00:00
if (width != 0 && height != 0) {
self.width = width;
self.height = height;
2016-07-19 09:42:13 +00:00
self.ratio = self.width/self.height;
}
}
}
-(NSString *)description {
return [NSString stringWithFormat:@"width:%f height:%f ratio:%f", self.width, self.height, self.ratio];
}
@end