/libs/ObjectAL/Actions/OALFunction.h
C Header | 266 lines | 55 code | 57 blank | 154 comment | 0 complexity | b11ec31c955839e9f1566b4c9bc60790 MD5 | raw file
Possible License(s): Apache-2.0
1// 2// OALFunction.h 3// ObjectAL 4// 5// Created by Karl Stenerud on 10-08-22. 6// 7// Copyright 2010 Karl Stenerud 8// 9// Licensed under the Apache License, Version 2.0 (the "License"); 10// you may not use this file except in compliance with the License. 11// You may obtain a copy of the License at 12// 13// http://www.apache.org/licenses/LICENSE-2.0 14// 15// Unless required by applicable law or agreed to in writing, software 16// distributed under the License is distributed on an "AS IS" BASIS, 17// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18// See the License for the specific language governing permissions and 19// limitations under the License. 20// 21// Note: You are NOT required to make the license available from within your 22// iOS application. Including it in your project is sufficient. 23// 24// Attribution is not required, but appreciated :) 25// 26 27#import <Foundation/Foundation.h> 28#import "SynthesizeSingleton.h" 29 30 31#pragma mark OALFunction 32 33/** 34 * A function takes a value from 0.0 to 1.0 and returns 35 * another value from 0.0 to 1.0. 36 */ 37@protocol OALFunction 38 39 40#pragma mark Function 41 42/** Calculate the function value. 43 * 44 * @param inputValue A value from 0.0 to 1.0 45 * @return The resulting value, which will also be from 0.0 to 1.0. 46 */ 47- (float) valueForInput:(float) inputValue; 48 49@end 50 51 52 53#pragma mark - 54#pragma mark OALLinearFunction 55 56/** Function that changes at a constant rate. 57 * <pre> 58 ## 59 ## 60 ## 61 ## 62 ## 63 ## 64 ## 65 ## 66 ## 67 ## 68 ## 69 </pre> 70 */ 71@interface OALLinearFunction : NSObject <OALFunction> 72{ 73} 74 75 76#pragma mark Object Management 77 78/** Singleton implementation providing "sharedInstance" and "purgeSharedInstance" methods. 79 * 80 * <b>- (OALLinearFunction*) sharedInstance</b>: Get the shared singleton instance. <br> 81 * <b>- (void) purgeSharedInstance</b>: Purge (deallocate) the shared instance. 82 */ 83SYNTHESIZE_SINGLETON_FOR_CLASS_HEADER(OALLinearFunction); 84 85/** Generate an instance of this function. 86 * 87 * @return An instance of this function. 88 */ 89+ (id) function; 90 91@end 92 93 94 95#pragma mark - 96#pragma mark OALSCurveFunction 97 98/** Changes slowly at the start, quickly at the midpoint, then slowly 99 * again at the end. 100 * <pre> 101 #### 102 ### 103 ## 104 # 105 # 106 # 107 # 108 # 109 ## 110 ### 111 #### 112 </pre> 113 */ 114@interface OALSCurveFunction : NSObject <OALFunction> 115{ 116} 117 118 119#pragma mark Object Management 120 121/** Singleton implementation providing "sharedInstance" and "purgeSharedInstance" methods. 122 * 123 * <b>- (OALSCurveFunction*) sharedInstance</b>: Get the shared singleton instance. <br> 124 * <b>- (void) purgeSharedInstance</b>: Purge (deallocate) the shared instance. 125 */ 126SYNTHESIZE_SINGLETON_FOR_CLASS_HEADER(OALSCurveFunction); 127 128/** Generate an instance of this function. 129 * 130 * @return An instance of this function. 131 */ 132+ (id) function; 133 134@end 135 136 137 138#pragma mark - 139#pragma mark OALExponentialFunction 140 141/** Changes slowly at the start, and quickly at the end. 142 * <pre> 143 # 144 # 145 # 146 # 147 # 148 # 149 ## 150 ### 151 #### 152 ##### 153 ###### 154 </pre> 155 */ 156@interface OALExponentialFunction : NSObject <OALFunction> 157{ 158} 159 160 161#pragma mark Object Management 162 163/** Singleton implementation providing "sharedInstance" and "purgeSharedInstance" methods. 164 * 165 * <b>- (OALExponentialFunction*) sharedInstance</b>: Get the shared singleton instance. <br> 166 * <b>- (void) purgeSharedInstance</b>: Purge (deallocate) the shared instance. 167 */ 168SYNTHESIZE_SINGLETON_FOR_CLASS_HEADER(OALExponentialFunction); 169 170/** Generate an instance of this function. 171 * 172 * @return An instance of this function. 173 */ 174+ (id) function; 175 176@end 177 178 179 180#pragma mark - 181#pragma mark OALLogarithmicFunction 182 183/** Changes quickly at the start, and slowly at the end. 184 * <pre> 185 ###### 186 ##### 187 #### 188 ### 189 ## 190 # 191 # 192 # 193 # 194 # 195 # 196 </pre> 197 */ 198@interface OALLogarithmicFunction : NSObject <OALFunction> 199{ 200} 201 202 203#pragma mark Object Management 204 205/** Singleton implementation providing "sharedInstance" and "purgeSharedInstance" methods. 206 * 207 * <b>- (OALLogarithmicFunction*) sharedInstance</b>: Get the shared singleton instance. <br> 208 * <b>- (void) purgeSharedInstance</b>: Purge (deallocate) the shared instance. 209 */ 210SYNTHESIZE_SINGLETON_FOR_CLASS_HEADER(OALLogarithmicFunction); 211 212/** Generate an instance of this function. 213 * 214 * @return An instance of this function. 215 */ 216+ (id) function; 217 218@end 219 220 221 222#pragma mark - 223#pragma mark OALReverseFunction 224 225/** Returns the reverse of another function. 226 * For example, a linear up ramp will become a linear down ramp: 227 * <pre> 228 | Before: | After: | 229 | ## | ## | 230 | ## | ## | 231 | ## | ## | 232 | ## | ## | 233 | ## | ## | 234 | ## | ## | 235 </pre> 236 */ 237@interface OALReverseFunction : NSObject <OALFunction> 238{ 239 id<OALFunction, NSObject> function; 240} 241 242 243#pragma mark Properties 244 245/** The function which will have its value reversed. */ 246@property(readwrite,retain) id<OALFunction, NSObject> function; 247 248 249#pragma mark Object Management 250 251/** Create a new reverse function. 252 * 253 * @param function The function to reverse. 254 * @return the new reversed function. 255 */ 256+ (id) functionWithFunction:(id<OALFunction, NSObject>) function; 257 258/** Initialize a reverse function. 259 * 260 * @param function The function to reverse. 261 * @return the initialized reversed function. 262 */ 263- (id) initWithFunction:(id<OALFunction, NSObject>) function; 264 265 266@end