├── Rakefile ├── lib ├── gosleap │ └── version.rb └── gosleap.rb ├── proj ├── main ├── sparkle.png ├── unicorn.png ├── imageleap.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── imageleap.xccheckout │ └── project.pbxproj ├── README.md ├── Makefile ├── imageleap.1 └── main.m ├── bin ├── imageleap ├── gosling.png ├── heygurl.png └── gosleap ├── gosleap.gif ├── Gemfile ├── .gitignore ├── README.md ├── gosleap.gemspec └── LICENSE.txt /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | -------------------------------------------------------------------------------- /lib/gosleap/version.rb: -------------------------------------------------------------------------------- 1 | module Gosleap 2 | VERSION = "0.1.0" 3 | end 4 | -------------------------------------------------------------------------------- /proj/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koriroys/gosleap/HEAD/proj/main -------------------------------------------------------------------------------- /bin/imageleap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koriroys/gosleap/HEAD/bin/imageleap -------------------------------------------------------------------------------- /gosleap.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koriroys/gosleap/HEAD/gosleap.gif -------------------------------------------------------------------------------- /bin/gosling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koriroys/gosleap/HEAD/bin/gosling.png -------------------------------------------------------------------------------- /bin/heygurl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koriroys/gosleap/HEAD/bin/heygurl.png -------------------------------------------------------------------------------- /proj/sparkle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koriroys/gosleap/HEAD/proj/sparkle.png -------------------------------------------------------------------------------- /proj/unicorn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koriroys/gosleap/HEAD/proj/unicorn.png -------------------------------------------------------------------------------- /lib/gosleap.rb: -------------------------------------------------------------------------------- 1 | require "gosleap/version" 2 | 3 | module Gosleap 4 | # Your code goes here... 5 | end 6 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | # Specify your gem's dependencies in gosleap.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /bin/gosleap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | gosling_image = "#{__dir__}/gosling.png" 4 | sparkle_image = "#{__dir__}/heygurl.png" 5 | imageleap = "#{__dir__}/imageleap" 6 | 7 | system("#{imageleap} -i #{gosling_image} -p #{sparkle_image}") 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | -------------------------------------------------------------------------------- /proj/imageleap.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /proj/README.md: -------------------------------------------------------------------------------- 1 | Imageleap 2 | =========== 3 | 4 | A reimplementaion of jgdavey/unicornleap that allows you to pass an arbitrary image path. 5 | 6 | Installation 7 | ------------ 8 | 9 | ### "Automatic" installation 10 | 11 | make 12 | make install 13 | 14 | The default installation prefix is /usr/local. You can change it with 15 | the PREFIX env variable. 16 | 17 | Usage 18 | ----- 19 | 20 | imageleap 21 | -------------------------------------------------------------------------------- /proj/Makefile: -------------------------------------------------------------------------------- 1 | program_name := imageleap 2 | 3 | CFLAGS += -std=c99 4 | LDFLAGS += -framework Cocoa -framework QuartzCore 5 | PREFIX ?= /usr/local 6 | 7 | .PHONY: all clean 8 | 9 | all: $(program_name) 10 | 11 | $(program_name): main 12 | @ mkdir -p build 13 | cp main build/$(program_name) 14 | 15 | install: $(program_name) 16 | cp build/$(program_name) ${PREFIX}/bin 17 | cp $(program_name).1 $(PREFIX)/share/man/man1/ 18 | 19 | clean: 20 | @- $(RM) main 21 | @- $(RM) build/$(program_name) 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gosleap 2 | 3 | Only works on OSX 4 | 5 | ## Usage 6 | 7 | ![ryan gosling jumps across the screen](https://raw.github.com/koriroys/gosleap/master/gosleap.gif) 8 | 9 | ## Installation 10 | 11 | Add this line to your application's Gemfile: 12 | 13 | gem 'gosleap' 14 | 15 | And then execute: 16 | 17 | $ bundle 18 | 19 | Or install it yourself: 20 | 21 | $ gem install gosleap 22 | 23 | ## Contributing 24 | 25 | 1. Fork it ( http://github.com//gosleap/fork ) 26 | 2. Create your feature branch (`git checkout -b my-new-feature`) 27 | 3. Commit your changes (`git commit -am 'Add some feature'`) 28 | 4. Push to the branch (`git push origin my-new-feature`) 29 | 5. Create new Pull Request 30 | -------------------------------------------------------------------------------- /gosleap.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path("../lib", __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'gosleap/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "gosleap" 8 | spec.version = Gosleap::VERSION 9 | spec.authors = ["Kori Roys"] 10 | spec.email = ["kori@koriroys.com"] 11 | spec.summary = %q{Makes a gosling jump across your screen.} 12 | spec.description = %q{Makes a gosling jump across your screen.} 13 | spec.homepage = "" 14 | spec.license = "MIT" 15 | 16 | spec.files = `git ls-files -z`.split("\x0") 17 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 18 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 19 | spec.require_paths = ["lib"] 20 | 21 | spec.required_ruby_version = "~> 2.0" 22 | 23 | spec.add_development_dependency "bundler", "~> 1.5" 24 | spec.add_development_dependency "rake" 25 | end 26 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Kori Roys 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /proj/imageleap.1: -------------------------------------------------------------------------------- 1 | .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples. 2 | .\"See Also: 3 | .\"man mdoc.samples for a complete listing of options 4 | .\"man mdoc for the short list of editing options 5 | .\"/usr/share/misc/mdoc.template 6 | .Dd 3/5/13 7 | .Dt imageleap 1 8 | .Os Darwin 9 | .Sh NAME 10 | .Nm imageleap 11 | .Nd display a flying image 12 | .Sh SYNOPSIS 13 | .Nm 14 | .Op Fl vh \" [-vh] 15 | .Op Fl s Ar seconds \" [-a path] 16 | .Sh DESCRIPTION \" Section Header - required - don't modify 17 | .Nm 18 | makes a image fly across your screen. That's all it does. 19 | .Sh OPTIONS 20 | .Bl -tag -width "-s, --seconds n " 21 | .It Fl s , \-seconds Ar n 22 | Number of seconds for the animation to last. 23 | .br 24 | Defaults to 25 | .Ar 2.0 26 | .It Fl n , \-number Ar n 27 | Number of images to display. 28 | .br 29 | Defaults to 30 | .Ar 1 31 | .It Fl h , \-help 32 | Display help 33 | .It Fl v 34 | Slightly more output 35 | .El \" Ends the list 36 | .Pp 37 | .Sh FILES \" File used or created by the topic of the man page 38 | .Bl -tag -width "~/.imageleap/image.png" -compact 39 | .It Pa ~/.imageleap/image.png 40 | The magic image. This must exist and be a valid PNG. 41 | .It Pa ~/.imageleap/sparkle.png 42 | The image for the sparkle effect. This must exist and be a valid PNG. 43 | .El \" Ends the list 44 | -------------------------------------------------------------------------------- /proj/imageleap.xcodeproj/project.xcworkspace/xcshareddata/imageleap.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 6454C814-19C6-46EA-8C14-9E77BD0E7B49 9 | IDESourceControlProjectName 10 | imageleap 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 62733D46-5D8C-4B0F-B338-C099491106C7 14 | ssh://github.com/jgdavey/unicornleap.git 15 | 16 | IDESourceControlProjectPath 17 | imageleap.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 62733D46-5D8C-4B0F-B338-C099491106C7 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | ssh://github.com/jgdavey/unicornleap.git 25 | IDESourceControlProjectVersion 26 | 110 27 | IDESourceControlProjectWCCIdentifier 28 | 62733D46-5D8C-4B0F-B338-C099491106C7 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 62733D46-5D8C-4B0F-B338-C099491106C7 36 | IDESourceControlWCCName 37 | imageleap 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /proj/imageleap.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9A2C9C6116E6D87400F945D4 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A2C9C6016E6D87400F945D4 /* QuartzCore.framework */; }; 11 | 9A2C9C6316E6D87A00F945D4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A2C9C6216E6D87A00F945D4 /* Cocoa.framework */; }; 12 | 9A2C9C6416E6D8B000F945D4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A2C9C5D16E6D7EA00F945D4 /* main.m */; }; 13 | /* End PBXBuildFile section */ 14 | 15 | /* Begin PBXCopyFilesBuildPhase section */ 16 | 9ABBBE3A16E6D68B00E12E46 /* CopyFiles */ = { 17 | isa = PBXCopyFilesBuildPhase; 18 | buildActionMask = 2147483647; 19 | dstPath = /usr/share/man/man1/; 20 | dstSubfolderSpec = 0; 21 | files = ( 22 | ); 23 | runOnlyForDeploymentPostprocessing = 1; 24 | }; 25 | /* End PBXCopyFilesBuildPhase section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 9A2C9C5D16E6D7EA00F945D4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 29 | 9A2C9C5E16E6D7EA00F945D4 /* image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = image.png; sourceTree = ""; }; 30 | 9A2C9C5F16E6D7EA00F945D4 /* imageleap.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = imageleap.1; sourceTree = ""; }; 31 | 9A2C9C6016E6D87400F945D4 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 32 | 9A2C9C6216E6D87A00F945D4 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 33 | 9ABBBE3C16E6D68B00E12E46 /* imageleap */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = imageleap; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | /* End PBXFileReference section */ 35 | 36 | /* Begin PBXFrameworksBuildPhase section */ 37 | 9ABBBE3916E6D68B00E12E46 /* Frameworks */ = { 38 | isa = PBXFrameworksBuildPhase; 39 | buildActionMask = 2147483647; 40 | files = ( 41 | 9A2C9C6316E6D87A00F945D4 /* Cocoa.framework in Frameworks */, 42 | 9A2C9C6116E6D87400F945D4 /* QuartzCore.framework in Frameworks */, 43 | ); 44 | runOnlyForDeploymentPostprocessing = 0; 45 | }; 46 | /* End PBXFrameworksBuildPhase section */ 47 | 48 | /* Begin PBXGroup section */ 49 | 9ABBBE3316E6D68B00E12E46 = { 50 | isa = PBXGroup; 51 | children = ( 52 | 9A2C9C5D16E6D7EA00F945D4 /* main.m */, 53 | 9A2C9C5E16E6D7EA00F945D4 /* image.png */, 54 | 9A2C9C5F16E6D7EA00F945D4 /* imageleap.1 */, 55 | 9ABBBE3E16E6D68B00E12E46 /* Frameworks */, 56 | 9ABBBE3D16E6D68B00E12E46 /* Products */, 57 | ); 58 | sourceTree = ""; 59 | }; 60 | 9ABBBE3D16E6D68B00E12E46 /* Products */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | 9ABBBE3C16E6D68B00E12E46 /* imageleap */, 64 | ); 65 | name = Products; 66 | sourceTree = ""; 67 | }; 68 | 9ABBBE3E16E6D68B00E12E46 /* Frameworks */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 9A2C9C6016E6D87400F945D4 /* QuartzCore.framework */, 72 | 9A2C9C6216E6D87A00F945D4 /* Cocoa.framework */, 73 | ); 74 | name = Frameworks; 75 | sourceTree = ""; 76 | }; 77 | /* End PBXGroup section */ 78 | 79 | /* Begin PBXNativeTarget section */ 80 | 9ABBBE3B16E6D68B00E12E46 /* imageleap */ = { 81 | isa = PBXNativeTarget; 82 | buildConfigurationList = 9ABBBE4816E6D68B00E12E46 /* Build configuration list for PBXNativeTarget "imageleap" */; 83 | buildPhases = ( 84 | 9ABBBE3816E6D68B00E12E46 /* Sources */, 85 | 9ABBBE3916E6D68B00E12E46 /* Frameworks */, 86 | 9ABBBE3A16E6D68B00E12E46 /* CopyFiles */, 87 | ); 88 | buildRules = ( 89 | ); 90 | dependencies = ( 91 | ); 92 | name = imageleap; 93 | productName = imageleap; 94 | productReference = 9ABBBE3C16E6D68B00E12E46 /* imageleap */; 95 | productType = "com.apple.product-type.tool"; 96 | }; 97 | /* End PBXNativeTarget section */ 98 | 99 | /* Begin PBXProject section */ 100 | 9ABBBE3416E6D68B00E12E46 /* Project object */ = { 101 | isa = PBXProject; 102 | attributes = { 103 | LastUpgradeCheck = 0460; 104 | ORGANIZATIONNAME = "Joshua Davey"; 105 | }; 106 | buildConfigurationList = 9ABBBE3716E6D68B00E12E46 /* Build configuration list for PBXProject "imageleap" */; 107 | compatibilityVersion = "Xcode 3.2"; 108 | developmentRegion = English; 109 | hasScannedForEncodings = 0; 110 | knownRegions = ( 111 | en, 112 | ); 113 | mainGroup = 9ABBBE3316E6D68B00E12E46; 114 | productRefGroup = 9ABBBE3D16E6D68B00E12E46 /* Products */; 115 | projectDirPath = ""; 116 | projectRoot = ""; 117 | targets = ( 118 | 9ABBBE3B16E6D68B00E12E46 /* imageleap */, 119 | ); 120 | }; 121 | /* End PBXProject section */ 122 | 123 | /* Begin PBXSourcesBuildPhase section */ 124 | 9ABBBE3816E6D68B00E12E46 /* Sources */ = { 125 | isa = PBXSourcesBuildPhase; 126 | buildActionMask = 2147483647; 127 | files = ( 128 | 9A2C9C6416E6D8B000F945D4 /* main.m in Sources */, 129 | ); 130 | runOnlyForDeploymentPostprocessing = 0; 131 | }; 132 | /* End PBXSourcesBuildPhase section */ 133 | 134 | /* Begin XCBuildConfiguration section */ 135 | 9ABBBE4616E6D68B00E12E46 /* Debug */ = { 136 | isa = XCBuildConfiguration; 137 | buildSettings = { 138 | ALWAYS_SEARCH_USER_PATHS = NO; 139 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 140 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 141 | CLANG_CXX_LIBRARY = "libc++"; 142 | CLANG_WARN_CONSTANT_CONVERSION = YES; 143 | CLANG_WARN_EMPTY_BODY = YES; 144 | CLANG_WARN_ENUM_CONVERSION = YES; 145 | CLANG_WARN_INT_CONVERSION = YES; 146 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 147 | COPY_PHASE_STRIP = NO; 148 | GCC_C_LANGUAGE_STANDARD = gnu99; 149 | GCC_DYNAMIC_NO_PIC = NO; 150 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 151 | GCC_OPTIMIZATION_LEVEL = 0; 152 | GCC_PREPROCESSOR_DEFINITIONS = ( 153 | "DEBUG=1", 154 | "$(inherited)", 155 | ); 156 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 157 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 158 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 159 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 160 | GCC_WARN_UNUSED_VARIABLE = YES; 161 | MACOSX_DEPLOYMENT_TARGET = 10.8; 162 | ONLY_ACTIVE_ARCH = YES; 163 | SDKROOT = macosx; 164 | }; 165 | name = Debug; 166 | }; 167 | 9ABBBE4716E6D68B00E12E46 /* Release */ = { 168 | isa = XCBuildConfiguration; 169 | buildSettings = { 170 | ALWAYS_SEARCH_USER_PATHS = NO; 171 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 172 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 173 | CLANG_CXX_LIBRARY = "libc++"; 174 | CLANG_WARN_CONSTANT_CONVERSION = YES; 175 | CLANG_WARN_EMPTY_BODY = YES; 176 | CLANG_WARN_ENUM_CONVERSION = YES; 177 | CLANG_WARN_INT_CONVERSION = YES; 178 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 179 | COPY_PHASE_STRIP = YES; 180 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 181 | GCC_C_LANGUAGE_STANDARD = gnu99; 182 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 183 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 184 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 185 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 186 | GCC_WARN_UNUSED_VARIABLE = YES; 187 | MACOSX_DEPLOYMENT_TARGET = 10.8; 188 | SDKROOT = macosx; 189 | }; 190 | name = Release; 191 | }; 192 | 9ABBBE4916E6D68B00E12E46 /* Debug */ = { 193 | isa = XCBuildConfiguration; 194 | buildSettings = { 195 | PRODUCT_NAME = "$(TARGET_NAME)"; 196 | }; 197 | name = Debug; 198 | }; 199 | 9ABBBE4A16E6D68B00E12E46 /* Release */ = { 200 | isa = XCBuildConfiguration; 201 | buildSettings = { 202 | PRODUCT_NAME = "$(TARGET_NAME)"; 203 | }; 204 | name = Release; 205 | }; 206 | /* End XCBuildConfiguration section */ 207 | 208 | /* Begin XCConfigurationList section */ 209 | 9ABBBE3716E6D68B00E12E46 /* Build configuration list for PBXProject "imageleap" */ = { 210 | isa = XCConfigurationList; 211 | buildConfigurations = ( 212 | 9ABBBE4616E6D68B00E12E46 /* Debug */, 213 | 9ABBBE4716E6D68B00E12E46 /* Release */, 214 | ); 215 | defaultConfigurationIsVisible = 0; 216 | defaultConfigurationName = Release; 217 | }; 218 | 9ABBBE4816E6D68B00E12E46 /* Build configuration list for PBXNativeTarget "imageleap" */ = { 219 | isa = XCConfigurationList; 220 | buildConfigurations = ( 221 | 9ABBBE4916E6D68B00E12E46 /* Debug */, 222 | 9ABBBE4A16E6D68B00E12E46 /* Release */, 223 | ); 224 | defaultConfigurationIsVisible = 0; 225 | defaultConfigurationName = Release; 226 | }; 227 | /* End XCConfigurationList section */ 228 | }; 229 | rootObject = 9ABBBE3416E6D68B00E12E46 /* Project object */; 230 | } 231 | -------------------------------------------------------------------------------- /proj/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #include 4 | #include 5 | #include 6 | 7 | const char* program_name; 8 | double seconds; 9 | const char* short_options = "hs:n:i:e:p:v"; 10 | const struct option long_options[] = { 11 | { "help", 0, NULL, 'h' }, 12 | { "seconds", 1, NULL, 's' }, 13 | { "image", 1, NULL, 'i' }, 14 | { "sparkle", 1, NULL, 'p' }, 15 | { "verbose", 0, NULL, 'v' }, 16 | { NULL, 0, NULL, 0 } /* Required at end of array. */ 17 | }; 18 | 19 | void invalid_image(FILE* stream, char * path) { 20 | fprintf (stream, "ERROR: You must have a valid PNG image at %s\n", path); 21 | exit(127); 22 | } 23 | 24 | void print_usage (FILE* stream, int exit_code) { 25 | fprintf (stream, "Usage: %s [options]\n", program_name); 26 | fprintf (stream, 27 | " -h --help Display this usage information.\n" 28 | " -s --seconds n Animate for n seconds. (default: 2.0)\n" 29 | " -i --image Custom image to use.\n" 30 | " -p --sparkle Custom sparkle image to use.\n" 31 | " -v --verbose Print verbose messages.\n"); 32 | exit (exit_code); 33 | } 34 | 35 | CGMutablePathRef pathInFrameForSize (CGRect screen, CGSize size) { 36 | CGMutablePathRef path = CGPathCreateMutable(); 37 | CGPoint origin = CGPointMake(-size.width, -size.height); 38 | CGPoint destination = CGPointMake(screen.size.width + size.width, origin.y); 39 | CGFloat midpoint = (destination.x + origin.x) / 2.0; 40 | CGFloat peak = (screen.size.height + size.height) / 2.0; 41 | CGPathMoveToPoint(path, NULL, origin.x, origin.y); 42 | 43 | CGPathAddCurveToPoint(path, NULL, midpoint, peak, 44 | midpoint, peak, 45 | destination.x, destination.y); 46 | return path; 47 | }; 48 | 49 | void animateLayerAlongPathForKey (CALayer *layer, CGMutablePathRef path, NSString *key) { 50 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:key]; 51 | [animation setPath: path]; 52 | [animation setDuration: seconds]; 53 | [animation setCalculationMode: kCAAnimationLinear]; 54 | [animation setRotationMode: nil]; 55 | [layer addAnimation:animation forKey:key]; 56 | } 57 | 58 | CALayer * layerForImageWithSize(CGImageRef image, CGSize size) { 59 | CALayer *layer = [CALayer layer]; 60 | 61 | [layer setContents: (id)(image)]; 62 | [layer setBounds:CGRectMake(0.0, 0.0, size.width, size.height)]; 63 | [layer setPosition:CGPointMake(-size.width, -size.height)]; 64 | 65 | return layer; 66 | } 67 | 68 | NSWindow * createTransparentWindow(CGRect screen) { 69 | NSWindow *window = [[NSWindow alloc] initWithContentRect: screen styleMask: NSBorderlessWindowMask 70 | backing: NSBackingStoreBuffered 71 | defer: NO]; 72 | [window setBackgroundColor:[NSColor colorWithCalibratedHue:0 saturation:0 brightness:0 alpha:0.0]]; 73 | [window setOpaque: NO]; 74 | [window setIgnoresMouseEvents:YES]; 75 | [window setLevel: NSFloatingWindowLevel]; 76 | 77 | return window; 78 | } 79 | 80 | CGSize getImageSize(NSString *imagePath) { 81 | NSImage *image = [[NSImage alloc] initWithContentsOfFile: imagePath]; 82 | if (![image isValid]) { 83 | invalid_image(stderr, (char *)[imagePath UTF8String]); 84 | } 85 | 86 | CGSize imageSize = image.size; 87 | 88 | [image dealloc]; 89 | return imageSize; 90 | } 91 | 92 | CGImageRef createCGImage(NSString *imagePath) { 93 | CGDataProviderRef source = CGDataProviderCreateWithFilename([imagePath UTF8String]); 94 | NSString* theFileName = [imagePath pathExtension]; 95 | CGImageRef cgimage; 96 | if ([theFileName isEqualToString: @"png"]) { 97 | cgimage = CGImageCreateWithPNGDataProvider(source, NULL, true, 0); 98 | } 99 | if ([theFileName isEqualToString: @"jpg"] || [theFileName isEqualToString: @"jpeg"]) { 100 | cgimage = CGImageCreateWithJPEGDataProvider(source, NULL, true, 0); 101 | } 102 | return cgimage; 103 | } 104 | 105 | CAEmitterLayer * getEmitterForImageInFrame (CGImageRef sparkleImage, CGSize imageSize) { 106 | static float base = 4.0; 107 | 108 | CAEmitterLayer *emitter = [[CAEmitterLayer alloc] init]; 109 | emitter.emitterPosition = CGPointMake(-imageSize.width, -imageSize.height); 110 | emitter.emitterSize = CGSizeMake(imageSize.width, imageSize.height); 111 | CAEmitterCell *sparkle = [CAEmitterCell emitterCell]; 112 | 113 | sparkle.contents = (id)(sparkleImage); 114 | 115 | sparkle.birthRate = 20.0/seconds + 15.0; 116 | sparkle.lifetime = 20.0; 117 | sparkle.lifetimeRange = 5.0; 118 | sparkle.name = @"sparkle"; 119 | 120 | // Fade from white to purple 121 | //sparkle.color = CGColorCreateGenericRGB(1.0, 1.0, 1.0, 1.0); 122 | //sparkle.greenSpeed = -0.7; 123 | 124 | sparkle.minificationFilter = kCAFilterNearest; 125 | 126 | // Fade out 127 | sparkle.alphaSpeed = -1.0; 128 | 129 | // Shrink 130 | sparkle.scale = 2.0; 131 | sparkle.scaleRange = 2.0; 132 | sparkle.scaleSpeed = -1.0; 133 | 134 | // Fall away 135 | sparkle.velocity = -20.0; 136 | sparkle.velocityRange = 20.0; 137 | sparkle.yAcceleration = -100.0; 138 | sparkle.xAcceleration = -50.0; 139 | 140 | // Spin 141 | //sparkle.spin = -2.0; 142 | //sparkle.spinRange = 4.0; 143 | 144 | emitter.renderMode = kCAEmitterLayerAdditive; 145 | emitter.emitterShape = kCAEmitterLayerCuboid; 146 | emitter.emitterCells = [NSArray arrayWithObject:sparkle]; 147 | return emitter; 148 | } 149 | 150 | void animateImage (const char* goslingPathString, const char* sparklePathString) { 151 | NSString *goslingImagePath = [NSString stringWithFormat: @"%s" , goslingPathString]; 152 | NSString *sparkleImagePath = [NSString stringWithFormat: @"%s" , sparklePathString]; 153 | 154 | // Objective C 155 | [NSApplication sharedApplication]; 156 | CGRect screen = NSScreen.mainScreen.frame; 157 | NSWindow *window = createTransparentWindow(screen); 158 | NSView *view = [[NSView alloc] initWithFrame:screen]; 159 | // NSString *imagePath = [NSString stringWithFormat: @"%s" , 1]; 160 | 161 | // NSString *folder = [NSHomeDirectory() stringByAppendingPathComponent:@".unicornleap"]; 162 | // NSString *folder = getcwd; 163 | // NSFileManager *NSFm; 164 | // NSString *folder = @"./"; 165 | // NSString *folder = [[NSFm currentDirectoryPath] stringByAppendingPathComponent]; 166 | // NSString *imagePath = [folder stringByAppendingPathComponent:@"gosling.png"]; 167 | // NSString *sparklePath = [folder stringByAppendingPathComponent:@"heygurl.png"]; 168 | 169 | CGSize imageSize = getImageSize(goslingImagePath); 170 | CGImageRef cgimage = createCGImage(goslingImagePath); 171 | CGMutablePathRef arcPath; 172 | arcPath = pathInFrameForSize(screen, imageSize); 173 | CALayer *layer; 174 | CAEmitterLayer *emitter; 175 | double waitFor = seconds/2.5; 176 | NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; 177 | layer = layerForImageWithSize(cgimage, imageSize); 178 | 179 | 180 | 181 | 182 | CGDataProviderRef sparkleSource = CGDataProviderCreateWithFilename([sparkleImagePath UTF8String]); 183 | CGImageRef sparkleImage = CGImageCreateWithPNGDataProvider(sparkleSource, NULL, true, 0); 184 | emitter = getEmitterForImageInFrame(sparkleImage, imageSize); 185 | 186 | [window setContentView: view]; 187 | [window makeKeyAndOrderFront: nil]; 188 | 189 | [view setWantsLayer: YES]; 190 | [view.layer addSublayer: layer]; 191 | [view.layer addSublayer: emitter]; 192 | 193 | animateLayerAlongPathForKey(layer, arcPath, @"position"); 194 | animateLayerAlongPathForKey(emitter, arcPath, @"emitterPosition"); 195 | 196 | [runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow: waitFor]]; 197 | 198 | // Wait for animation to finish 199 | [runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow: seconds - waitFor + 0.2]]; 200 | [goslingImagePath release]; 201 | [goslingImagePath release]; 202 | [view release]; 203 | [window release]; 204 | return; 205 | } 206 | 207 | int main (int argc, char * argv[]) { 208 | program_name = argv[0]; 209 | 210 | // Defaults 211 | char* s = NULL; 212 | char* i = NULL; 213 | 214 | const char* image_path; 215 | const char* sparkle_path; 216 | int verbose = 0, num = 1; 217 | double sec = 2.0; 218 | 219 | // Parse options 220 | int next_option; 221 | 222 | do { 223 | next_option = getopt_long(argc, argv, short_options, long_options, NULL); 224 | switch(next_option) 225 | { 226 | case 's': 227 | s = optarg; 228 | break; 229 | 230 | case 'v': 231 | verbose = 1; 232 | break; 233 | 234 | case 'i': 235 | image_path = optarg; 236 | break; 237 | 238 | case 'p': 239 | sparkle_path = optarg; 240 | break; 241 | 242 | case 'h': print_usage(stdout, 0); 243 | case '?': print_usage(stderr, 1); 244 | case -1: break; 245 | default: abort(); 246 | } 247 | } while (next_option != -1); 248 | 249 | // Coerce string to double 250 | if (NULL != s) sec = strtod(s, NULL); 251 | if (! sec > 0.0) sec = 2.0; 252 | seconds = sec; 253 | 254 | if (verbose) { 255 | printf("Seconds: %f\n", seconds); 256 | printf("Image: %s\n", image_path); 257 | printf("Sparkle: %s\n", sparkle_path); 258 | } 259 | 260 | animateImage(image_path, sparkle_path); 261 | 262 | return 0; 263 | } 264 | --------------------------------------------------------------------------------