Add minimum viable product

This commit is contained in:
Spotlight 2021-11-15 02:33:34 -06:00
commit 5a5dfb7bb2
Signed by: spotlight
GPG key ID: 874AA355B3209BDC
41 changed files with 405 additions and 0 deletions

78
SPRootViewController.m Normal file
View file

@ -0,0 +1,78 @@
#import "SPRootViewController.h"
#import "CALayer.h"
#import "CAPackage.h"
#import "CAState.h"
#import "CAStateController.h"
@interface SPRootViewController ()
- (CGImageRef)getImage:(NSString *)named;
@end
@implementation SPRootViewController
- (void)loadView {
[super loadView];
// Let's get this party started! Load our package.
NSURL *caarPath = [[NSBundle bundleForClass:NSClassFromString(@"PKPass")]
URLForResource:@"ShredderSheet"
withExtension:@"caar"];
CAPackage *package = [CAPackage packageWithContentsOfURL:caarPath
type:kCAPackageTypeArchive
options:nil
error:nil];
// Determine the frame of the unarchived root layer.
CALayer *rootLayer = [package rootLayer];
CGRect rootLayerFrame = [rootLayer frame];
// We can create a new view to harass.
// Exhilerating!
UIView *layerView = [[UIView alloc] initWithFrame:rootLayerFrame];
[[layerView layer] addSublayer:rootLayer];
[self.view addSubview:layerView];
// Ensure our package's root layer does similar, I... think.
[[package publishedObjectWithName:@"Root"] setFrame:rootLayerFrame];
// Oh, our very own state controller!
// We've grown up so quickly.
CAStateController *stateController =
[[CAStateController alloc] initWithLayer:rootLayer];
// Configure our initial state.
CAState *shreddingState = [[rootLayer states] objectAtIndex:2];
[stateController setInitialStatesOfLayer:rootLayer];
[stateController setState:shreddingState
ofLayer:rootLayer
transitionSpeed:1.0f];
// Have our wonderful, extremely 2011/2012-esque metal design.
// It's local! There's no reason not to.
[[package publishedObjectWithName:@"shredderFront"]
setContents:(id)[self getImage:@"ShredderMetal"]];
[[package publishedObjectWithName:@"shredderBack"]
setContents:(id)[self getImage:@"ShredderMetal"]];
// Set what we're shredding.
[[package publishedObjectWithName:@"cardFrontUnshredded"]
setContents:(id)[[UIColor redColor] CGColor]];
[[package publishedObjectWithName:@"cardFrontShredded"]
setContents:(id)[[UIColor blueColor] CGColor]];
[[package publishedObjectWithName:@"cardBackUnshredded"]
setContents:(id)[[UIColor blueColor] CGColor]];
}
- (CGImageRef)getImage:(NSString *)named {
NSBundle *passKitBundle =
[NSBundle bundleForClass:NSClassFromString(@"PKPass")];
NSString *filename = [NSString stringWithFormat:@"%@@2x", named];
NSString *path = [passKitBundle pathForResource:filename ofType:@"png"];
UIImage *image = [UIImage imageWithContentsOfFile:path];
return [image CGImage];
}
@end