mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-16 10:30:08 +00:00
54 lines
1.5 KiB
Objective-C
54 lines
1.5 KiB
Objective-C
//
|
|
// LOTMask.m
|
|
// LottieAnimator
|
|
//
|
|
// Created by Brandon Withrow on 12/14/15.
|
|
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
|
//
|
|
|
|
#import "LOTMask.h"
|
|
#import "LOTAnimatableShapeValue.h"
|
|
#import "LOTAnimatableNumberValue.h"
|
|
|
|
@implementation LOTMask
|
|
|
|
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
|
self = [super init];
|
|
if (self) {
|
|
[self _mapFromJSON:jsonDictionary frameRate:frameRate];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)_mapFromJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
|
NSNumber *closed = jsonDictionary[@"cl"];
|
|
_closed = closed.boolValue;
|
|
|
|
NSNumber *inverted = jsonDictionary[@"inv"];
|
|
_inverted = inverted.boolValue;
|
|
|
|
NSString *mode = jsonDictionary[@"mode"];
|
|
if ([mode isEqualToString:@"a"]) {
|
|
_maskMode = LOTMaskModeAdd;
|
|
} else if ([mode isEqualToString:@"s"]) {
|
|
_maskMode = LOTMaskModeSubtract;
|
|
} else if ([mode isEqualToString:@"i"]) {
|
|
_maskMode = LOTMaskModeIntersect;
|
|
} else {
|
|
_maskMode = LOTMaskModeUnknown;
|
|
}
|
|
|
|
NSDictionary *maskshape = jsonDictionary[@"pt"];
|
|
if (maskshape) {
|
|
_maskPath = [[LOTAnimatableShapeValue alloc] initWithShapeValues:maskshape frameRate:frameRate closed:_closed];
|
|
}
|
|
|
|
NSDictionary *opacity = jsonDictionary[@"o"];
|
|
if (opacity) {
|
|
_opacity = [[LOTAnimatableNumberValue alloc] initWithNumberValues:opacity frameRate:frameRate];
|
|
[_opacity remapValuesFromMin:@0 fromMax:@100 toMin:@0 toMax:@1];
|
|
}
|
|
}
|
|
|
|
@end
|