Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davdroman committed May 10, 2015
0 parents commit 6197975
Show file tree
Hide file tree
Showing 67 changed files with 2,700 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Xcode

build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
Binary file added Assets/1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 David Roman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
16 changes: 16 additions & 0 deletions Popsicle.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Pod::Spec.new do |s|
s.name = "Popsicle"
s.version = "1.0.0"
s.summary = "Simple, extensible value interpolation framework"
s.homepage = "https://github.com/Dromaguirre/Popsicle"
s.author = { "David Roman" => "[email protected]" }
s.license = { :type => 'MIT', :file => 'LICENSE' }

s.platform = :ios, '8.0'
s.ios.deployment_target = '8.0'

s.source = { :git => "https://github.com/Dromaguirre/Popsicle.git", :tag => s.version.to_s }
s.source_files = 'Popsicle/*.{h,m}'
s.frameworks = 'Foundation', 'UIKit'
s.requires_arc = true
end
828 changes: 828 additions & 0 deletions Popsicle.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 86 additions & 0 deletions Popsicle.xcodeproj/xcshareddata/xcschemes/Popsicle.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75CE051E1ACA133B008B893D"
BuildableName = "Popsicle.framework"
BlueprintName = "Popsicle"
ReferencedContainer = "container:Popsicle.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75CE051E1ACA133B008B893D"
BuildableName = "Popsicle.framework"
BlueprintName = "Popsicle"
ReferencedContainer = "container:Popsicle.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75CE051E1ACA133B008B893D"
BuildableName = "Popsicle.framework"
BlueprintName = "Popsicle"
ReferencedContainer = "container:Popsicle.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75CE051E1ACA133B008B893D"
BuildableName = "Popsicle.framework"
BlueprintName = "Popsicle"
ReferencedContainer = "container:Popsicle.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
26 changes: 26 additions & 0 deletions Popsicle/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>me.davidroman.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
18 changes: 18 additions & 0 deletions Popsicle/PSAffineTransformInterpolation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// PSAffineTransformInterpolation.h
// Popsicle
//
// Created by David Román Aguirre on 3/11/14.
// Copyright (c) 2014 David Roman. All rights reserved.
//

#import "PSInterpolation.h"
#import <UIKit/UIKit.h>

#define CGAffineTransformCreate(tx, ty, sx, sy, deg) CGAffineTransformRotate(CGAffineTransformConcat(CGAffineTransformMakeTranslation(tx, ty), CGAffineTransformMakeScale(sx, sy)), (deg*M_PI_2)/180)

@interface PSAffineTransformInterpolation : PSInterpolation

+ (instancetype)interpolationWithStartTime:(float)startTime endTime:(float)endTime fromValue:(CGAffineTransform)fromValue toValue:(CGAffineTransform)toValue;

@end
45 changes: 45 additions & 0 deletions Popsicle/PSAffineTransformInterpolation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// PSAffineTransformInterpolation.m
// Popsicle
//
// Created by David Román Aguirre on 3/11/14.
// Copyright (c) 2014 David Roman. All rights reserved.
//

#import "PSAffineTransformInterpolation.h"

#import "PSInterpolation+Subclass.h"

#define CGAffineTransformGetXTranslation(t) t.tx
#define CGAffineTransformGetYTranslation(t) t.ty
#define CGAffineTransformGetXScale(t) sqrt(t.a * t.a + t.c * t.c)
#define CGAffineTransformGetYScale(t) sqrt(t.b * t.b + t.d * t.d)
#define CGAffineTransformGetRotation(t) atan2f(t.b, t.a)

@implementation PSAffineTransformInterpolation

+ (instancetype)interpolationWithStartTime:(float)startTime endTime:(float)endTime fromValue:(CGAffineTransform)fromValue toValue:(CGAffineTransform)toValue {
return [super interpolationWithStartTime:startTime endTime:endTime fromValue:[NSValue valueWithCGAffineTransform:fromValue] toValue:[NSValue valueWithCGAffineTransform:toValue]];
}

- (id)valueForTimeFraction:(float)timeFraction {
CGAffineTransform fromValue = [self.fromValue CGAffineTransformValue];
CGAffineTransform toValue = [self.toValue CGAffineTransformValue];

CGFloat xTranslationInterpolation = Interpolation(fromValue.tx, toValue.tx, timeFraction);
CGFloat yTranslationInterpolation = Interpolation(fromValue.ty, toValue.ty, timeFraction);
CGAffineTransform translationValue = CGAffineTransformMakeTranslation(xTranslationInterpolation, yTranslationInterpolation);

CGFloat xScaleInterpolation = Interpolation(CGAffineTransformGetXScale(fromValue), CGAffineTransformGetXScale(toValue), timeFraction);
CGFloat yScaleInterpolation = Interpolation(CGAffineTransformGetYScale(fromValue), CGAffineTransformGetYScale(toValue), timeFraction);
CGAffineTransform scaleValue = CGAffineTransformMakeScale(xScaleInterpolation, yScaleInterpolation);

CGFloat rotationInterpolation = Interpolation(CGAffineTransformGetRotation(fromValue), CGAffineTransformGetRotation(toValue), timeFraction);
CGAffineTransform rotationValue = CGAffineTransformMakeRotation(rotationInterpolation);

CGAffineTransform value = CGAffineTransformConcat(CGAffineTransformConcat(translationValue, scaleValue), rotationValue);

return [NSValue valueWithCGAffineTransform:value];
}

@end
16 changes: 16 additions & 0 deletions Popsicle/PSColorInterpolation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// PSColorInterpolation.h
// Popsicle
//
// Created by David Román Aguirre on 3/11/14.
// Copyright (c) 2014 David Roman. All rights reserved.
//

#import "PSInterpolation.h"
#import <UIKit/UIKit.h>

@interface PSColorInterpolation : PSInterpolation

+ (instancetype)interpolationWithStartTime:(float)startTime endTime:(float)endTime fromValue:(UIColor *)fromValue toValue:(UIColor *)toValue;

@end
46 changes: 46 additions & 0 deletions Popsicle/PSColorInterpolation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// PSColorInterpolation.m
// Popsicle
//
// Created by David Román Aguirre on 3/11/14.
// Copyright (c) 2014 David Roman. All rights reserved.
//

#import "PSColorInterpolation.h"

#import "PSInterpolation+Subclass.h"

@implementation PSColorInterpolation

+ (instancetype)interpolationWithStartTime:(float)startTime endTime:(float)endTime fromValue:(UIColor *)fromValue toValue:(UIColor *)toValue {
return [super interpolationWithStartTime:startTime endTime:endTime fromValue:fromValue toValue:toValue];
}

- (id)valueForTimeFraction:(float)timeFraction {
UIColor *fromValue = self.fromValue;
UIColor *toValue = self.toValue;

CGFloat fromRed;
CGFloat fromGreen;
CGFloat fromBlue;
CGFloat fromAlpha;

CGFloat toRed;
CGFloat toGreen;
CGFloat toBlue;
CGFloat toAlpha;

[fromValue getRed:&fromRed green:&fromGreen blue:&fromBlue alpha:&fromAlpha];
[toValue getRed:&toRed green:&toGreen blue:&toBlue alpha:&toAlpha];

CGFloat redInterpolation = Interpolation(fromRed, toRed, timeFraction);
CGFloat greenInterpolation = Interpolation(fromGreen, toGreen, timeFraction);
CGFloat blueInterpolation = Interpolation(fromBlue, toBlue, timeFraction);
CGFloat alphaInterpolation = Interpolation(fromAlpha, toAlpha, timeFraction);

UIColor *value = [UIColor colorWithRed:redInterpolation green:greenInterpolation blue:blueInterpolation alpha:alphaInterpolation];

return value;
}

@end
15 changes: 15 additions & 0 deletions Popsicle/PSFloatInterpolation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// PSFloatInterpolation.h
// Popsicle
//
// Created by David Román Aguirre on 1/11/14.
// Copyright (c) 2014 David Roman. All rights reserved.
//

#import "PSInterpolation.h"

@interface PSFloatInterpolation : PSInterpolation

+ (instancetype)interpolationWithStartTime:(float)startTime endTime:(float)endTime fromValue:(float)fromValue toValue:(float)toValue;

@end
28 changes: 28 additions & 0 deletions Popsicle/PSFloatInterpolation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// PSFloatInterpolation.m
// Popsicle
//
// Created by David Román Aguirre on 1/11/14.
// Copyright (c) 2014 David Roman. All rights reserved.
//

#import "PSFloatInterpolation.h"

#import "PSInterpolation+Subclass.h"

@implementation PSFloatInterpolation

+ (instancetype)interpolationWithStartTime:(float)startTime endTime:(float)endTime fromValue:(float)fromValue toValue:(float)toValue {
return [super interpolationWithStartTime:startTime endTime:endTime fromValue:@(fromValue) toValue:@(toValue)];
}

- (id)valueForTimeFraction:(float)timeFraction {
float fromValue = [self.fromValue floatValue];
float toValue = [self.toValue floatValue];

float value = Interpolation(fromValue, toValue, timeFraction);

return @(value);
}

@end
15 changes: 15 additions & 0 deletions Popsicle/PSIntegerInterpolation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// PSIntegerInterpolation.h
// Popsicle
//
// Created by David Román Aguirre on 27/10/14.
// Copyright (c) 2014 David Roman. All rights reserved.
//

#import "PSInterpolation.h"

@interface PSIntegerInterpolation : PSInterpolation

+ (instancetype)interpolationWithStartTime:(float)startTime endTime:(float)endTime fromValue:(NSInteger)fromValue toValue:(NSInteger)toValue;

@end
28 changes: 28 additions & 0 deletions Popsicle/PSIntegerInterpolation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// PSIntegerInterpolation.m
// Popsicle
//
// Created by David Román Aguirre on 27/10/14.
// Copyright (c) 2014 David Roman. All rights reserved.
//

#import "PSIntegerInterpolation.h"

#import "PSInterpolation+Subclass.h"

@implementation PSIntegerInterpolation

+ (instancetype)interpolationWithStartTime:(float)startTime endTime:(float)endTime fromValue:(NSInteger)fromValue toValue:(NSInteger)toValue {
return [super interpolationWithStartTime:startTime endTime:endTime fromValue:@(fromValue) toValue:@(toValue)];
}

- (id)valueForTimeFraction:(float)timeFraction {
NSInteger fromValue = [self.fromValue integerValue];
NSInteger toValue = [self.toValue integerValue];

NSInteger value = (NSInteger)floor(Interpolation(fromValue, toValue, timeFraction));

return @(value);
}

@end
Loading

0 comments on commit 6197975

Please sign in to comment.